18DECLARE_TARGET_SIMD_UNIFORM(data)
34 real* offload_array) {
35 data->
id = &(offload_array[0*offload_data->
Nmrk]);
36 data->
Kcoef = &(offload_array[1*offload_data->
Nmrk]);
37 data->
Dcoef = &(offload_array[2*offload_data->
Nmrk]);
45 for(
int i = 0; i < offload_data->
Nmrk; i++) {
72 GPU_PARALLEL_LOOP_ALL_LEVELS
73 for(
int i=0; i < p_f->
n_mrk; i++) {
78 data, p_f->
index[i], p_f->
id[i], p_f->
rho[i], p_f->
r[i], pitchsign,
83 GPU_PARALLEL_LOOP_ALL_LEVELS
84 for(
int i=0; i < p_f->
n_mrk; i++) {
86 if( p_f->
id[i] < 1 || p_f->
running[i] > 0 ) {
105 for(
int i=0; i <
NSIMD; i++) {
106 real pitchsign = 1 - 2*(p_f->ppar[i] < 0);
108 data, p_f->index[i], p_f->id[i], p_f->rho[i], p_f->r[i], pitchsign,
109 p_f->mileage[i], p_i->mileage[i], p_f->theta[i], p_i->theta[i]);
114 for(
int i=0; i <
NSIMD; i++) {
117 if( p_f->id[i] < 1 || p_f->running[i] > 0 ) {
137 for(
int i=0; i <
NSIMD; i++) {
138 real pitchsign = 1 - 2*(p_f->pitch[i] < 0);
140 data, p_f->index[i], p_f->id[i], p_f->rho[i], p_f->r[i], pitchsign,
141 p_f->mileage[i], p_i->mileage[i], p_f->theta[i], p_i->theta[i]);
146 for(
int i=0; i <
NSIMD; i++) {
148 if( p_f->id[i] < 1 || p_f->running[i] > 0 ) {
235 int positive = 0, negative = 0;
237 while(link != NULL) {
249 if(positive >= negative) {
259 if(datasize > data->
Navg) {
261 int navgpnt = ceil(datasize/data->
Navg);
262 real* rho = malloc(navgpnt*
sizeof(
real));
263 real* time = malloc(navgpnt*
sizeof(
real));
271 rho[navgpnt-1] = link->
rho;
272 time[navgpnt-1] = link->
time;
274 int nextrapnts = datasize - navgpnt*data->
Navg;
275 if(nextrapnts == 0) {
276 nextrapnts = data->
Navg;
278 for(
int k = 1; k < nextrapnts; k++) {
283 rho[navgpnt-1] += link->
rho;
284 time[navgpnt-1] += link->
time;
286 rho[navgpnt-1] /= nextrapnts;
287 time[navgpnt-1] /= nextrapnts;
290 for(
int j = navgpnt-2; j > -1; j--) {
293 for(
int k = 0; k < data->
Navg; k++) {
299 time[j] += link->
time;
301 rho[j] /= data->
Navg;
302 time[j] /= data->
Navg;
307 for(
int j = 0; j < navgpnt-1; j++) {
308 K += ( rho[j+1] - rho[j] ) / ( time[j+1] - time[j] );
313 for(
int j = 0; j < navgpnt-1; j++) {
314 real a = rho[j+1] - rho[j] - K * ( time[j+1] - time[j] );
315 D += 0.5*a*a / ( time[j+1] - time[j] );
322 data->
id[index] = (
real)
id;
323 data->
Kcoef[index] = K;
324 data->
Dcoef[index] = D;
330 while(link != NULL) {
362 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.
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 transport coefficient data on target.
void diag_transcoef_init(diag_transcoef_data *data, diag_transcoef_offload_data *offload_data, real *offload_array)
Initializes orbit diagnostics offload data.
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
Transport coefficient diagnostics offload data struct.
Struct representing NSIMD particle markers.
Struct representing NSIMD guiding center markers.
Struct representing NSIMD field line markers.