40 real** offload_array) {
42 int n_rho = offload_data->
n_rho;
46 "Min rho = %1.2le, Max rho = %1.2le,"
47 " Number of rho grid points = %d,"
48 " Number of ion species = %d\n",
49 (*offload_array)[0], (*offload_array)[n_rho-1], n_rho, n_ions);
51 "Species Z/A charge [e]/mass [amu] Density [m^-3] at Min/Max rho"
52 " Temperature [eV] at Min/Max rho\n");
53 for(
int i=0; i < n_ions; i++) {
55 " %3d /%3d %3d /%7.3f %1.2le/%1.2le "
57 offload_data->
znum[i], offload_data->
anum[i],
60 (*offload_array)[n_rho*(4+i)],
61 (*offload_array)[n_rho*(5+i) - 1],
62 (*offload_array)[n_rho*2] /
CONST_E,
63 (*offload_array)[n_rho*3-1] /
CONST_E);
66 "[electrons] %3d /%7.3f %1.2le/%1.2le "
69 (*offload_array)[n_rho*3],
70 (*offload_array)[n_rho*4 - 1],
71 (*offload_array)[n_rho] /
CONST_E,
72 (*offload_array)[n_rho*2-1] /
CONST_E);
73 real quasineutrality = 0;
74 for(
int k = 0; k <n_rho; k++) {
75 real ele_qdens = (*offload_array)[n_rho*3 + k] *
CONST_E;
77 for(
int i=0; i < n_ions; i++) {
79 (*offload_array)[n_rho*(4+i) + k] * offload_data->
charge[i+1];
81 quasineutrality = fmax( quasineutrality,
82 fabs( 1 - ion_qdens / ele_qdens ) );
85 " %.2f\n", 1+quasineutrality);
98 real** offload_array) {
100 *offload_array = NULL;
116 real* offload_array) {
121 for(
int i = 0; i < pls_data->
n_species; i++) {
122 pls_data->
mass[i] = offload_data->
mass[i];
124 pls_data->
znum[i] = offload_data->
znum[i];
125 pls_data->
anum[i] = offload_data->
anum[i];
127 pls_data->
rho = &offload_array[0];
128 pls_data->
temp = &offload_array[pls_data->
n_rho];
129 pls_data->
dens = &offload_array[pls_data->
n_rho*3];
149 if(rho < pls_data->rho[0]) {
152 else if(rho >= pls_data->
rho[pls_data->
n_rho-1]) {
157 while(i_rho < pls_data->n_rho - 1 && pls_data->
rho[i_rho] <= rho) {
161 real t_rho = (rho - pls_data->
rho[i_rho])
162 / (pls_data->
rho[i_rho+1] - pls_data->
rho[i_rho]);
166 temp[0] = p1 + t_rho * (p2 - p1);
189 if(rho < pls_data->rho[0]) {
192 else if(rho >= pls_data->
rho[pls_data->
n_rho-1]) {
197 while(i_rho < pls_data->n_rho - 1 && pls_data->
rho[i_rho] <= rho) {
201 real t_rho = (rho - pls_data->
rho[i_rho])
202 / (pls_data->
rho[i_rho+1] - pls_data->
rho[i_rho]);
206 dens[0] = p1 + t_rho * (p2 - p1);
228 if(rho < pls_data->rho[0]) {
231 else if(rho >= pls_data->
rho[pls_data->
n_rho-1]) {
236 while(i_rho < pls_data->n_rho-1 && pls_data->
rho[i_rho] <= rho) {
241 real t_rho = (rho - pls_data->
rho[i_rho])
242 / (pls_data->
rho[i_rho+1] - pls_data->
rho[i_rho]);
245 for(
int i = 0; i < pls_data->
n_species; i++) {
246 p1 = pls_data->
dens[i*pls_data->
n_rho + i_rho];
247 p2 = pls_data->
dens[i*pls_data->
n_rho + i_rho+1];
248 dens[i] = p1 + t_rho * (p2 - p1);
252 p1 = pls_data->
temp[i*pls_data->
n_rho + i_rho];
253 p2 = pls_data->
temp[i*pls_data->
n_rho + i_rho+1];
254 temp[i] = p1 + t_rho * (p2 - p1);
Main header file for ASCOT5.
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_1D_init(plasma_1D_data *pls_data, plasma_1D_offload_data *offload_data, real *offload_array)
Initialize magnetic field data struct on target.
a5err plasma_1D_eval_dens(real *dens, real rho, int species, plasma_1D_data *pls_data)
Evaluate plasma density.
a5err plasma_1D_eval_densandtemp(real *dens, real *temp, real rho, plasma_1D_data *pls_data)
Evaluate plasma density and temperature for all species.
void plasma_1D_free_offload(plasma_1D_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
a5err plasma_1D_eval_temp(real *temp, real rho, int species, plasma_1D_data *pls_data)
Evaluate plasma temperature.
int plasma_1D_init_offload(plasma_1D_offload_data *offload_data, real **offload_array)
Initialize 1D plasma data and check inputs.
Header file for plasma_1D.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