26 int* anum,
int* znum,
real* mass,
real* charge,
32 data->
anum = (
int*) malloc( nion*
sizeof(
int) );
33 data->
znum = (
int*) malloc( nion*
sizeof(
int) );
36 for(
int i = 0; i < data->
n_species; i++) {
38 data->
znum[i] = znum[i];
39 data->
anum[i] = anum[i];
41 data->
mass[i] = mass[i];
42 data->
charge[i] = charge[i];
46 data->
dens = (
real*) malloc( (nion+1)*nrho*
sizeof(
real) );
47 for(
int i = 0; i < data->
n_rho; i++) {
48 data->
rho[i] = rho[i];
49 data->
temp[i] = Te[i];
50 data->
temp[nrho + i] = Ti[i];
51 data->
dens[i] = ne[i];
52 for(
int j = 0; j < nion; j++) {
53 data->
dens[(j+1) * nrho + i] = ni[j*nrho + i];
59 "Min rho = %1.2le, Max rho = %1.2le,"
60 " Number of rho grid points = %d,"
61 " Number of ion species = %d\n",
64 "Species Z/A charge [e]/mass [amu] Density [m^-3] at Min/Max rho"
65 " Temperature [eV] at Min/Max rho\n");
66 for(
int i=0; i < nion; i++) {
68 " %3d /%3d %3d /%7.3f %1.2le/%1.2le "
73 data->
dens[(i+1)*nrho], data->
dens[(i+1)*nrho - 1],
77 "[electrons] %3d /%7.3f %1.2le/%1.2le "
82 real quasineutrality = 0;
83 for(
int k = 0; k < nrho; k++) {
86 for(
int i = 0; i < nion; i++) {
87 ion_qdens += data->
dens[(i+1)*nrho + k] * data->
charge[i+1];
89 quasineutrality = fmax( quasineutrality,
90 fabs( 1 - ion_qdens / ele_qdens ) );
93 " %.2f\n", 1+quasineutrality);
143 if(rho < pls_data->rho[0]) {
146 else if(rho >= pls_data->
rho[pls_data->
n_rho-1]) {
151 while(i_rho < pls_data->n_rho - 1 && pls_data->
rho[i_rho] <= rho) {
155 real t_rho = (rho - pls_data->
rho[i_rho])
156 / (pls_data->
rho[i_rho+1] - pls_data->
rho[i_rho]);
160 temp[0] = p1 + t_rho * (p2 - p1);
183 if(rho < pls_data->rho[0]) {
186 else if(rho >= pls_data->
rho[pls_data->
n_rho-1]) {
191 while(i_rho < pls_data->n_rho - 1 && pls_data->
rho[i_rho] <= rho) {
195 real t_rho = (rho - pls_data->
rho[i_rho])
196 / (pls_data->
rho[i_rho+1] - pls_data->
rho[i_rho]);
200 dens[0] = p1 + t_rho * (p2 - p1);
222 if(rho < pls_data->rho[0]) {
225 else if(rho >= pls_data->
rho[pls_data->
n_rho-1]) {
230 while(i_rho < pls_data->n_rho-1 && pls_data->
rho[i_rho] <= rho) {
235 real t_rho = (rho - pls_data->
rho[i_rho])
236 / (pls_data->
rho[i_rho+1] - pls_data->
rho[i_rho]);
239 for(
int i = 0; i < pls_data->
n_species; i++) {
240 p1 = pls_data->
dens[i*pls_data->
n_rho + i_rho];
241 p2 = pls_data->
dens[i*pls_data->
n_rho + i_rho+1];
242 dens[i] = p1 + t_rho * (p2 - p1);
246 p1 = pls_data->
temp[i*pls_data->
n_rho + i_rho];
247 p2 = pls_data->
temp[i*pls_data->
n_rho + i_rho+1];
248 temp[i] = p1 + t_rho * (p2 - p1);
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.
a5err plasma_1D_eval_dens(real *dens, real rho, int species, plasma_1D_data *pls_data)
Evaluate plasma density.
a5err plasma_1D_eval_densandtemp(real *dens, real *temp, real rho, plasma_1D_data *pls_data)
Evaluate plasma density and temperature for all species.
void plasma_1D_free(plasma_1D_data *data)
Free allocated resources.
void plasma_1D_offload(plasma_1D_data *data)
Offload data to the accelerator.
a5err plasma_1D_eval_temp(real *temp, real rho, int species, plasma_1D_data *pls_data)
Evaluate plasma temperature.
int plasma_1D_init(plasma_1D_data *data, int nrho, int nion, real *rho, int *anum, int *znum, real *mass, real *charge, real *Te, real *Ti, real *ne, real *ni)
Initialize 1D plasma data and check inputs.
Header file for plasma_1D.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
1D plasma parameters on the target