30 data->
anum = (
int*) malloc( nion*
sizeof(
int) );
31 data->
znum = (
int*) malloc( nion*
sizeof(
int) );
34 for(
int i = 0; i < data->
n_species; i++) {
36 data->
znum[i] = znum[i];
37 data->
anum[i] = anum[i];
39 data->
mass[i] = mass[i];
40 data->
charge[i] = charge[i];
43 for(
int i = 0; i < nrho; i++) {
44 data->
rho[i] = rho[i];
47 for(
int i = 0; i < ntime; i++) {
48 data->
time[i] = time[i];
50 data->
temp = (
real*) malloc( 2*nrho*ntime*
sizeof(
real) );
51 data->
dens = (
real*) malloc( (nion+1)*nrho*ntime*
sizeof(
real) );
52 for(
int i = 0; i < nrho; i++) {
53 for(
int j = 0; j < ntime; j++) {
54 data->
temp[j*2*nrho + i] = Te[j*nrho + i];
55 data->
temp[(j*2+1)*nrho + i] = Ti[j*nrho + i];
56 data->
dens[j*nrho + i] = ne[j*nrho + i];
57 for(
int k = 0; k < nion; k++) {
58 data->
dens[(k+1)*nrho*ntime + j*nrho + i] =
59 ni[k*nrho*ntime + j*nrho + i];
66 "Min rho = %1.2le, Max rho = %1.2le,"
67 " Number of rho grid points = %d\n",
70 "Min time = %1.2le, Max time = %1.2le,"
71 " Number of time points = %d\n",
75 "Species Z/A charge [e]/mass [amu] "
76 "Density [m^-3] at Min/Max rho(t=t0)"
77 " Temperature [eV] at Min/Max rho(t=t0)\n");
78 for(
int i=0; i < nion; i++) {
80 " %3d /%3d %3d /%7.3f %1.2le/%1.2le "
85 data->
dens[nrho*ntime + i*nrho],
86 data->
dens[nrho*ntime + (i+1)*nrho - 1],
91 "[electrons] %3d /%7.3f %1.2le/%1.2le "
96 real quasineutrality = 0;
97 for(
int k = 0; k < nrho; k++) {
101 for(
int i=0; i < nion; i++) {
102 int idx = nrho*ntime + ntime + nrho * (2+1) + k;
103 ion_qdens += data->
dens[idx] * data->
charge[i+1];
105 quasineutrality = fmax( quasineutrality,
106 fabs( 1 - ion_qdens / ele_qdens ) );
109 " %.2f\n", 1+quasineutrality);
166 *temp = temp_temp[species];
193 *dens = temp_dens[species];
217 if(rho < pls_data->rho[0]) {
220 else if(rho >= pls_data->
rho[pls_data->
n_rho-1]) {
225 while(i_rho < pls_data->n_rho-1 && pls_data->
rho[i_rho] <= rho) {
230 real t_rho = (rho - pls_data->
rho[i_rho])
231 / (pls_data->
rho[i_rho+1] - pls_data->
rho[i_rho]);
234 while(i_time < pls_data->n_time-1 && pls_data->
time[i_time] <= t) {
239 real t_time = (t - pls_data->
time[i_time])
240 / (pls_data->
time[i_time+1] - pls_data->
time[i_time]);
247 else if(i_time >= pls_data->
n_time-2) {
249 i_time = pls_data->
n_time-2;
253 for(
int i = 0; i < pls_data->
n_species; i++) {
254 real p11, p12, p21, p22, p1, p2;
269 p1 = p11 + t_rho * (p12 - p11);
270 p2 = p21 + t_rho * (p22 - p21);
272 dens[i] = p1 + t_time * (p2 - p1);
276 p11 = pls_data->
temp[i_time*2*pls_data->
n_rho
279 p12 = pls_data->
temp[i_time*2*pls_data->
n_rho
282 p21 = pls_data->
temp[(i_time+1)*2*pls_data->
n_rho
285 p22 = pls_data->
temp[(i_time+1)*2*pls_data->
n_rho
289 p1 = p11 + t_rho * (p12 - p11);
290 p2 = p21 + t_rho * (p22 - p21);
292 temp[i] = p1 + t_time * (p2 - p1);
Main header file for ASCOT5.
#define MAX_SPECIES
Maximum number of plasma species.
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.
void plasma_1Dt_offload(plasma_1Dt_data *data)
Offload data to the accelerator.
void plasma_1Dt_free(plasma_1Dt_data *data)
Free allocated resources.
a5err plasma_1Dt_eval_densandtemp(real *dens, real *temp, real rho, real t, plasma_1Dt_data *pls_data)
Evaluate plasma density and temperature for all species.
int plasma_1Dt_init(plasma_1Dt_data *data, int nrho, int ntime, int nion, real *rho, real *time, int *anum, int *znum, real *mass, real *charge, real *Te, real *Ti, real *ne, real *ni)
Initialize 1Dt plasma data and check inputs.
a5err plasma_1Dt_eval_temp(real *temp, real rho, real t, int species, plasma_1Dt_data *pls_data)
Evaluate plasma temperature.
a5err plasma_1Dt_eval_dens(real *dens, real rho, real t, int species, plasma_1Dt_data *pls_data)
Evaluate plasma density.
Header file for plasma_1Dt.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
1D plasma parameters on the target