28#define PLASMA_1DS_NONEG 1 
   31#define PLASMA_1DS_LOG 1 
   34#define PLASMA_1DS_SQRT 2 
   44                    int nion, 
int* anum, 
int* znum, 
real* mass, 
real* charge,
 
   48    data->
anum = (
int*) malloc( nion*
sizeof(
int) );
 
   49    data->
znum = (
int*) malloc( nion*
sizeof(
int) );
 
   52    for(
int i = 0; i < data->
n_species; i++) {
 
   54            data->
znum[i] = znum[i];
 
   55            data->
anum[i] = anum[i];
 
   57        data->
mass[i] = mass[i];
 
   58        data->
charge[i] = charge[i];
 
   64    real* ni_scaled = (
real*) malloc( nion*nrho*
sizeof(
real) );
 
   65    for(
int i=0; i < nrho; i++) {
 
   66#if PLASMA_1DS_NONEG == PLASMA_1DS_LOG 
   67        Te_scaled[i] = log(Te[i]);
 
   68        Ti_scaled[i] = log(Ti[i]);
 
   69        ne_scaled[i] = log(ne[i]);
 
   70        for(
int j = 0; j < nion; j++) {
 
   71            ni_scaled[j*nrho + i] = log(ni[j*nrho + i]);
 
   73#elif PLASMA_1DS_NONEG == PLASMA_1DS_SQRT 
   74        Te_scaled[i] = sqrt(Te[i]);
 
   75        Ti_scaled[i] = sqrt(Ti[i]);
 
   76        ne_scaled[i] = sqrt(ne[i]);
 
   77        for(
int j = 0; j < nion; j++) {
 
   78            ni_scaled[j*nrho + i] = sqrt(ni[j*nrho + i]);
 
   85        print_err(
"Error: Failed to initialize splines.\n");
 
   95        print_err(
"Error: Failed to initialize splines.\n");
 
  107        print_err(
"Error: Failed to initialize splines.\n");
 
  115    for(
int i = 0; i < nion; i++) {
 
  119            print_err(
"Error: Failed to initialize splines.\n");
 
  138              "Min rho = %1.2le, Max rho = %1.2le," 
  139              " Number of rho grid points = %d," 
  140              " Number of ion species = %d\n",
 
  141              rhomin, rhomax, nrho, nion);
 
  143              "Species Z/A  charge [e]/mass [amu] Density [m^-3] at Min/Max rho" 
  144              "    Temperature [eV] at Min/Max rho\n");
 
  145    real T0, T1, n0, n1, vtor0, vtor1;
 
  146    for(
int i=0; i < nion; i++) {
 
  152                  " %3d  /%3d   %3d  /%7.3f             %1.2le/%1.2le     " 
  167              "[electrons]  %3d  /%7.3f             %1.2le/%1.2le          " 
  170    real quasineutrality = 0;
 
  171    for(
int k = 0; k < nrho; k++) {
 
  172        real rho = rhomin + k * (rhomax - rhomin) / (nrho - 1);
 
  176        for(
int i=0; i < nion; i++) {
 
  180        quasineutrality = fmax( quasineutrality,
 
  181                                fabs( 1 - ion_qdens / ele_qdens ) );
 
  184              " %.2f\n", 1+quasineutrality);
 
  186              "%1.2le/%1.2le\n", vtor0, vtor1);
 
 
  201    for(
int i = 0; i < data->
n_species; i++) {
 
  202        free(data->
dens[i].
c);
 
 
  221    for (
int i = 0; i < data->
n_species; i++) {
 
  222        GPU_MAP_TO_DEVICE( data->
dens[i].
c[0:data->
dens[i].
n_x*NSIZE_COMP1D] )
 
 
  246#if PLASMA_1DS_NONEG == PLASMA_1DS_LOG 
  248#elif PLASMA_1DS_NONEG == PLASMA_1DS_SQRT 
  249    *temp = (*temp) * (*temp);
 
  251    if(!err && *temp < 0){
 
 
  278#if PLASMA_1DS_NONEG == PLASMA_1DS_LOG 
  280#elif PLASMA_1DS_NONEG == PLASMA_1DS_SQRT 
  281    *dens = (*dens) * (*dens);
 
  283    if(!err && *dens < 0){
 
 
  322#if PLASMA_1DS_NONEG == PLASMA_1DS_LOG 
  324        dens[i] = exp(dens[i]);
 
  325        temp[i] = exp(temp[i]);
 
  327#elif PLASMA_1DS_NONEG == PLASMA_1DS_SQRT 
  329        dens[i] = dens[i]*dens[i];
 
  330        temp[i] = temp[i]*temp[i];
 
  334        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.
a5err interp1Dcomp_eval_f(real *f, interp1D_data *str, real x)
Evaluate interpolated value of 1D scalar field.
int interp1Dcomp_setup(interp1D_data *str, real *f, int n_x, int bc_x, real x_min, real x_max)
Set up splines to interpolate 1D scalar data.
int plasma_1DS_init(plasma_1DS_data *data, int nrho, real rhomin, real rhomax, int nion, int *anum, int *znum, real *mass, real *charge, real *Te, real *Ti, real *ne, real *ni, real *vtor)
Initialize 1DS plasma data and check inputs.
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.
a5err plasma_1DS_eval_flow(real *vflow, real rho, real r, plasma_1DS_data *pls_data)
Evalate plasma flow along the field lines.
void plasma_1DS_free(plasma_1DS_data *data)
Free allocated resources.
a5err plasma_1DS_eval_temp(real *temp, real rho, int species, plasma_1DS_data *plasma_data)
Evaluate plasma temperature.
void plasma_1DS_offload(plasma_1DS_data *data)
Offload data to the accelerator.
Header file for plasma_1DS.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
#define print_err(...)
Print to standard error.
Cubic interpolation struct.
1D spline plasma parameters on the target