38 real** offload_array) {
43 int nusize = offload_data->
npsi * offload_data->
ntheta;
44 int thetasize = offload_data->
npsi * offload_data->
nthetag;
45 int contoursize = offload_data->
nrzs;
54 real* coeff_array = (
real*)malloc( ( ( nusize + thetasize)
55 * NSIZE_COMP2D + 2*contoursize )
71 &coeff_array[nusize * NSIZE_COMP2D],
72 &(*offload_array)[nusize],
76 THETAMIN-padding, THETAMAX+padding);
78 for(
int i = 0; i < contoursize; i++) {
79 coeff_array[(nusize + thetasize)*NSIZE_COMP2D + i] =
80 (*offload_array)[nusize + thetasize + i];
81 coeff_array[(nusize + thetasize)*NSIZE_COMP2D + contoursize + i] =
82 (*offload_array)[nusize + thetasize + contoursize + i];
86 *offload_array = coeff_array;
88 * NSIZE_COMP2D + 2 * contoursize;
109 real* offload_array) {
120 int nusize = offload_data->
npsi * offload_data->
ntheta * NSIZE_COMP2D;
121 int thetasize = offload_data->
npsi * offload_data->
nthetag * NSIZE_COMP2D;
122 int contoursize = offload_data->
nrzs;
135 &(offload_array[nusize]),
141 THETAMIN-padding, THETAMAX+padding);
143 boozerdata->
rs = &(offload_array[nusize + thetasize]);
144 boozerdata->
zs = &(offload_array[nusize + thetasize + contoursize]);
145 boozerdata->
nrzs = offload_data->
nrzs;
155 real** offload_array) {
156 free(*offload_array);
201 real psi[4], rho[2], r0, z0;
213 if(!err && psi[0] < boozerdata->
psi_max &&
214 psi[0] > boozerdata->
psi_min) {
237 psithetazeta[0]=psi[0];
238 psithetazeta[1]=psi[1];
240 psithetazeta[3]=psi[3];
244 asq = (r - r0) * (r - r0)
245 + (z - z0) * (z - z0);
247 dthgeo_dr=-(z-z0)/asq;
249 dthgeo_dz=(r-r0)/asq;
252 psithetazeta[4]=theta[0];
253 psithetazeta[5]=theta[1]*psi[1]+theta[2]*dthgeo_dr;
255 psithetazeta[7]=theta[1]*psi[3]+theta[2]*dthgeo_dz;
259 psithetazeta[9]=nu[1]*psi[1]+nu[2]*psithetazeta[5];
260 psithetazeta[10]=1.0;
261 psithetazeta[11]=nu[1]*psi[3]+nu[2]*psithetazeta[7];
268 if(!err && interperr) {
a5err B_field_eval_psi_dpsi(real psi_dpsi[4], real r, real phi, real z, real t, B_field_data *Bdata)
Evaluate poloidal flux psi and its derivatives.
a5err B_field_eval_rho(real rho[2], real psi, B_field_data *Bdata)
Evaluate normalized poloidal flux rho and its psi derivative.
a5err B_field_get_axis_rz(real rz[2], B_field_data *Bdata, real phi)
Return magnetic axis Rz-coordinates.
Header file for B_field.c.
Main header file for ASCOT5.
void boozer_free_offload(boozer_offload_data *offload_data, real **offload_array)
Free offload array.
int boozer_init_offload(boozer_offload_data *offload_data, real **offload_array)
Load Boozer data and prepare parameters for offload.
void boozer_init(boozer_data *boozerdata, boozer_offload_data *offload_data, real *offload_array)
Initialize boozer data struct on target.
a5err boozer_eval_psithetazeta(real psithetazeta[12], int *isinside, real r, real phi, real z, B_field_data *Bdata, boozer_data *boozerdata)
Evaluate Boozer coordinates and partial derivatives.
Header file for boozer.c.
Header file containing physical and mathematical constants.
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.
Spline interpolation library.
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.
int interp2Dcomp_init_coeff(real *c, 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)
Calculate bicubic spline interpolation coefficients for scalar 2D data.
void interp2Dcomp_init_spline(interp2D_data *str, real *c, int n_x, int n_y, int bc_x, int bc_y, real x_min, real x_max, real y_min, real y_max)
Initialize a bicubic spline.
int math_point_in_polygon(real r, real z, real *rv, real *zv, int n)
Check if coordinates are within polygon.
real fmod(real x, real y)
Compute the modulus of two real numbers.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
Magnetic field simulation data.
Boozer parameters on the target.
interp2D_data theta_psithetageom
interp2D_data nu_psitheta
offload data for maps between boozer and cylindrical coordinates