ASCOT5
|
Analytic magnetic field. More...
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "../ascot5.h"
#include "../consts.h"
#include "../print.h"
#include "../error.h"
#include "B_GS.h"
Go to the source code of this file.
Functions | |
int | B_GS_init_offload (B_GS_offload_data *offload_data, real **offload_array) |
Initialize magnetic field offload data. | |
void | B_GS_free_offload (B_GS_offload_data *offload_data, real **offload_array) |
Free offload array. | |
void | B_GS_init (B_GS_data *Bdata, B_GS_offload_data *offload_data, real *offload_array) |
Initialize magnetic field data struct on target. | |
a5err | B_GS_eval_psi (real *psi, real r, real phi, real z, B_GS_data *Bdata) |
Evaluate poloidal flux psi. | |
a5err | B_GS_eval_psi_dpsi (real psi_dpsi[4], real r, real phi, real z, B_GS_data *Bdata) |
Evaluate poloidal flux psi and its derivatives. | |
a5err | B_GS_eval_rho_drho (real rho_drho[4], real r, real phi, real z, B_GS_data *Bdata) |
Evaluate normalized poloidal flux rho and its derivatives. | |
a5err | B_GS_eval_B (real B[3], real r, real phi, real z, B_GS_data *Bdata) |
Evaluate magnetic field. | |
a5err | B_GS_eval_B_dB (real B_dB[12], real r, real phi, real z, B_GS_data *Bdata) |
Evaluate magnetic field and its derivatives. | |
a5err | B_GS_get_axis_rz (real rz[2], B_GS_data *Bdata) |
Return magnetic axis R-coordinate. | |
Analytic magnetic field.
This module implements a toroidal magnetic field based on an analytical solution to the Grad-Shafranov equation [1].
In this model, the poloidal flux psi is calculated as
where and are pre-calculated coefficients which can be chosen so that realistic equilibria resembling different machines are produced. The equilibrium can be non-symmetric with respect to magnetic plane, and can have zero, one, or two X-points. is a scaling constant, and . From the poloidal magnetic field components can be evaluated from Grad-Shafranov relations
and toroidal field is evaluated as
This module also includes the possibility to have an analytical model for toroidal field ripple, which is used if ripple period . The rippled toroidal field is
where
and and .
[1] A.J. Cerfon, J.P. Freidberg. "One size fits all" analytic solutions to the Grad-Shafranov equation. Physics of Plasmas 17 (3) (2010) 032502. http://scitation.aip.org/content/aip/journal/pop/17/3/10.1063/1.3328818
Definition in file B_GS.c.
int B_GS_init_offload | ( | B_GS_offload_data * | offload_data, |
real ** | offload_array ) |
Initialize magnetic field offload data.
The offload data struct is very simple and contains only the necessary fields which are all initialized when the data is read (except B_GS.offload_array_length). The offload array is not required at all. Therefore, this function only sets the offload_array_length to zero, assigns a NULL pointer to offload_array, and prints sanity checks so that user may verify that data was initialized succesfully.
offload_data | pointer to offload data struct |
offload_array | pointer to offload array |
void B_GS_free_offload | ( | B_GS_offload_data * | offload_data, |
real ** | offload_array ) |
void B_GS_init | ( | B_GS_data * | Bdata, |
B_GS_offload_data * | offload_data, | ||
real * | offload_array ) |
Evaluate normalized poloidal flux rho and its derivatives.
rho_drho | pointer where rho and its derivatives will be stored |
r | R coordinate [m] |
phi | phi coordinate [rad] |
z | z coordinate [m] |
Bdata | pointer to magnetic field data struct |