ASCOT5
Toggle main menu visibility
Loading...
Searching...
No Matches
Efield
E_2DS.c
Go to the documentation of this file.
1
5
#include <stdlib.h>
6
#include "
../ascot5.h
"
7
#include "../offload.h"
8
#include "
../print.h
"
9
#include "
../error.h
"
10
#include "
../spline/interp.h
"
11
#include "
E_2DS.h
"
12
13
int
E_2DS_init(
E_2DS_data
* data,
int
nr,
real
rmin,
real
rmax,
int
nz,
14
real
zmin,
real
zmax,
real
* vpot) {
15
16
int
err = 0;
17
18
/* Set up the splines */
19
err =
interp2Dcomp_setup
(&data->
vpot
, vpot, nr, nz,
NATURALBC
,
NATURALBC
,
20
rmin, rmax, zmin, zmax);
21
22
if
(err) {
23
print_err
(
"Error: Failed to initialize splines.\n"
);
24
return
1;
25
}
26
27
return
0;
28
}
29
30
31
void
E_2DS_free(
E_2DS_data
* data) {
32
free(data->
vpot
.
c
);
33
}
34
35
36
void
E_2DS_offload(
E_2DS_data
* data) {
37
GPU_MAP_TO_DEVICE(
38
data->
vpot
, data->
vpot
.
c
[0:data->
vpot
.
n_x
*data->
vpot
.
n_y
*NSIZE_COMP2D]
39
)
40
}
41
42
43
a5err
E_2DS_eval_E(
real
E[3],
real
r,
real
z,
E_2DS_data
* Edata) {
44
real
vdv[6];
45
int
interperr = 0;
46
interperr +=
interp2Dcomp_eval_df
(vdv, &Edata->
vpot
, r, z);
47
48
a5err
err = 0;
49
if
(interperr) {
50
err = error_raise(
ERR_INPUT_EVALUATION
, __LINE__,
EF_E_2DS
);
51
}
52
53
E[0] = -vdv[1];
54
E[1] = 0;
55
E[2] = -vdv[2];
56
57
return
err;
58
}
E_2DS.h
Header file for E_2DS.c.
ascot5.h
Main header file for ASCOT5.
real
double real
Definition
ascot5.h:85
error.h
Error module for ASCOT5.
a5err
unsigned long int a5err
Simulation error flag.
Definition
error.h:17
EF_E_2DS
@ EF_E_2DS
Definition
error.h:55
ERR_INPUT_EVALUATION
@ ERR_INPUT_EVALUATION
Definition
error.h:65
interp.h
Spline interpolation library.
interp2Dcomp_setup
int interp2Dcomp_setup(interp2D_data *str, real *f, int n_x, int n_y, int bc_x, int bc_y, real x_min, real x_max, real y_min, real y_max)
Set up splines to interpolate 2D scalar data.
Definition
interp2Dcomp.c:174
NATURALBC
@ NATURALBC
Definition
interp.h:37
interp2Dcomp_eval_df
DECLARE_TARGET_END a5err interp2Dcomp_eval_df(real *f_df, interp2D_data *str, real x, real y)
Evaluate interpolated value and 1st and 2nd derivatives of 2D field.
Definition
interp2Dcomp.c:293
print.h
Macros for printing console output.
print_err
#define print_err(...)
Print to standard error.
Definition
print.h:42
E_2DS_data
2D spline electric field parameters
Definition
E_2DS.h:17
E_2DS_data::vpot
interp2D_data vpot
Definition
E_2DS.h:18
interp2D_data::n_y
int n_y
Definition
interp.h:70
interp2D_data::n_x
int n_x
Definition
interp.h:69
interp2D_data::c
real * c
Definition
interp.h:79
Generated on
for ASCOT5 by
1.18.0