56 for(
int i = 0; i < 9; i++) {
61 "\nTrivial cartesian magnetic field (B_TC)\n"
62 "Magnetic axis at (R,z) = (%.1f,%.1f)\n"
63 "psi = %.1f, rho = %.1f\n"
64 "Magnetic field at origo\n"
65 "B_x = %.3f B_y = %.3f B_z = %.3f\n"
66 "Magnetic field gradient\n"
67 "dB_x/dx = %.3f dB_x/dy = %.3f B_x/dz = %.3f\n"
68 "dB_y/dx = %.3f dB_y/dy = %.3f B_y/dz = %.3f\n"
69 "dB_z/dx = %.3f dB_z/dy = %.3f B_z/dz = %.3f\n",
72 data->
B[0], data->
B[1], data->
B[2],
73 data->
dB[0], data->
dB[1], data->
dB[2],
74 data->
dB[3], data->
dB[4], data->
dB[5],
75 data->
dB[6], data->
dB[7], data->
dB[8]);
93 GPU_MAP_TO_DEVICE( data->
B[0:3], data->
dB[0:9] )
109 psi[0] = Bdata->psival;
127 psi_dpsi[0] = Bdata->psival;
148 rho_drho[0] = Bdata->rhoval;
172 real rpz[3] = {r, phi, z};
176 Bxyz[0] = Bdata->B[0] + Bdata->dB[0]*xyz[0] + Bdata->dB[1]*xyz[1]
177 + Bdata->dB[2]*xyz[2];
178 Bxyz[1] = Bdata->B[1] + Bdata->dB[3]*xyz[0] + Bdata->dB[4]*xyz[1]
179 + Bdata->dB[5]*xyz[2];
180 Bxyz[2] = Bdata->B[2] + Bdata->dB[6]*xyz[0] + Bdata->dB[7]*xyz[1]
181 + Bdata->dB[8]*xyz[2];
204 real rpz[3] = {r, phi, z};
208 Bxyz[0] = Bdata->B[0] + Bdata->dB[0]*xyz[0] + Bdata->dB[1]*xyz[1]
209 + Bdata->dB[2]*xyz[2];
210 Bxyz[1] = Bdata->B[1] + Bdata->dB[3]*xyz[0] + Bdata->dB[4]*xyz[1]
211 + Bdata->dB[5]*xyz[2];
212 Bxyz[2] = Bdata->B[2] + Bdata->dB[6]*xyz[0] + Bdata->dB[7]*xyz[1]
213 + Bdata->dB[8]*xyz[2];
223 real B_dBxyz[12] = {Bdata->B[0], Bdata->dB[0], Bdata->dB[1], Bdata->dB[2],
224 Bdata->B[1], Bdata->dB[3], Bdata->dB[4], Bdata->dB[5],
225 Bdata->B[2], Bdata->dB[6], Bdata->dB[7], Bdata->dB[8]};
241 rz[0] = Bdata->axisr;
242 rz[1] = Bdata->axisz;
void B_TC_offload(B_TC_data *data)
Offload data to the accelerator.
a5err B_TC_eval_rho_drho(real rho_drho[4], real r, real phi, real z, B_TC_data *Bdata)
Evaluate normalized poloidal flux rho and its derivatives.
a5err B_TC_eval_psi(real *psi, real r, real phi, real z, B_TC_data *Bdata)
Evaluate poloidal flux psi.
a5err B_TC_eval_psi_dpsi(real psi_dpsi[4], real r, real phi, real z, B_TC_data *Bdata)
Evaluate poloidal flux psi and its derivatives.
a5err B_TC_eval_B_dB(real B_dB[12], real r, real phi, real z, B_TC_data *Bdata)
Evaluate magnetic field and its derivatives.
int B_TC_init(B_TC_data *data, real axisr, real axisz, real psival, real rhoval, real B[3], real dB[9])
Initialize magnetic field data.
void B_TC_free(B_TC_data *data)
Free allocated resources.
a5err B_TC_get_axis_rz(real rz[2], B_TC_data *Bdata)
Return magnetic axis R-coordinate.
a5err B_TC_eval_B(real B[3], real r, real phi, real z, B_TC_data *Bdata)
Evaluate magnetic field.
Main header file for ASCOT5.
unsigned long int a5err
Simulation error flag.
void math_jac_xyz2rpz(real *xyz, real *rpz, real r, real phi)
Convert a Jacobian from cartesian to cylindrical coordinates.
#define math_vec_xyz2rpz(vxyz, vrpz, phi)
Transform vector from cartesian to cylindrical basis: vxyz -> vrpz, phi is the toroidal angle in radi...
#define math_rpz2xyz(rpz, xyz)
Convert cylindrical coordinates rpz to cartesian coordinates xyz.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
TC magnetic field parameters on the target.