ASCOT5
Loading...
Searching...
No Matches
asigma.c
Go to the documentation of this file.
1
21#include <stdlib.h>
22#include <stdio.h>
23#include <math.h>
24#include "ascot5.h"
25#include "print.h"
26#include "error.h"
27#include "math.h"
28#include "asigma.h"
29#include "asigma/asigma_loc.h"
30#include "consts.h"
31
32#pragma omp declare target
34static int ASIGMA_EXTRAPOLATE = 0;
35#pragma omp end declare target
36
45void asigma_extrapolate(int extrapolate) {
46 ASIGMA_EXTRAPOLATE = extrapolate;
47}
48
67 real** offload_array) {
68 int err = 0;
69
70 switch(offload_data->type) {
71
72 case asigma_type_loc:
73 err = asigma_loc_init_offload(&(offload_data->asigma_loc),
74 offload_array);
75 offload_data->offload_array_length =
76 offload_data->asigma_loc.offload_array_length;
77 break;
78
79 default:
80 /* Unrecognized input. Produce error. */
81 print_err("Error: Unrecognized atomic reaction data type.");
82 err = 1;
83 break;
84 }
85 if(!err) {
86 print_out(VERBOSE_IO, "Estimated memory usage %.1f MB\n",
87 offload_data->offload_array_length
88 * sizeof(real) / (1024.0*1024.0) );
89 }
90
91 return err;
92}
93
105 real** offload_array) {
106 switch(offload_data->type) {
107 case asigma_type_loc:
108 asigma_loc_free_offload(&(offload_data->asigma_loc), offload_array);
109 break;
110 }
111}
112
127 real* offload_array) {
128 int err = 0;
129 switch(offload_data->type) {
130 case asigma_type_loc:
132 &(offload_data->asigma_loc), offload_array);
133 break;
134
135 default:
136 /* Unrecognized input. Produce error. */
137 print_err("Error: Unrecognized atomic reaction data type.");
138 err = 1;
139 break;
140 }
141 asigma_data->type = offload_data->type;
142
143 return err;
144}
145
167 real* sigma, int z_1, int a_1, int z_2, int a_2, real E_coll_per_amu,
169 a5err err = 0;
170
171 switch(asigma_data->type) {
172 case asigma_type_loc:
174 sigma, z_1, a_1, z_2, a_2, E_coll_per_amu, reac_type,
176 break;
177
178 default:
179 /* Unrecognized input. Produce error. */
180 err = error_raise( ERR_UNKNOWN_INPUT, __LINE__, EF_ASIGMA );
181 break;
182 }
183 if(err || sigma[0] < 0.0) {
184 /* In case of error or unphysical negative value, return zero value
185 to avoid further complications */
186 sigma[0] = 0.0;
187 }
188
189 return err;
190}
191
217 real* sigmav, int z_1, int a_1, real m_1, int z_2, int a_2,
218 real E, real T_e, real T_0, real n_i, asigma_reac_type reac_type,
220 a5err err = 0;
221
222 switch(asigma_data->type) {
223 case asigma_type_loc:
225 sigmav, z_1, a_1, m_1, z_2, a_2, E, T_e, T_0, n_i,
227 break;
228
229 default:
230 /* Unrecognized input. Produce error. */
231 err = error_raise( ERR_UNKNOWN_INPUT, __LINE__, EF_ASIGMA );
232 break;
233 }
234 if(err || sigmav[0] < 0.0) {
235 /* In case of error or unphysical negative value, return zero value
236 to avoid further complications */
237 sigmav[0] = 0.0;
238 }
239
240 return err;
241}
242
263 real* ratecoeff, int z_1, int a_1, real E, real mass, int nspec,
264 const int* znum, const int* anum, real T_0, real* n_0,
266 a5err err = 0;
267
268 switch(asigma_data->type) {
269 case asigma_type_loc:
270 err = asigma_loc_eval_cx(
271 ratecoeff, z_1, a_1, E, mass, nspec, znum, anum, T_0, n_0,
273 break;
274
275 default:
276 /* Unrecognized input. Produce error. */
277 err = error_raise( ERR_UNKNOWN_INPUT, __LINE__, EF_ASIGMA );
278 break;
279 }
280 if(err || ratecoeff[0] < 0.0) {
281 /* In case of error or unphysical negative value, return zero value
282 to avoid further complications */
283 ratecoeff[0] = 0.0;
284 }
285
286 return err;
287}
288
309 real* ratecoeff, int z_1, int a_1, real E, real mass, int nion,
310 const int* znum, const int* anum, real T_e, real* n_i,
312 a5err err = 0;
313
314 switch(asigma_data->type) {
315 case asigma_type_loc:
317 ratecoeff, z_1, a_1, E, mass, nion, znum, anum, T_e, n_i,
319 break;
320
321 default:
322 /* Unrecognized input. Produce error. */
323 err = error_raise( ERR_UNKNOWN_INPUT, __LINE__, EF_ASIGMA );
324 break;
325 }
326 if(err || ratecoeff[0] < 0.0) {
327 /* In case of error or unphysical negative value, return zero value
328 to avoid further complications */
329 ratecoeff[0] = 0.0;
330 }
331
332 return err;
333}
Main header file for ASCOT5.
double real
Definition ascot5.h:85
static int ASIGMA_EXTRAPOLATE
Definition asigma.c:34
a5err asigma_eval_sigma(real *sigma, int z_1, int a_1, int z_2, int a_2, real E_coll_per_amu, asigma_reac_type reac_type, asigma_data *asigma_data)
Evaluate atomic reaction cross-section.
Definition asigma.c:166
a5err asigma_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, asigma_data *asigma_data)
Evaluate charge exchange rate coefficient.
Definition asigma.c:262
void asigma_extrapolate(int extrapolate)
Toggle extrapolation when evaluating cross sections.
Definition asigma.c:45
void asigma_free_offload(asigma_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
Definition asigma.c:104
int asigma_init(asigma_data *asigma_data, asigma_offload_data *offload_data, real *offload_array)
Initializes atomic reaction data struct on target.
Definition asigma.c:126
a5err asigma_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, asigma_reac_type reac_type, asigma_data *asigma_data)
Evaluate atomic reaction rate coefficient.
Definition asigma.c:216
a5err asigma_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, asigma_data *asigma_data)
Evaluate beam stopping rate coefficient.
Definition asigma.c:308
int asigma_init_offload(asigma_offload_data *offload_data, real **offload_array)
Load atomic reaction data and prepare parameters.
Definition asigma.c:66
Header file for asigma.c.
asigma_reac_type
Reaction types for atomic reaction data.
Definition asigma.h:34
@ asigma_type_loc
Definition asigma.h:24
void asigma_loc_free_offload(asigma_loc_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
Definition asigma_loc.c:197
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.
Definition asigma_loc.c:477
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.
Definition asigma_loc.c:309
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.
Definition asigma_loc.c:216
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.
Definition asigma_loc.c:384
int asigma_loc_init_offload(asigma_loc_offload_data *offload_data, real **offload_array)
Initialize local file atomic data and check inputs.
Definition asigma_loc.c:52
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.
Definition asigma_loc.c:549
Header file for asigma_loc.c.
Header file containing physical and mathematical constants.
Error module for ASCOT5.
unsigned long int a5err
Simulation error flag.
Definition error.h:17
@ EF_ASIGMA
Definition error.h:51
@ ERR_UNKNOWN_INPUT
Definition error.h:64
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.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
Definition print.h:31
@ VERBOSE_IO
Definition print.h:20
#define print_err(...)
Print to standard error.
Definition print.h:42
Atomic reaction simulation data.
Definition asigma.h:66
asigma_type type
Definition asigma.h:67
asigma_loc_data asigma_loc
Definition asigma.h:68
Atomic reaction offload data.
Definition asigma.h:53
asigma_type type
Definition asigma.h:54
asigma_loc_offload_data asigma_loc
Definition asigma.h:55
int offload_array_length
Definition asigma.h:57