28#define PLASMA_1DS_NONEG 1
31#define PLASMA_1DS_LOG 1
34#define PLASMA_1DS_SQRT 2
57 real** offload_array) {
61 int n_rho = offload_data->
n_rho;
65 real* coeff_array = (
real*) malloc((2 + n_species) * NSIZE_COMP1D
66 * n_rho *
sizeof(
real));
68 for(
int i=0; i< ((2 + n_species)*n_rho); i++) {
69#if PLASMA_1DS_NONEG == PLASMA_1DS_LOG
70 (*offload_array)[i] = log( (*offload_array)[i]);
71#elif PLASMA_1DS_NONEG == PLASMA_1DS_SQRT
72 (*offload_array)[i] = sqrt( (*offload_array)[i] );
80 coeff_array + 0*n_rho*NSIZE_COMP1D,
81 *offload_array + 0*n_rho,
87 coeff_array + 1*n_rho*NSIZE_COMP1D,
88 *offload_array + 1*n_rho,
93 for(
int i=0; i < n_species; i++) {
95 coeff_array + (2 +i)*n_rho*NSIZE_COMP1D,
96 *offload_array + (2 + i)*n_rho,
106 free(*offload_array);
107 *offload_array = coeff_array;
111 real temp0, temp1, dens0, dens1;
115 int n_ions = n_species - 1;
118 "Min rho = %1.2le, Max rho = %1.2le,"
119 " Number of rho grid points = %d,"
120 " Number of ion species = %d\n",
123 "Species Z/A charge [e]/mass [amu] Density [m^-3] at Min/Max rho"
124 " Temperature [eV] at Min/Max rho\n");
125 for(
int i=0; i < n_ions; i++) {
131 " %3d /%3d %3d /%7.3f %1.2le/%1.2le "
133 offload_data->
znum[i], offload_data->
anum[i],
144 "[electrons] %3d /%7.3f %1.2le/%1.2le "
147 real quasineutrality = 0;
148 for(
int k = 0; k <n_rho; k++) {
150 + k * (offload_data->
rho_max - offload_data->
rho_min) / (n_rho - 1);
155 for(
int i=0; i < n_ions; i++) {
159 quasineutrality = fmax( quasineutrality,
160 fabs( 1 - ion_qdens / ele_qdens ) );
163 " %.2f\n", 1+quasineutrality);
175 real** offload_array) {
176 free(*offload_array);
177 *offload_array = NULL;
193 real* offload_array) {
203 int n_rho = offload_data->
n_rho;
205 &(offload_array[0*n_rho]),
210 &(offload_array[1*n_rho*NSIZE_COMP1D]),
215 for(
int i=0; i<offload_data->
n_species; i++) {
217 &(offload_array[(2+i)*n_rho*NSIZE_COMP1D]),
244#if PLASMA_1DS_NONEG == PLASMA_1DS_LOG
246#elif PLASMA_1DS_NONEG == PLASMA_1DS_SQRT
247 *temp = (*temp) * (*temp);
249 if(!err && *temp < 0){
276#if PLASMA_1DS_NONEG == PLASMA_1DS_LOG
278#elif PLASMA_1DS_NONEG == PLASMA_1DS_SQRT
279 *dens = (*dens) * (*dens);
281 if(!err && *dens < 0){
320#if PLASMA_1DS_NONEG == PLASMA_1DS_LOG
322 dens[i] = exp(dens[i]);
323 temp[i] = exp(temp[i]);
325#elif PLASMA_1DS_NONEG == PLASMA_1DS_SQRT
327 dens[i] = dens[i]*dens[i];
328 temp[i] = temp[i]*temp[i];
332 if(!err && (dens[i] < 0 || temp[i] < 0) ) {
Main header file for ASCOT5.
Header file containing physical and mathematical constants.
#define CONST_U
Atomic mass unit in kilograms [kg]
#define CONST_M_E
Electron mass [kg]
#define CONST_E
Elementary charge [C]
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.
int interp1Dcomp_init_coeff(real *c, real *f, int n_x, int bc_x, real x_min, real x_max)
Calculate cubic spline interpolation coefficients for scalar 1D data.
a5err interp1Dcomp_eval_f(real *f, interp1D_data *str, real x)
Evaluate interpolated value of 1D scalar field.
void interp1Dcomp_init_spline(interp1D_data *str, real *c, int n_x, int bc_x, real x_min, real x_max)
Initialize a cubic spline.
void plasma_1DS_free_offload(plasma_1DS_offload_data *offload_data, real **offload_array)
Free offload array and reset parameters.
a5err plasma_1DS_eval_densandtemp(real *dens, real *temp, real rho, plasma_1DS_data *plasma_data)
Evaluate plasma density and temperature for all species.
a5err plasma_1DS_eval_dens(real *dens, real rho, int species, plasma_1DS_data *plasma_data)
Evaluate plasma density.
int plasma_1DS_init_offload(plasma_1DS_offload_data *offload_data, real **offload_array)
Initialize 1DS plasma data and check inputs.
a5err plasma_1DS_eval_temp(real *temp, real rho, int species, plasma_1DS_data *plasma_data)
Evaluate plasma temperature.
void plasma_1DS_init(plasma_1DS_data *plasma_data, plasma_1DS_offload_data *offload_data, real *offload_array)
Initialize magnetic field data struct on target.
Header file for plasma_1DS.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
1D spline plasma parameters on the target
1D spline plasma parameters that will be offloaded to target