ASCOT5
Loading...
Searching...
No Matches
neutral.c
Go to the documentation of this file.
1
16#include <stdio.h>
17#include "ascot5.h"
18#include "error.h"
19#include "print.h"
20#include "neutral.h"
21#include "neutral/N0_1D.h"
22#include "neutral/N0_3D.h"
23
30 switch(data->type) {
31 case neutral_type_1D:
32 N0_1D_free(&data->N01D);
33 break;
34 case neutral_type_3D:
35 N0_3D_free(&data->N03D);
36 break;
37 }
38}
39
46 switch(data->type) {
47 case neutral_type_1D:
48 N0_1D_offload(&data->N01D);
49 break;
50 case neutral_type_3D:
51 N0_3D_offload(&data->N03D);
52 break;
53 }
54}
55
74 neutral_data* ndata) {
75 a5err err = 0;
76
77 switch(ndata->type) {
78 case neutral_type_1D:
79 err = N0_1D_eval_n0(n0, rho, &(ndata->N01D));
80 break;
81 case neutral_type_3D:
82 err = N0_3D_eval_n0(n0, r, phi, z, &(ndata->N03D));
83 break;
84 default:
85 /* Unregonized input. Produce error. */
86 err = error_raise( ERR_UNKNOWN_INPUT, __LINE__, EF_NEUTRAL);
87 break;
88 }
89
90 if(err) {
91 /* Return some reasonable values to avoid further errors */
92 n0[0] = 0;
93 }
94
95 return err;
96}
97
116 neutral_data* ndata) {
117 a5err err = 0;
118
119 switch(ndata->type) {
120 case neutral_type_1D:
121 err = N0_1D_eval_t0(t0, rho, &(ndata->N01D));
122 break;
123 case neutral_type_3D:
124 err = N0_3D_eval_t0(t0, r, phi, z, &(ndata->N03D));
125 break;
126 default:
127 /* Unregonized input. Produce error. */
128 err = error_raise( ERR_UNKNOWN_INPUT, __LINE__, EF_NEUTRAL);
129 break;
130 }
131
132 if(err) {
133 /* Return some reasonable values to avoid further errors */
134 t0[0] = 1;
135 }
136
137 return err;
138}
139
152 int n = 0;
153 switch(ndata->type) {
154 case neutral_type_1D:
155 n = N0_1D_get_n_species(&(ndata->N01D));
156 break;
157 case neutral_type_3D:
158 n = N0_3D_get_n_species(&(ndata->N03D));
159 break;
160 }
161
162 return n;
163}
void N0_1D_offload(N0_1D_data *data)
Offload data to the accelerator.
Definition N0_1D.c:94
void N0_1D_free(N0_1D_data *data)
Free allocated resources.
Definition N0_1D.c:79
a5err N0_1D_eval_n0(real *n0, real rho, N0_1D_data *ndata)
Evaluate neutral density.
Definition N0_1D.c:110
a5err N0_1D_eval_t0(real *t0, real rho, N0_1D_data *ndata)
Evaluate neutral temperature.
Definition N0_1D.c:136
int N0_1D_get_n_species(N0_1D_data *ndata)
Return number of neutral species.
Definition N0_1D.c:157
Header file for N0_1D.c.
a5err N0_3D_eval_n0(real *n0, real r, real phi, real z, N0_3D_data *ndata)
Evaluate neutral density.
Definition N0_3D.c:114
int N0_3D_get_n_species(N0_3D_data *ndata)
Return number of neutral species.
Definition N0_3D.c:163
a5err N0_3D_eval_t0(real *t0, real r, real phi, real z, N0_3D_data *ndata)
Evaluate neutral temperature.
Definition N0_3D.c:142
void N0_3D_offload(N0_3D_data *data)
Offload data to the accelerator.
Definition N0_3D.c:96
void N0_3D_free(N0_3D_data *data)
Free allocated resources.
Definition N0_3D.c:81
Header file for N0_3D.c.
Main header file for ASCOT5.
double real
Definition ascot5.h:85
Error module for ASCOT5.
unsigned long int a5err
Simulation error flag.
Definition error.h:17
@ EF_NEUTRAL
Definition error.h:44
@ 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
int neutral_get_n_species(neutral_data *ndata)
Get the number of neutral species.
Definition neutral.c:151
void neutral_offload(neutral_data *data)
Offload data to the accelerator.
Definition neutral.c:45
a5err neutral_eval_n0(real *n0, real rho, real r, real phi, real z, real t, neutral_data *ndata)
Evaluate neutral density.
Definition neutral.c:73
void neutral_free(neutral_data *data)
Free allocated resources.
Definition neutral.c:29
a5err neutral_eval_t0(real *t0, real rho, real r, real phi, real z, real t, neutral_data *ndata)
Evaluate neutral temperature.
Definition neutral.c:115
Header file for neutral.c.
@ neutral_type_1D
Definition neutral.h:20
@ neutral_type_3D
Definition neutral.h:21
Macros for printing console output.
Neutral simulation data.
Definition neutral.h:30
N0_1D_data N01D
Definition neutral.h:32
N0_3D_data N03D
Definition neutral.h:33
neutral_type type
Definition neutral.h:31