34 int n_x,
int n_y,
int bc_x,
int bc_y,
44 x_grid = (x_max - x_min) / ( n_x - 1 * (bc_x ==
NATURALBC) );
51 y_grid = (y_max - y_min) / ( n_y - 1 * (bc_y ==
NATURALBC) );
58 real* f_x = malloc(n_x*
sizeof(
real));
59 real* f_y = malloc(n_y*
sizeof(
real));
60 real* c_x = malloc(n_x*NSIZE_COMP1D*
sizeof(
real));
61 real* c_y = malloc(n_y*NSIZE_COMP1D*
sizeof(
real));
63 if(f_x == NULL || f_y == NULL || c_x == NULL || c_y == NULL) {
72 for(
int i_y=0; i_y<n_y; i_y++) {
74 for(
int i_x=0; i_x<n_x; i_x++) {
75 f_x[i_x] = f[i_y*n_x+i_x];
78 for(
int i_x=0; i_x<n_x; i_x++) {
79 c[i_y*n_x*4 + i_x*4 ] = c_x[i_x*2];
80 c[i_y*n_x*4 + i_x*4 + 1] = c_x[i_x*2+1] / (x_grid*x_grid);
86 for(
int i_x=0; i_x<n_x; i_x++) {
89 for(
int i_y=0; i_y<n_y; i_y++) {
90 f_y[i_y] = f[i_y*n_x + i_x];
93 for(
int i_y=0; i_y<n_y; i_y++) {
94 c[i_y*n_x*4+i_x*4+2] = c_y[i_y*2+1]/(y_grid*y_grid);
98 for(
int i_y=0; i_y<n_y; i_y++) {
99 f_y[i_y] = c[i_y*n_x*4 + i_x*4 + 1];
102 for(
int i_y=0; i_y<n_y; i_y++) {
103 c[i_y*n_x*4 + i_x*4 + 3] = c_y[i_y*2 + 1] / (y_grid*y_grid);
131 int n_x,
int n_y,
int bc_x,
int bc_y,
138 real x_grid = (x_max - x_min) / ( n_x - 1 * (bc_x ==
NATURALBC) );
139 real y_grid = (y_max - y_min) / ( n_y - 1 * (bc_y ==
NATURALBC) );
185 real dx3 = dx * (dx*dx - 1.0);
187 real dxi3 = dxi * (dxi*dxi - 1.0);
195 real dy3 = dy * (dy*dy - 1.0);
197 real dyi3 = dyi * (dyi*dyi - 1.0);
200 int n = i_y*str->
n_x*4+i_x*4;
208 x1 = -(str->
n_x-1)*x1;
214 y1 = -(str->
n_y-1)*y1;
222 dxi*(dyi*str->
c[n]+dy*str->
c[n+y1])
223 +dx*(dyi*str->
c[n+x1]+dy*str->
c[n+y1+x1]))
225 dxi3*(dyi*str->
c[n+1] + dy*str->
c[n+y1+1])
226 +dx3*(dyi*str->
c[n+x1+1] + dy*str->
c[n+y1+x1+1]))
228 dxi*(dyi3*str->
c[n+2]+dy3*str->
c[n+y1+2])
229 +dx*(dyi3*str->
c[n+x1+2]+dy3*str->
c[n+y1+x1+2]))
231 dxi3*(dyi3*str->
c[n+3]+dy3*str->
c[n+y1+3])
232 +dx3*(dyi3*str->
c[n+x1+3]+dy3*str->
c[n+y1+x1+3]));
277 real dx3 = dx * (dx*dx - 1.0);
278 real dx3dx = 3*dx*dx - 1;
280 real dxi3 = dxi * (dxi*dxi - 1.0);
281 real dxi3dx = -3*dxi*dxi + 1;
291 real dy3 = dy * (dy*dy - 1.0);
292 real dy3dy = 3*dy*dy - 1;
294 real dyi3 = dyi * (dyi*dyi - 1.0);
295 real dyi3dy = -3*dyi*dyi + 1;
300 int n = i_y*str->
n_x*4+i_x*4;
308 x1 = -(str->
n_x-1)*x1;
314 y1 = -(str->
n_y-1)*y1;
323 dxi*(dyi*str->
c[n]+dy*str->
c[n+y1])
324 +dx*(dyi*str->
c[n+x1]+dy*str->
c[n+y1+x1]))
326 dxi3*(dyi*str->
c[n+1] + dy*str->
c[n+y1+1])
327 +dx3*(dyi*str->
c[n+x1+1] + dy*str->
c[n+y1+x1+1]))
329 dxi*(dyi3*str->
c[n+2]+dy3*str->
c[n+y1+2])
330 +dx*(dyi3*str->
c[n+x1+2]+dy3*str->
c[n+y1+x1+2]))
332 dxi3*(dyi3*str->
c[n+3]+dy3*str->
c[n+y1+3])
333 +dx3*(dyi3*str->
c[n+x1+3]+dy3*str->
c[n+y1+x1+3]));
337 -(dyi*str->
c[n] +dy*str->
c[n+y1])
338 +(dyi*str->
c[n+x1]+dy*str->
c[n+y1+x1]))
340 dxi3dx*(dyi*str->
c[n+1] +dy*str->
c[n+y1+1])
341 +dx3dx*(dyi*str->
c[n+x1+1]+dy*str->
c[n+y1+x1+1]))
343 -(dyi3*str->
c[n+2] +dy3*str->
c[n+y1+2])
344 +(dyi3*str->
c[n+x1+2]+dy3*str->
c[n+y1+x1+2]))
346 dxi3dx*(dyi3*str->
c[n+3] +dy3*str->
c[n+y1+3])
347 +dx3dx*(dyi3*str->
c[n+x1+3]+dy3*str->
c[n+y1+x1+3]));
351 dxi*(-str->
c[n] +str->
c[n+y1])
352 +dx*(-str->
c[n+x1]+str->
c[n+y1+x1]))
354 dxi3*(-str->
c[n+1] +str->
c[n+y1+1])
355 +dx3*(-str->
c[n+x1+1]+str->
c[n+y1+x1+1]))
357 dxi*(dyi3dy*str->
c[n+2] +dy3dy*str->
c[n+y1+2])
358 +dx*(dyi3dy*str->
c[n+x1+2]+dy3dy*str->
c[n+y1+x1+2]))
360 dxi3*(dyi3dy*str->
c[n+3] +dy3dy*str->
c[n+y1+3])
361 +dx3*(dyi3dy*str->
c[n+x1+3]+dy3dy*str->
c[n+y1+x1+3]));
365 dxi*(dyi*str->
c[n+1] +dy*str->
c[n+y1+1])
366 +dx*(dyi*str->
c[n+x1+1]+dy*str->
c[n+y1+x1+1]))
368 dxi*(dyi3*str->
c[n+3] +dy3*str->
c[n+y1+3])
369 +dx*(dyi3*str->
c[n+x1+3]+dy3*str->
c[n+y1+x1+3]));
373 dxi*(dyi*str->
c[n+2] +dy*str->
c[n+y1+2])
374 +dx*(dyi*str->
c[n+x1+2]+dy*str->
c[n+y1+x1+2]))
376 dxi3*(dyi*str->
c[n+3] +dy*str->
c[n+y1+3])
377 +dx3*(dyi*str->
c[n+x1+3]+dy*str->
c[n+y1+x1+3]));
381 str->
c[n] -str->
c[n+y1]
382 -str->
c[n+x1]+str->
c[n+y1+x1])
384 dxi3dx*(-str->
c[n+1] +str->
c[n+y1+1])
385 +dx3dx*(-str->
c[n+x1+1]+str->
c[n+y1+x1+1]))
387 -(dyi3dy*str->
c[n+2] +dy3dy*str->
c[n+y1+2])
388 +(dyi3dy*str->
c[n+x1+2]+dy3dy*str->
c[n+y1+x1+2]))
390 dxi3dx*(dyi3dy*str->
c[n+3] +dy3dy*str->
c[n+y1+3])
391 +dx3dx*(dyi3dy*str->
c[n+x1+3]+dy3dy*str->
c[n+y1+x1+3]));
Main header file for ASCOT5.
unsigned long int a5err
Simulation error flag.
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.
a5err interp2Dcomp_eval_f(real *f, interp2D_data *str, real x, real y)
Evaluate interpolated value of a 2D field.
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.
Spline interpolation library.
real fmod(real x, real y)
Compute the modulus of two real numbers.
Header file for splineexpl.c and splinecomp.c.
void splinecomp(real *f, int n, int bc, real *c)
Calculate compact cubic spline interpolation coefficients in 1D.
Bicubic interpolation struct.