18DECLARE_TARGET_SIMD_UNIFORM(data)
31 data->
id = (
int*) malloc( data->
Nmrk *
sizeof(
int) );
36 for(
int i = 0; i < data->
Nmrk; i++) {
66 GPU_PARALLEL_LOOP_ALL_LEVELS
67 for(
int i=0; i < p_f->
n_mrk; i++) {
72 data, p_f->
index[i], p_f->
id[i], p_f->
rho[i], p_f->
r[i], pitchsign,
77 GPU_PARALLEL_LOOP_ALL_LEVELS
78 for(
int i=0; i < p_f->
n_mrk; i++) {
80 if( p_f->
id[i] < 1 || p_f->
running[i] > 0 ) {
99 for(
int i=0; i <
NSIMD; i++) {
100 real pitchsign = 1 - 2*(p_f->ppar[i] < 0);
102 data, p_f->index[i], p_f->id[i], p_f->rho[i], p_f->r[i], pitchsign,
103 p_f->mileage[i], p_i->mileage[i], p_f->theta[i], p_i->theta[i]);
108 for(
int i=0; i <
NSIMD; i++) {
111 if( p_f->id[i] < 1 || p_f->running[i] > 0 ) {
131 for(
int i=0; i <
NSIMD; i++) {
132 real pitchsign = 1 - 2*(p_f->pitch[i] < 0);
134 data, p_f->index[i], p_f->id[i], p_f->rho[i], p_f->r[i], pitchsign,
135 p_f->mileage[i], p_i->mileage[i], p_f->theta[i], p_i->theta[i]);
140 for(
int i=0; i <
NSIMD; i++) {
142 if( p_f->id[i] < 1 || p_f->running[i] > 0 ) {
229 int positive = 0, negative = 0;
231 while(link != NULL) {
243 if(positive >= negative) {
253 if(datasize > data->
Navg) {
255 int navgpnt = ceil(datasize/data->
Navg);
256 real* rho = malloc(navgpnt*
sizeof(
real));
257 real* time = malloc(navgpnt*
sizeof(
real));
265 rho[navgpnt-1] = link->
rho;
266 time[navgpnt-1] = link->
time;
268 int nextrapnts = datasize - navgpnt*data->
Navg;
269 if(nextrapnts == 0) {
270 nextrapnts = data->
Navg;
272 for(
int k = 1; k < nextrapnts; k++) {
277 rho[navgpnt-1] += link->
rho;
278 time[navgpnt-1] += link->
time;
280 rho[navgpnt-1] /= nextrapnts;
281 time[navgpnt-1] /= nextrapnts;
284 for(
int j = navgpnt-2; j > -1; j--) {
287 for(
int k = 0; k < data->
Navg; k++) {
293 time[j] += link->
time;
295 rho[j] /= data->
Navg;
296 time[j] /= data->
Navg;
301 for(
int j = 0; j < navgpnt-1; j++) {
302 K += ( rho[j+1] - rho[j] ) / ( time[j+1] - time[j] );
307 for(
int j = 0; j < navgpnt-1; j++) {
308 real a = rho[j+1] - rho[j] - K * ( time[j+1] - time[j] );
309 D += 0.5*a*a / ( time[j+1] - time[j] );
316 data->
id[index] = (
real)
id;
317 data->
Kcoef[index] = K;
318 data->
Dcoef[index] = D;
324 while(link != NULL) {
356 k = fabs(a / (fang - iang));
Main header file for ASCOT5.
#define NSIMD
Number of particles simulated simultaneously in a particle group operations.
Header file containing physical and mathematical constants.
void diag_transcoef_update_ml(diag_transcoef_data *data, particle_simd_ml *p_f, particle_simd_ml *p_i)
Collect transport diagnostics for ml simulation.
void diag_transcoef_init(diag_transcoef_data *data)
Initializes transport coefficient diagnostics data.
DECLARE_TARGET_SIMD real diag_transcoef_check_omp_crossing(real fang, real iang)
Check if marker has crossed omp.
void diag_transcoef_process_and_clean(diag_transcoef_data *data, integer index, integer id)
Process recorded data to transport coefficients and clean.
void diag_transcoef_update_gc(diag_transcoef_data *data, particle_simd_gc *p_f, particle_simd_gc *p_i)
Collect transport diagnostics for gc simulation.
void diag_transcoef_update_fo(diag_transcoef_data *data, particle_simd_fo *p_f, particle_simd_fo *p_i)
Collect transport diagnostics for fo simulation.
void diag_transcoef_free(diag_transcoef_data *data)
Free allocated resources.
void diag_transcoef_record(diag_transcoef_data *data, integer index, integer id, real rho, real r, real pitchsign, real t_f, real t_i, real theta_f, real theta_i)
Check if criteria for recording is met for a single marker and make the record.
Header file for diag_transcoef.c.
real fmod(real x, real y)
Compute the modulus of two real numbers.
#define math_dot(a, b)
Calculate dot product a[3] dot b[3].
Header file for particle.c.
Header file for simulate.c.
Transport coefficient diagnostics offload data struct.
diag_transcoef_link ** datapoints
Simple linked list link for storing data points.
struct diag_transcoef_link * prevlink
Struct representing NSIMD particle markers.
Struct representing NSIMD guiding center markers.
Struct representing NSIMD field line markers.