37 real** offload_array) {
39 int n_rho = offload_data->
n_rho;
40 int n_time = offload_data->
n_time;
44 "Min rho = %1.2le, Max rho = %1.2le,"
45 " Number of rho grid points = %d\n",
46 (*offload_array)[0], (*offload_array)[n_rho-1], n_rho);
48 "Min time = %1.2le, Max time = %1.2le,"
49 " Number of time points = %d\n",
50 (*offload_array)[n_rho], (*offload_array)[n_rho+n_time-1],n_time);
52 "Number of ion species = %d\n", n_ions);
54 "Species Z/A charge [e]/mass [amu] "
55 "Density [m^-3] at Min/Max rho(t=t0)"
56 " Temperature [eV] at Min/Max rho(t=t0)\n");
57 for(
int i=0; i < n_ions; i++) {
59 " %3d /%3d %3d /%7.3f %1.2le/%1.2le "
61 offload_data->
znum[i], offload_data->
anum[i],
64 (*offload_array)[2*n_rho*n_time + n_time + n_rho*(3+i)],
65 (*offload_array)[2*n_rho*n_time + n_time + n_rho*(4+i) - 1],
66 (*offload_array)[n_time + n_rho*2] /
CONST_E,
67 (*offload_array)[n_time + n_rho*3-1] /
CONST_E);
70 "[electrons] %3d /%7.3f %1.2le/%1.2le "
73 (*offload_array)[2*n_rho*n_time + n_time + n_rho*1],
74 (*offload_array)[2*n_rho*n_time + n_time + n_rho*2 - 1],
75 (*offload_array)[n_time + n_rho*1] /
CONST_E,
76 (*offload_array)[n_time + n_rho*2 - 1] /
CONST_E);
77 real quasineutrality = 0;
78 for(
int k = 0; k <n_rho; k++) {
80 (*offload_array)[2*n_rho*n_time + n_time + n_rho + k] *
CONST_E;
82 for(
int i=0; i < n_ions; i++) {
83 int idx = 2*n_rho*n_time + n_time + n_rho * (2+1) + k;
85 (*offload_array)[idx] * offload_data->
charge[i+1];
87 quasineutrality = fmax( quasineutrality,
88 fabs( 1 - ion_qdens / ele_qdens ) );
91 " %.2f\n", 1+quasineutrality);
104 real** offload_array) {
105 free(*offload_array);
106 *offload_array = NULL;
122 real* offload_array) {
128 for(
int i = 0; i < pls_data->
n_species; i++) {
129 pls_data->
mass[i] = offload_data->
mass[i];
132 pls_data->
rho = &offload_array[0];
133 pls_data->
time = &offload_array[pls_data->
n_rho];
161 *temp = temp_temp[species];
188 *dens = temp_dens[species];
212 if(rho < pls_data->rho[0]) {
215 else if(rho >= pls_data->
rho[pls_data->
n_rho-1]) {
220 while(i_rho < pls_data->n_rho-1 && pls_data->
rho[i_rho] <= rho) {
225 real t_rho = (rho - pls_data->
rho[i_rho])
226 / (pls_data->
rho[i_rho+1] - pls_data->
rho[i_rho]);
229 while(i_time < pls_data->n_time-1 && pls_data->
time[i_time] <= t) {
234 real t_time = (t - pls_data->
time[i_time])
235 / (pls_data->
time[i_time+1] - pls_data->
time[i_time]);
242 else if(i_time >= pls_data->
n_time-2) {
244 i_time = pls_data->
n_time-2;
248 for(
int i = 0; i < pls_data->
n_species; i++) {
249 real p11, p12, p21, p22, p1, p2;
264 p1 = p11 + t_rho * (p12 - p11);
265 p2 = p21 + t_rho * (p22 - p21);
267 dens[i] = p1 + t_time * (p2 - p1);
271 p11 = pls_data->
temp[i_time*2*pls_data->
n_rho
274 p12 = pls_data->
temp[i_time*2*pls_data->
n_rho
277 p21 = pls_data->
temp[(i_time+1)*2*pls_data->
n_rho
280 p22 = pls_data->
temp[(i_time+1)*2*pls_data->
n_rho
284 p1 = p11 + t_rho * (p12 - p11);
285 p2 = p21 + t_rho * (p22 - p21);
287 temp[i] = p1 + t_time * (p2 - p1);
Main header file for ASCOT5.
#define MAX_SPECIES
Maximum number of plasma species.
Header file containing physical and mathematical constants.
#define CONST_U
Atomic mass unit in kilograms [kg]
#define CONST_M_E
Electron mass [kg]
#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.
void plasma_1Dt_free_offload(plasma_1Dt_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
int plasma_1Dt_init_offload(plasma_1Dt_offload_data *offload_data, real **offload_array)
Initialize 1Dt plasma data and check inputs.
a5err plasma_1Dt_eval_densandtemp(real *dens, real *temp, real rho, real t, plasma_1Dt_data *pls_data)
Evaluate plasma density and temperature for all species.
a5err plasma_1Dt_eval_temp(real *temp, real rho, real t, int species, plasma_1Dt_data *pls_data)
Evaluate plasma temperature.
a5err plasma_1Dt_eval_dens(real *dens, real rho, real t, int species, plasma_1Dt_data *pls_data)
Evaluate plasma density.
void plasma_1Dt_init(plasma_1Dt_data *pls_data, plasma_1Dt_offload_data *offload_data, real *offload_array)
Initialize magnetic field data struct on target.
Header file for plasma_1Dt.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
1D plasma parameters on the target
1D plasma parameters that will be offloaded to target