ASCOT5
Loading...
Searching...
No Matches
plasma.c
Go to the documentation of this file.
1
23#include <stdio.h>
24#include <stdlib.h>
25#include "ascot5.h"
26#include "error.h"
27#include "print.h"
28#include "plasma.h"
29#include "plasma/plasma_1D.h"
30#include "plasma/plasma_1DS.h"
31#include "consts.h"
32
39 switch(data->type) {
40 case plasma_type_1D:
42 break;
43 case plasma_type_1Dt:
45 break;
46 case plasma_type_1DS:
48 break;
49 }
50}
51
58 switch(data->type) {
59 case plasma_type_1D:
61 break;
62 case plasma_type_1Dt:
64 break;
65 case plasma_type_1DS:
67 break;
68 }
69}
70
90a5err plasma_eval_temp(real* temp, real rho, real r, real phi, real z, real t,
91 int species, plasma_data* pls_data) {
92 a5err err = 0;
93
94 switch(pls_data->type) {
95 case plasma_type_1D:
96 err = plasma_1D_eval_temp(temp, rho, species,
97 &(pls_data->plasma_1D));
98 break;
99
100 case plasma_type_1Dt:
101 err = plasma_1Dt_eval_temp(temp, rho, t, species,
102 &(pls_data->plasma_1Dt));
103 break;
104
105 case plasma_type_1DS:
106 err = plasma_1DS_eval_temp(temp, rho, species,
107 &(pls_data->plasma_1DS));
108 break;
109 }
110 if(err) {
111 /* In case of error, return some reasonable value to avoid further
112 complications */
113 temp[0] = 1e20;
114 }
115
116 return err;
117}
118
138a5err plasma_eval_dens(real* dens, real rho, real r, real phi, real z, real t,
139 int species, plasma_data* pls_data) {
140 a5err err = 0;
141
142 switch(pls_data->type) {
143 case plasma_type_1D:
144 err = plasma_1D_eval_dens(dens, rho, species,
145 &(pls_data->plasma_1D));
146 break;
147
148 case plasma_type_1Dt:
149 err = plasma_1Dt_eval_dens(dens, rho, t, species,
150 &(pls_data->plasma_1Dt));
151 break;
152
153 case plasma_type_1DS:
154 err = plasma_1DS_eval_dens(dens, rho, species,
155 &(pls_data->plasma_1DS));
156 break;
157 }
158
159 if(err) {
160 /* In case of error, return some reasonable value to avoid further
161 complications */
162 dens[0] = 1e20;
163 }
164 return err;
165}
166
187 real r, real phi, real z, real t,
188 plasma_data* pls_data) {
189 a5err err = 0;
190
191 switch(pls_data->type) {
192 case plasma_type_1D:
193 err = plasma_1D_eval_densandtemp(dens, temp,
194 rho, &(pls_data->plasma_1D));
195 break;
196
197 case plasma_type_1Dt:
198 err = plasma_1Dt_eval_densandtemp(dens, temp,
199 rho, t, &(pls_data->plasma_1Dt));
200 break;
201
202 case plasma_type_1DS:
203 err = plasma_1DS_eval_densandtemp(dens, temp,
204 rho, &(pls_data->plasma_1DS));
205 break;
206
207 default:
208 /* Unregonized input. Produce error. */
209 err = error_raise( ERR_UNKNOWN_INPUT, __LINE__, EF_PLASMA );
210 break;
211 }
212
213 if(err) {
214 /* In case of error, return some reasonable values to avoid further
215 complications */
216 for(int i=0; i<MAX_SPECIES; i++) {
217 dens[i] = 1e20;
218 temp[i] = 1e3;
219 }
220 }
221
222 return err;
223}
224
238 int n = 0;
239 switch(pls_data->type) {
240 case plasma_type_1D:
241 n = pls_data->plasma_1D.n_species;
242 break;
243
244 case plasma_type_1Dt:
245 n = pls_data->plasma_1Dt.n_species;
246 break;
247
248 case plasma_type_1DS:
249 n = pls_data->plasma_1DS.n_species;
250 break;
251 }
252
253 return n;
254}
255
268 const real* mass = NULL;
269 switch(pls_data->type) {
270 case plasma_type_1D:
271 mass = pls_data->plasma_1D.mass;
272 break;
273
274 case plasma_type_1Dt:
275 mass = pls_data->plasma_1Dt.mass;
276 break;
277
278 case plasma_type_1DS:
279 mass = pls_data->plasma_1DS.mass;
280 break;
281 }
282
283 return mass;
284}
285
298 const real* charge = NULL;
299 switch(pls_data->type) {
300 case plasma_type_1D:
301 charge = pls_data->plasma_1D.charge;
302 break;
303
304 case plasma_type_1Dt:
305 charge = pls_data->plasma_1Dt.charge;
306 break;
307
308 case plasma_type_1DS:
309 charge = pls_data->plasma_1DS.charge;
310 break;
311 }
312
313 return charge;
314}
315
326 const int* znum = NULL;
327 switch(pls_data->type) {
328 case plasma_type_1D:
329 znum = pls_data->plasma_1D.znum;
330 break;
331
332 case plasma_type_1Dt:
333 znum = pls_data->plasma_1Dt.znum;
334 break;
335
336 case plasma_type_1DS:
337 znum = pls_data->plasma_1DS.znum;
338 break;
339 }
340
341 return znum;
342}
343
354 const int* anum = NULL;
355 switch(pls_data->type) {
356 case plasma_type_1D:
357 anum = pls_data->plasma_1D.anum;
358 break;
359
360 case plasma_type_1Dt:
361 anum = pls_data->plasma_1Dt.anum;
362 break;
363
364 case plasma_type_1DS:
365 anum = pls_data->plasma_1DS.anum;
366 break;
367 }
368
369 return anum;
370}
Main header file for ASCOT5.
double real
Definition ascot5.h:85
#define MAX_SPECIES
Maximum number of plasma species.
Definition ascot5.h:95
Header file containing physical and mathematical constants.
Error module for ASCOT5.
unsigned long int a5err
Simulation error flag.
Definition error.h:17
@ EF_PLASMA
Definition error.h:42
@ 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
void plasma_free(plasma_data *data)
Free allocated resources.
Definition plasma.c:38
const real * plasma_get_species_mass(plasma_data *pls_data)
Get mass of all plasma species.
Definition plasma.c:267
const int * plasma_get_species_znum(plasma_data *pls_data)
Get charge number of ion species.
Definition plasma.c:325
int plasma_get_n_species(plasma_data *pls_data)
Get the number of plasma species.
Definition plasma.c:237
const real * plasma_get_species_charge(plasma_data *pls_data)
Get charge of all plasma species.
Definition plasma.c:297
a5err plasma_eval_temp(real *temp, real rho, real r, real phi, real z, real t, int species, plasma_data *pls_data)
Evaluate plasma temperature.
Definition plasma.c:90
a5err plasma_eval_densandtemp(real *dens, real *temp, real rho, real r, real phi, real z, real t, plasma_data *pls_data)
Evaluate plasma density and temperature for all species.
Definition plasma.c:186
void plasma_offload(plasma_data *data)
Offload data to the accelerator.
Definition plasma.c:57
a5err plasma_eval_dens(real *dens, real rho, real r, real phi, real z, real t, int species, plasma_data *pls_data)
Evaluate plasma density.
Definition plasma.c:138
const int * plasma_get_species_anum(plasma_data *pls_data)
Get atomic mass number of ion species.
Definition plasma.c:353
Header file for plasma.c.
@ plasma_type_1D
Definition plasma.h:21
@ plasma_type_1Dt
Definition plasma.h:22
@ plasma_type_1DS
Definition plasma.h:23
a5err plasma_1DS_eval_densandtemp(real *dens, real *temp, real rho, plasma_1DS_data *plasma_data)
Evaluate plasma density and temperature for all species.
Definition plasma_1DS.c:294
a5err plasma_1DS_eval_dens(real *dens, real rho, int species, plasma_1DS_data *plasma_data)
Evaluate plasma density.
Definition plasma_1DS.c:259
void plasma_1DS_free(plasma_1DS_data *data)
Free allocated resources.
Definition plasma_1DS.c:189
a5err plasma_1DS_eval_temp(real *temp, real rho, int species, plasma_1DS_data *plasma_data)
Evaluate plasma temperature.
Definition plasma_1DS.c:228
void plasma_1DS_offload(plasma_1DS_data *data)
Offload data to the accelerator.
Definition plasma_1DS.c:205
Header file for plasma_1DS.c.
a5err plasma_1D_eval_dens(real *dens, real rho, int species, plasma_1D_data *pls_data)
Evaluate plasma density.
Definition plasma_1D.c:179
a5err plasma_1D_eval_densandtemp(real *dens, real *temp, real rho, plasma_1D_data *pls_data)
Evaluate plasma density and temperature for all species.
Definition plasma_1D.c:219
void plasma_1D_free(plasma_1D_data *data)
Free allocated resources.
Definition plasma_1D.c:102
void plasma_1D_offload(plasma_1D_data *data)
Offload data to the accelerator.
Definition plasma_1D.c:117
a5err plasma_1D_eval_temp(real *temp, real rho, int species, plasma_1D_data *pls_data)
Evaluate plasma temperature.
Definition plasma_1D.c:139
Header file for plasma_1D.c.
void plasma_1Dt_offload(plasma_1Dt_data *data)
Offload data to the accelerator.
Definition plasma_1Dt.c:134
void plasma_1Dt_free(plasma_1Dt_data *data)
Free allocated resources.
Definition plasma_1Dt.c:118
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.
Definition plasma_1Dt.c:213
a5err plasma_1Dt_eval_temp(real *temp, real rho, real t, int species, plasma_1Dt_data *pls_data)
Evaluate plasma temperature.
Definition plasma_1Dt.c:158
a5err plasma_1Dt_eval_dens(real *dens, real rho, real t, int species, plasma_1Dt_data *pls_data)
Evaluate plasma density.
Definition plasma_1Dt.c:186
Macros for printing console output.
real * charge
Definition plasma_1D.h:18
Plasma simulation data.
Definition plasma.h:32
plasma_1D_data plasma_1D
Definition plasma.h:34
plasma_1Dt_data plasma_1Dt
Definition plasma.h:35
plasma_1DS_data plasma_1DS
Definition plasma.h:36
plasma_type type
Definition plasma.h:33