ASCOT5
Loading...
Searching...
No Matches
hdf5_options.c
Go to the documentation of this file.
1
5#include <stdlib.h>
6#include <hdf5.h>
7#include <hdf5_hl.h>
8#include "../ascot5.h"
9#include "../consts.h"
10#include "../diag.h"
11#include "../diag/diag_orb.h"
12#include "../diag/dist_5D.h"
13#include "../diag/dist_6D.h"
14#include "../diag/dist_rho5D.h"
15#include "../diag/dist_rho6D.h"
16#include "../diag/dist_com.h"
17#include "../endcond.h"
18#include "../math.h"
19#include "../simulate.h"
20#include "hdf5_helpers.h"
21#include "hdf5_options.h"
22#define OPTPATH
24int hdf5_options_read_dist5D(hid_t file, dist_5D_data* dist, char* qid);
25int hdf5_options_read_dist6D(hid_t file, dist_6D_data* dist, char* qid);
26int hdf5_options_read_distrho5D(hid_t file, dist_rho5D_data* dist, char* qid);
27int hdf5_options_read_distrho6D(hid_t file, dist_rho6D_data* dist, char* qid);
28int hdf5_options_read_distCOM(hid_t file, dist_COM_data* dist, char* qid);
29int hdf5_options_read_diagorb(hid_t file, diag_orb_data* diagorb, char* qid);
30int hdf5_options_read_diagtrcof(hid_t file, diag_transcoef_data* diagtrcof,
31 char* qid);
32
47int hdf5_options_read(hid_t file, sim_data* sim, char* qid){
48
49 #undef OPTPATH
50 #define OPTPATH "/options/opt_XXXXXXXXXX/"
51
52 real tempfloat; // For reading float data that is converted to int.
53
54 if( hdf5_read_double(OPTPATH "SIM_MODE", &tempfloat,
55 file, qid, __FILE__, __LINE__) ) {return 1;}
56 sim->sim_mode = (int)tempfloat;
57 if( hdf5_read_double(OPTPATH "ENABLE_ADAPTIVE", &tempfloat,
58 file, qid, __FILE__, __LINE__) ) {return 1;}
59 sim->enable_ada = (int)tempfloat;
60 if( hdf5_read_double(OPTPATH "RECORD_MODE", &tempfloat,
61 file, qid, __FILE__, __LINE__) ) {return 1;}
62 sim->record_mode = (int)tempfloat;
63
64
65 if( hdf5_read_double(OPTPATH "FIXEDSTEP_USE_USERDEFINED", &tempfloat,
66 file, qid, __FILE__, __LINE__) ) {return 1;}
67 sim->fix_usrdef_use = (int)tempfloat;
68 if( hdf5_read_double(OPTPATH "FIXEDSTEP_USERDEFINED", &sim->fix_usrdef_val,
69 file, qid, __FILE__, __LINE__) ) {return 1;}
70 if( hdf5_read_double(OPTPATH "FIXEDSTEP_GYRODEFINED", &tempfloat,
71 file, qid, __FILE__, __LINE__) ) {return 1;}
72 sim->fix_gyrodef_nstep = (int)tempfloat;
73
74
75 if( hdf5_read_double(OPTPATH "ADAPTIVE_TOL_ORBIT", &sim->ada_tol_orbfol,
76 file, qid, __FILE__, __LINE__) ) {return 1;}
77 if( hdf5_read_double(OPTPATH "ADAPTIVE_TOL_CCOL", &sim->ada_tol_clmbcol,
78 file, qid, __FILE__, __LINE__) ) {return 1;}
79 if( hdf5_read_double(OPTPATH "ADAPTIVE_MAX_DRHO", &sim->ada_max_drho,
80 file, qid, __FILE__, __LINE__) ) {return 1;}
81 if( hdf5_read_double(OPTPATH "ADAPTIVE_MAX_DPHI", &sim->ada_max_dphi,
82 file, qid, __FILE__, __LINE__) ) {return 1;}
83
84
85 if( hdf5_read_double(OPTPATH "ENABLE_ORBIT_FOLLOWING", &tempfloat,
86 file, qid, __FILE__, __LINE__) ) {return 1;}
87 sim->enable_orbfol = (int)tempfloat;
88 if( hdf5_read_double(OPTPATH "ENABLE_COULOMB_COLLISIONS", &tempfloat,
89 file, qid, __FILE__, __LINE__) ) {return 1;}
90 sim->enable_clmbcol = (int)tempfloat;
91 if( hdf5_read_double(OPTPATH "ENABLE_MHD", &tempfloat,
92 file, qid, __FILE__, __LINE__) ) {return 1;}
93 sim->enable_mhd = (int)tempfloat;
94 if( hdf5_read_double(OPTPATH "ENABLE_ATOMIC", &tempfloat,
95 file, qid, __FILE__, __LINE__) ) {return 1;}
96 sim->enable_atomic = (int)tempfloat;
97 if( hdf5_read_double(OPTPATH "DISABLE_FIRSTORDER_GCTRANS", &tempfloat,
98 file, qid, __FILE__, __LINE__) ) {return 1;}
99 sim->disable_gctransform = (int)tempfloat;
100 if( hdf5_read_double(OPTPATH "DISABLE_ENERGY_CCOLL", &tempfloat,
101 file, qid, __FILE__, __LINE__) ) {return 1;}
102 sim->disable_energyccoll = (int)tempfloat;
103 if( hdf5_read_double(OPTPATH "DISABLE_PITCH_CCOLL", &tempfloat,
104 file, qid, __FILE__, __LINE__) ) {return 1;}
105 sim->disable_pitchccoll = (int)tempfloat;
106 if( hdf5_read_double(OPTPATH "DISABLE_GCDIFF_CCOLL", &tempfloat,
107 file, qid, __FILE__, __LINE__) ) {return 1;}
108 sim->disable_gcdiffccoll = (int)tempfloat;
109 if( hdf5_read_double(OPTPATH "REVERSE_TIME", &tempfloat,
110 file, qid, __FILE__, __LINE__) ) {return 1;}
111 sim->reverse_time = (int)tempfloat;
112
113 int ec;
114 sim->endcond_active = 0;
115
116 if( hdf5_read_double(OPTPATH "ENDCOND_SIMTIMELIM", &tempfloat,
117 file, qid, __FILE__, __LINE__) ) {return 1;}
118 ec = (int)tempfloat;
119 sim->endcond_active = sim->endcond_active | endcond_tlim * (ec > 0);
120 if( hdf5_read_double(OPTPATH "ENDCOND_CPUTIMELIM", &tempfloat,
121 file, qid, __FILE__, __LINE__) ) {return 1;}
122 ec = (int)tempfloat;
123 sim->endcond_active = sim->endcond_active | endcond_cpumax * (ec > 0);
124 if( hdf5_read_double(OPTPATH "ENDCOND_RHOLIM", &tempfloat,
125 file, qid, __FILE__, __LINE__) ) {return 1;}
126 ec = (int)tempfloat;
127 sim->endcond_active = sim->endcond_active | endcond_rhomin * (ec > 0);
128 sim->endcond_active = sim->endcond_active | endcond_rhomax * (ec > 0);
129 if( hdf5_read_double(OPTPATH "ENDCOND_ENERGYLIM", &tempfloat,
130 file, qid, __FILE__, __LINE__) ) {return 1;}
131 ec = (int)tempfloat;
132 sim->endcond_active = sim->endcond_active | endcond_emin * (ec > 0);
133 sim->endcond_active = sim->endcond_active | endcond_therm * (ec > 0);
134 if( hdf5_read_double(OPTPATH "ENDCOND_WALLHIT", &tempfloat,
135 file, qid, __FILE__, __LINE__) ) {return 1;}
136 ec = (int)tempfloat;
137 sim->endcond_active = sim->endcond_active | endcond_wall * (ec > 0);
138 if( hdf5_read_double(OPTPATH "ENDCOND_MAXORBS", &tempfloat,
139 file, qid, __FILE__, __LINE__) ) {return 1;}
140 ec = (int)tempfloat;
141 sim->endcond_active = sim->endcond_active | endcond_polmax * (ec > 0);
142 sim->endcond_active = sim->endcond_active | endcond_tormax * (ec > 0);
143 if( hdf5_read_double(OPTPATH "ENDCOND_NEUTRALIZED", &tempfloat,
144 file, qid, __FILE__, __LINE__) ) {return 1;}
145 ec = (int)tempfloat;
146 sim->endcond_active = sim->endcond_active | endcond_neutr * (ec > 0);
147 if( hdf5_read_double(OPTPATH "ENDCOND_IONIZED", &tempfloat,
148 file, qid, __FILE__, __LINE__) ) {return 1;}
149 ec = (int)tempfloat;
150 sim->endcond_active = sim->endcond_active | endcond_ioniz * (ec > 0);
151
152 sim->endcond_torandpol = 0;
153 if( ec == 2) {
154 sim->endcond_torandpol = 1;
155 }
156
157
158 if( hdf5_read_double(OPTPATH "ENDCOND_LIM_SIMTIME",
160 file, qid, __FILE__, __LINE__) ) {return 1;}
161 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_MILEAGE",
163 file, qid, __FILE__, __LINE__) ) {return 1;}
164 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_CPUTIME",
166 file, qid, __FILE__, __LINE__) ) {return 1;}
167 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_RHO",
168 &sim->endcond_max_rho,
169 file, qid, __FILE__, __LINE__) ) {return 1;}
170 if( hdf5_read_double(OPTPATH "ENDCOND_MIN_RHO",
171 &sim->endcond_min_rho,
172 file, qid, __FILE__, __LINE__) ) {return 1;}
173 if( hdf5_read_double(OPTPATH "ENDCOND_MIN_ENERGY",
174 &sim->endcond_min_ekin,
175 file, qid, __FILE__, __LINE__) ) {return 1;}
176 if( hdf5_read_double(OPTPATH "ENDCOND_MIN_THERMAL",
178 file, qid, __FILE__, __LINE__) ) {return 1;}
179 sim->endcond_min_ekin *= CONST_E; // eV -> J
180
181 int temp;
182 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_POLOIDALORBS", &tempfloat,
183 file, qid, __FILE__, __LINE__) ) {return 1;}
184 temp = (int)tempfloat;
185 sim->endcond_max_polorb = temp * 2 *CONST_PI;
186
187 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_TOROIDALORBS", &tempfloat,
188 file, qid, __FILE__, __LINE__) ) {return 1;}
189 temp = (int)tempfloat;
190 sim->endcond_max_tororb = temp * 2 *CONST_PI;
191
192
193 /* See which diagnostics are active */
194 diag_data* diag = &sim->diag_data;
195
196 if( hdf5_read_double(OPTPATH "ENABLE_DIST_5D", &tempfloat,
197 file, qid, __FILE__, __LINE__) ) {return 1;}
198 diag->dist5D_collect = (int)tempfloat;
199 if( hdf5_read_double(OPTPATH "ENABLE_DIST_6D", &tempfloat,
200 file, qid, __FILE__, __LINE__) ) {return 1;}
201 diag->dist6D_collect = (int)tempfloat;
202 if( hdf5_read_double(OPTPATH "ENABLE_DIST_RHO5D", &tempfloat,
203 file, qid, __FILE__, __LINE__) ) {return 1;}
204 diag->distrho5D_collect = (int)tempfloat;
205 if( hdf5_read_double(OPTPATH "ENABLE_DIST_RHO6D", &tempfloat,
206 file, qid, __FILE__, __LINE__) ) {return 1;}
207 diag->distrho6D_collect = (int)tempfloat;
208 if( hdf5_read_double(OPTPATH "ENABLE_DIST_COM", &tempfloat,
209 file, qid, __FILE__, __LINE__) ) {return 1;}
210 diag->distCOM_collect = (int)tempfloat;
211 if( hdf5_read_double(OPTPATH "ENABLE_ORBITWRITE", &tempfloat,
212 file, qid, __FILE__, __LINE__) ) {return 1;}
213 diag->diagorb_collect = (int)tempfloat;
214 if( hdf5_read_double(OPTPATH "ENABLE_TRANSCOEF", &tempfloat,
215 file, qid, __FILE__, __LINE__) ) {return 1;}
216 diag->diagtrcof_collect = (int)tempfloat;
217
218 /* Read individual diagnostics data */
219 if(diag->dist5D_collect) {
220 if( hdf5_options_read_dist5D(file, &diag->dist5D, qid) ) {
221 return 1;
222 }
223 }
224 if(diag->dist6D_collect) {
225 if( hdf5_options_read_dist6D(file, &diag->dist6D, qid) ) {
226 return 1;
227 }
228 }
229 if(diag->distrho5D_collect) {
230 if( hdf5_options_read_distrho5D(file, &diag->distrho5D, qid) ) {
231 return 1;
232 }
233 }
234 if(diag->distrho6D_collect) {
235 if( hdf5_options_read_distrho6D(file, &diag->distrho6D, qid) ) {
236 return 1;
237 }
238 }
239 if(diag->distCOM_collect) {
240 if( hdf5_options_read_distCOM(file, &diag->distCOM, qid) ) {
241 return 1;
242 }
243 }
244 if(diag->diagorb_collect) {
245 diag->diagorb.record_mode = sim->sim_mode;
246 if(sim->record_mode && (sim->sim_mode == simulate_mode_fo ||
247 sim->sim_mode == simulate_mode_hybrid) ) {
249 }
250
251 if( hdf5_options_read_diagorb(file, &diag->diagorb, qid) ) {
252 return 1;
253 }
254 }
255
256 if(diag->diagtrcof_collect) {
257 if( hdf5_options_read_diagtrcof(file, &diag->diagtrcof, qid) ) {
258 return 1;
259 }
260 }
261
262 return 0;
263}
264
275 char* qid) {
276 #undef OPTPATH
277 #define OPTPATH "/options/opt_XXXXXXXXXX/"
278
279 real tempfloat;
280
281 if( hdf5_read_double(OPTPATH "DIST_MIN_R", &dist->min_r,
282 file, qid, __FILE__, __LINE__) ) {return 1;}
283 if( hdf5_read_double(OPTPATH "DIST_MAX_R", &dist->max_r,
284 file, qid, __FILE__, __LINE__) ) {return 1;}
285 if( hdf5_read_double(OPTPATH "DIST_NBIN_R", &tempfloat,
286 file, qid, __FILE__, __LINE__) ) {return 1;}
287 dist->n_r = (int)tempfloat;
288
289 if( hdf5_read_double(OPTPATH "DIST_MIN_PHI", &dist->min_phi,
290 file, qid, __FILE__, __LINE__) ) {return 1;}
291 if( hdf5_read_double(OPTPATH "DIST_MAX_PHI", &dist->max_phi,
292 file, qid, __FILE__, __LINE__) ) {return 1;}
293 if( hdf5_read_double(OPTPATH "DIST_NBIN_PHI", &tempfloat,
294 file, qid, __FILE__, __LINE__) ) {return 1;}
295 dist->n_phi = (int)tempfloat;
296 dist->min_phi = math_deg2rad(dist->min_phi);
297 dist->max_phi = math_deg2rad(dist->max_phi);
298
299 if( hdf5_read_double(OPTPATH "DIST_MIN_Z", &dist->min_z,
300 file, qid, __FILE__, __LINE__) ) {return 1;}
301 if( hdf5_read_double(OPTPATH "DIST_MAX_Z", &dist->max_z,
302 file, qid, __FILE__, __LINE__) ) {return 1;}
303 if( hdf5_read_double(OPTPATH "DIST_NBIN_Z", &tempfloat,
304 file, qid, __FILE__, __LINE__) ) {return 1;}
305 dist->n_z = (int)tempfloat;
306
307 if( hdf5_read_double(OPTPATH "DIST_MIN_PPA", &dist->min_ppara,
308 file, qid, __FILE__, __LINE__) ) {return 1;}
309 if( hdf5_read_double(OPTPATH "DIST_MAX_PPA", &dist->max_ppara,
310 file, qid, __FILE__, __LINE__) ) {return 1;}
311 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPA", &tempfloat,
312 file, qid, __FILE__, __LINE__) ) {return 1;}
313 dist->n_ppara = (int)tempfloat;
314
315 if( hdf5_read_double(OPTPATH "DIST_MIN_PPE", &dist->min_pperp,
316 file, qid, __FILE__, __LINE__) ) {return 1;}
317 if( hdf5_read_double(OPTPATH "DIST_MAX_PPE", &dist->max_pperp,
318 file, qid, __FILE__, __LINE__) ) {return 1;}
319 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPE", &tempfloat,
320 file, qid, __FILE__, __LINE__) ) {return 1;}
321 dist->n_pperp = (int)tempfloat;
322
323 if( hdf5_read_double(OPTPATH "DIST_MIN_TIME", &dist->min_time,
324 file, qid, __FILE__, __LINE__) ) {return 1;}
325 if( hdf5_read_double(OPTPATH "DIST_MAX_TIME", &dist->max_time,
326 file, qid, __FILE__, __LINE__) ) {return 1;}
327 if( hdf5_read_double(OPTPATH "DIST_NBIN_TIME", &tempfloat,
328 file, qid, __FILE__, __LINE__) ) {return 1;}
329 dist->n_time = (int)tempfloat;
330
331 if( hdf5_read_double(OPTPATH "DIST_MIN_CHARGE", &dist->min_q,
332 file, qid, __FILE__, __LINE__) ) {return 1;}
333 if( hdf5_read_double(OPTPATH "DIST_MAX_CHARGE", &dist->max_q,
334 file, qid, __FILE__, __LINE__) ) {return 1;}
335 if( hdf5_read_double(OPTPATH "DIST_NBIN_CHARGE", &tempfloat,
336 file, qid, __FILE__, __LINE__) ) {return 1;}
337 dist->n_q = (int)tempfloat;
338
339 return 0;
340}
341
352 char* qid) {
353 #undef OPTPATH
354 #define OPTPATH "/options/opt_XXXXXXXXXX/"
355
356 real tempfloat;
357
358 if( hdf5_read_double(OPTPATH "DIST_MIN_R", &dist->min_r,
359 file, qid, __FILE__, __LINE__) ) {return 1;}
360 if( hdf5_read_double(OPTPATH "DIST_MAX_R", &dist->max_r,
361 file, qid, __FILE__, __LINE__) ) {return 1;}
362 if( hdf5_read_double(OPTPATH "DIST_NBIN_R", &tempfloat,
363 file, qid, __FILE__, __LINE__) ) {return 1;}
364 dist->n_r = (int)tempfloat;
365
366 if( hdf5_read_double(OPTPATH "DIST_MIN_PHI", &dist->min_phi,
367 file, qid, __FILE__, __LINE__) ) {return 1;}
368 if( hdf5_read_double(OPTPATH "DIST_MAX_PHI", &dist->max_phi,
369 file, qid, __FILE__, __LINE__) ) {return 1;}
370 if( hdf5_read_double(OPTPATH "DIST_NBIN_PHI", &tempfloat,
371 file, qid, __FILE__, __LINE__) ) {return 1;}
372 dist->n_phi = (int)tempfloat;
373 dist->min_phi = math_deg2rad(dist->min_phi);
374 dist->max_phi = math_deg2rad(dist->max_phi);
375
376 if( hdf5_read_double(OPTPATH "DIST_MIN_Z", &dist->min_z,
377 file, qid, __FILE__, __LINE__) ) {return 1;}
378 if( hdf5_read_double(OPTPATH "DIST_MAX_Z", &dist->max_z,
379 file, qid, __FILE__, __LINE__) ) {return 1;}
380 if( hdf5_read_double(OPTPATH "DIST_NBIN_Z", &tempfloat,
381 file, qid, __FILE__, __LINE__) ) {return 1;}
382 dist->n_z = (int)tempfloat;
383
384 if( hdf5_read_double(OPTPATH "DIST_MIN_PR", &dist->min_pr,
385 file, qid, __FILE__, __LINE__) ) {return 1;}
386 if( hdf5_read_double(OPTPATH "DIST_MAX_PR", &dist->max_pr,
387 file, qid, __FILE__, __LINE__) ) {return 1;}
388 if( hdf5_read_double(OPTPATH "DIST_NBIN_PR", &tempfloat,
389 file, qid, __FILE__, __LINE__) ) {return 1;}
390 dist->n_pr = (int)tempfloat;
391
392 if( hdf5_read_double(OPTPATH "DIST_MIN_PPHI", &dist->min_pphi,
393 file, qid, __FILE__, __LINE__) ) {return 1;}
394 if( hdf5_read_double(OPTPATH "DIST_MAX_PPHI", &dist->max_pphi,
395 file, qid, __FILE__, __LINE__) ) {return 1;}
396 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPHI", &tempfloat,
397 file, qid, __FILE__, __LINE__) ) {return 1;}
398 dist->n_pphi = (int)tempfloat;
399
400 if( hdf5_read_double(OPTPATH "DIST_MIN_PZ", &dist->min_pz,
401 file, qid, __FILE__, __LINE__) ) {return 1;}
402 if( hdf5_read_double(OPTPATH "DIST_MAX_PZ", &dist->max_pz,
403 file, qid, __FILE__, __LINE__) ) {return 1;}
404 if( hdf5_read_double(OPTPATH "DIST_NBIN_PZ", &tempfloat,
405 file, qid, __FILE__, __LINE__) ) {return 1;}
406 dist->n_pz = (int)tempfloat;
407
408 if( hdf5_read_double(OPTPATH "DIST_MIN_TIME", &dist->min_time,
409 file, qid, __FILE__, __LINE__) ) {return 1;}
410 if( hdf5_read_double(OPTPATH "DIST_MAX_TIME", &dist->max_time,
411 file, qid, __FILE__, __LINE__) ) {return 1;}
412 if( hdf5_read_double(OPTPATH "DIST_NBIN_TIME", &tempfloat,
413 file, qid, __FILE__, __LINE__) ) {return 1;}
414 dist->n_time = (int)tempfloat;
415
416 if( hdf5_read_double(OPTPATH "DIST_MIN_CHARGE", &dist->min_q,
417 file, qid, __FILE__, __LINE__) ) {return 1;}
418 if( hdf5_read_double(OPTPATH "DIST_MAX_CHARGE", &dist->max_q,
419 file, qid, __FILE__, __LINE__) ) {return 1;}
420 if( hdf5_read_double(OPTPATH "DIST_NBIN_CHARGE", &tempfloat,
421 file, qid, __FILE__, __LINE__) ) {return 1;}
422 dist->n_q = (int)tempfloat;
423
424 return 0;
425}
426
437 char* qid) {
438 #undef OPTPATH
439 #define OPTPATH "/options/opt_XXXXXXXXXX/"
440
441 real tempfloat;
442
443 if( hdf5_read_double(OPTPATH "DIST_MIN_RHO", &dist->min_rho,
444 file, qid, __FILE__, __LINE__) ) {return 1;}
445 if( hdf5_read_double(OPTPATH "DIST_MAX_RHO", &dist->max_rho,
446 file, qid, __FILE__, __LINE__) ) {return 1;}
447 if( hdf5_read_double(OPTPATH "DIST_NBIN_RHO", &tempfloat,
448 file, qid, __FILE__, __LINE__) ) {return 1;}
449 dist->n_rho = (int)tempfloat;
450
451 if( hdf5_read_double(OPTPATH "DIST_MIN_PHI", &dist->min_phi,
452 file, qid, __FILE__, __LINE__) ) {return 1;}
453 if( hdf5_read_double(OPTPATH "DIST_MAX_PHI", &dist->max_phi,
454 file, qid, __FILE__, __LINE__) ) {return 1;}
455 if( hdf5_read_double(OPTPATH "DIST_NBIN_PHI", &tempfloat,
456 file, qid, __FILE__, __LINE__) ) {return 1;}
457 dist->n_phi = (int)tempfloat;
458 dist->min_phi = math_deg2rad(dist->min_phi);
459 dist->max_phi = math_deg2rad(dist->max_phi);
460
461 if( hdf5_read_double(OPTPATH "DIST_MIN_THETA", &dist->min_theta,
462 file, qid, __FILE__, __LINE__) ) {return 1;}
463 if( hdf5_read_double(OPTPATH "DIST_MAX_THETA", &dist->max_theta,
464 file, qid, __FILE__, __LINE__) ) {return 1;}
465 if( hdf5_read_double(OPTPATH "DIST_NBIN_THETA", &tempfloat,
466 file, qid, __FILE__, __LINE__) ) {return 1;}
467 dist->n_theta = (int)tempfloat;
468 dist->min_theta = math_deg2rad(dist->min_theta);
469 dist->max_theta = math_deg2rad(dist->max_theta);
470
471 if( hdf5_read_double(OPTPATH "DIST_MIN_PPA", &dist->min_ppara,
472 file, qid, __FILE__, __LINE__) ) {return 1;}
473 if( hdf5_read_double(OPTPATH "DIST_MAX_PPA", &dist->max_ppara,
474 file, qid, __FILE__, __LINE__) ) {return 1;}
475 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPA", &tempfloat,
476 file, qid, __FILE__, __LINE__) ) {return 1;}
477 dist->n_ppara = (int)tempfloat;
478
479 if( hdf5_read_double(OPTPATH "DIST_MIN_PPE", &dist->min_pperp,
480 file, qid, __FILE__, __LINE__) ) {return 1;}
481 if( hdf5_read_double(OPTPATH "DIST_MAX_PPE", &dist->max_pperp,
482 file, qid, __FILE__, __LINE__) ) {return 1;}
483 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPE", &tempfloat,
484 file, qid, __FILE__, __LINE__) ) {return 1;}
485 dist->n_pperp = (int)tempfloat;
486
487 if( hdf5_read_double(OPTPATH "DIST_MIN_TIME", &dist->min_time,
488 file, qid, __FILE__, __LINE__) ) {return 1;}
489 if( hdf5_read_double(OPTPATH "DIST_MAX_TIME", &dist->max_time,
490 file, qid, __FILE__, __LINE__) ) {return 1;}
491 if( hdf5_read_double(OPTPATH "DIST_NBIN_TIME", &tempfloat,
492 file, qid, __FILE__, __LINE__) ) {return 1;}
493 dist->n_time = (int)tempfloat;
494
495 if( hdf5_read_double(OPTPATH "DIST_MIN_CHARGE", &dist->min_q,
496 file, qid, __FILE__, __LINE__) ) {return 1;}
497 if( hdf5_read_double(OPTPATH "DIST_MAX_CHARGE", &dist->max_q,
498 file, qid, __FILE__, __LINE__) ) {return 1;}
499 if( hdf5_read_double(OPTPATH "DIST_NBIN_CHARGE", &tempfloat,
500 file, qid, __FILE__, __LINE__) ) {return 1;}
501 dist->n_q = (int)tempfloat;
502
503 return 0;
504}
505
516 char* qid) {
517 #undef OPTPATH
518 #define OPTPATH "/options/opt_XXXXXXXXXX/"
519
520 real tempfloat;
521
522 if( hdf5_read_double(OPTPATH "DIST_MIN_RHO", &dist->min_rho,
523 file, qid, __FILE__, __LINE__) ) {return 1;}
524 if( hdf5_read_double(OPTPATH "DIST_MAX_RHO", &dist->max_rho,
525 file, qid, __FILE__, __LINE__) ) {return 1;}
526 if( hdf5_read_double(OPTPATH "DIST_NBIN_RHO", &tempfloat,
527 file, qid, __FILE__, __LINE__) ) {return 1;}
528 dist->n_rho = (int)tempfloat;
529
530 if( hdf5_read_double(OPTPATH "DIST_MIN_PHI", &dist->min_phi,
531 file, qid, __FILE__, __LINE__) ) {return 1;}
532 if( hdf5_read_double(OPTPATH "DIST_MAX_PHI", &dist->max_phi,
533 file, qid, __FILE__, __LINE__) ) {return 1;}
534 if( hdf5_read_double(OPTPATH "DIST_NBIN_PHI", &tempfloat,
535 file, qid, __FILE__, __LINE__) ) {return 1;}
536 dist->n_phi = (int)tempfloat;
537 dist->min_phi = math_deg2rad(dist->min_phi);
538 dist->max_phi = math_deg2rad(dist->max_phi);
539
540 if( hdf5_read_double(OPTPATH "DIST_MIN_THETA", &dist->min_theta,
541 file, qid, __FILE__, __LINE__) ) {return 1;}
542 if( hdf5_read_double(OPTPATH "DIST_MAX_THETA", &dist->max_theta,
543 file, qid, __FILE__, __LINE__) ) {return 1;}
544 if( hdf5_read_double(OPTPATH "DIST_NBIN_THETA", &tempfloat,
545 file, qid, __FILE__, __LINE__) ) {return 1;}
546 dist->n_theta = (int)tempfloat;
547 dist->min_theta = math_deg2rad(dist->min_theta);
548 dist->max_theta = math_deg2rad(dist->max_theta);
549
550 if( hdf5_read_double(OPTPATH "DIST_MIN_PR", &dist->min_pr,
551 file, qid, __FILE__, __LINE__) ) {return 1;}
552 if( hdf5_read_double(OPTPATH "DIST_MAX_PR", &dist->max_pr,
553 file, qid, __FILE__, __LINE__) ) {return 1;}
554 if( hdf5_read_double(OPTPATH "DIST_NBIN_PR", &tempfloat,
555 file, qid, __FILE__, __LINE__) ) {return 1;}
556 dist->n_pr = (int)tempfloat;
557
558 if( hdf5_read_double(OPTPATH "DIST_MIN_PPHI", &dist->min_pphi,
559 file, qid, __FILE__, __LINE__) ) {return 1;}
560 if( hdf5_read_double(OPTPATH "DIST_MAX_PPHI", &dist->max_pphi,
561 file, qid, __FILE__, __LINE__) ) {return 1;}
562 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPHI", &tempfloat,
563 file, qid, __FILE__, __LINE__) ) {return 1;}
564 dist->n_pphi = (int)tempfloat;
565
566 if( hdf5_read_double(OPTPATH "DIST_MIN_PZ", &dist->min_pz,
567 file, qid, __FILE__, __LINE__) ) {return 1;}
568 if( hdf5_read_double(OPTPATH "DIST_MAX_PZ", &dist->max_pz,
569 file, qid, __FILE__, __LINE__) ) {return 1;}
570 if( hdf5_read_double(OPTPATH "DIST_NBIN_PZ", &tempfloat,
571 file, qid, __FILE__, __LINE__) ) {return 1;}
572 dist->n_pz = (int)tempfloat;
573
574 if( hdf5_read_double(OPTPATH "DIST_MIN_TIME", &dist->min_time,
575 file, qid, __FILE__, __LINE__) ) {return 1;}
576 if( hdf5_read_double(OPTPATH "DIST_MAX_TIME", &dist->max_time,
577 file, qid, __FILE__, __LINE__) ) {return 1;}
578 if( hdf5_read_double(OPTPATH "DIST_NBIN_TIME", &tempfloat,
579 file, qid, __FILE__, __LINE__) ) {return 1;}
580 dist->n_time = (int)tempfloat;
581
582 if( hdf5_read_double(OPTPATH "DIST_MIN_CHARGE", &dist->min_q,
583 file, qid, __FILE__, __LINE__) ) {return 1;}
584 if( hdf5_read_double(OPTPATH "DIST_MAX_CHARGE", &dist->max_q,
585 file, qid, __FILE__, __LINE__) ) {return 1;}
586 if( hdf5_read_double(OPTPATH "DIST_NBIN_CHARGE", &tempfloat,
587 file, qid, __FILE__, __LINE__) ) {return 1;}
588 dist->n_q = (int)tempfloat;
589
590 return 0;
591}
592
603 char* qid) {
604 #undef OPTPATH
605 #define OPTPATH "/options/opt_XXXXXXXXXX/"
606
607 real tempfloat;
608 if( hdf5_read_double(OPTPATH "DIST_MIN_MU", &dist->min_mu,
609 file, qid, __FILE__, __LINE__) ) {return 1;}
610 if( hdf5_read_double(OPTPATH "DIST_MAX_MU", &dist->max_mu,
611 file, qid, __FILE__, __LINE__) ) {return 1;}
612 if( hdf5_read_double(OPTPATH "DIST_NBIN_MU", &tempfloat,
613 file, qid, __FILE__, __LINE__) ) {return 1;}
614 dist->n_mu = (int)tempfloat;
615
616 if( hdf5_read_double(OPTPATH "DIST_MIN_EKIN", &dist->min_Ekin,
617 file, qid, __FILE__, __LINE__) ) {return 1;}
618 if( hdf5_read_double(OPTPATH "DIST_MAX_EKIN", &dist->max_Ekin,
619 file, qid, __FILE__, __LINE__) ) {return 1;}
620 if( hdf5_read_double(OPTPATH "DIST_NBIN_EKIN", &tempfloat,
621 file, qid, __FILE__, __LINE__) ) {return 1;}
622 dist->n_Ekin = (int)tempfloat;
623
624 if( hdf5_read_double(OPTPATH "DIST_MIN_PTOR", &dist->min_Ptor,
625 file, qid, __FILE__, __LINE__) ) {return 1;}
626 if( hdf5_read_double(OPTPATH "DIST_MAX_PTOR", &dist->max_Ptor,
627 file, qid, __FILE__, __LINE__) ) {return 1;}
628 if( hdf5_read_double(OPTPATH "DIST_NBIN_PTOR", &tempfloat,
629 file, qid, __FILE__, __LINE__) ) {return 1;}
630 dist->n_Ptor = (int)tempfloat;
631
632 return 0;
633}
634
645 char* qid) {
646 #undef OPTPATH
647 #define OPTPATH "/options/opt_XXXXXXXXXX/"
648
649 real tempfloat;
650
651 if( hdf5_read_double(OPTPATH "ORBITWRITE_MODE", &tempfloat,
652 file, qid, __FILE__, __LINE__) ) {return 1;}
653 diagorb->mode = (int)tempfloat;
654
655 if( hdf5_read_double(OPTPATH "ORBITWRITE_NPOINT", &tempfloat,
656 file, qid, __FILE__, __LINE__) ) {return 1;}
657 diagorb->Npnt = (int)tempfloat;
658 if( hdf5_read_double(OPTPATH "ORBITWRITE_INTERVAL",
659 &(diagorb->writeInterval),
660 file, qid, __FILE__, __LINE__) ) {return 1;}
661
662
663
664 for(int i=0; i < DIAG_ORB_MAXPOINCARES; i++) {
668 }
669
670 if( hdf5_read_double(OPTPATH "ORBITWRITE_TOROIDALANGLES",
671 (diagorb->toroidalangles),
672 file, qid, __FILE__, __LINE__) ) {return 1;}
673 if( hdf5_read_double(OPTPATH "ORBITWRITE_POLOIDALANGLES",
674 (diagorb->poloidalangles),
675 file, qid, __FILE__, __LINE__) ) {return 1;}
676 if( hdf5_read_double(OPTPATH "ORBITWRITE_RADIALDISTANCES",
677 (diagorb->radialdistances),
678 file, qid, __FILE__, __LINE__) ) {return 1;}
679
680
681 for(int i=0; i < DIAG_ORB_MAXPOINCARES; i++) {
682 if(diagorb->toroidalangles[0] < 0) {
683 /* Negative angle means plane is disabled */
684 diagorb->ntoroidalplots = 0;
685 break;
686 }
688 diagorb->ntoroidalplots = i;
689 break;
690 }
691 }
692
693 for(int i=0; i < DIAG_ORB_MAXPOINCARES; i++) {
694 if(diagorb->poloidalangles[0] < 0) {
695 /* Negative angle means plane is disabled */
696 diagorb->npoloidalplots = 0;
697 break;
698 }
700 diagorb->npoloidalplots = i;
701 break;
702 }
703 }
704
705 for(int i=0; i < DIAG_ORB_MAXPOINCARES; i++) {
706 if(diagorb->radialdistances[0] < 0) {
707 /* Negative angle means plane is disabled */
708 diagorb->nradialplots = 0;
709 break;
710 }
711 if(diagorb->radialdistances[i] == RADIAL_FILLER_VALUE) {
712 diagorb->nradialplots = i;
713 break;
714 }
715 }
716
717 for(int i=0; i < diagorb->ntoroidalplots; i++) {
718 diagorb->toroidalangles[i] = diagorb->toroidalangles[i]*CONST_PI/180;
719 }
720 for(int i=0; i < diagorb->npoloidalplots; i++) {
721 diagorb->poloidalangles[i] = diagorb->poloidalangles[i]*CONST_PI/180;
722 }
723 return 0;
724}
725
736 hid_t file, diag_transcoef_data* diagtrcof, char* qid) {
737 #undef OPTPATH
738 #define OPTPATH "/options/opt_XXXXXXXXXX/"
739
740 if( hdf5_read_double(OPTPATH "TRANSCOEF_INTERVAL", &diagtrcof->interval,
741 file, qid, __FILE__, __LINE__) ) {return 1;}
742
743 real tempfloat;
744 if( hdf5_read_double(OPTPATH "TRANSCOEF_NAVG", &tempfloat,
745 file, qid, __FILE__, __LINE__) ) {return 1;}
746 diagtrcof->Navg = (int)tempfloat;
747
748 if( hdf5_read_double(OPTPATH "TRANSCOEF_RECORDRHO", &tempfloat,
749 file, qid, __FILE__, __LINE__) ) {return 1;}
750 diagtrcof->recordrho = (int)tempfloat;
751
752 return 0;
753}
Main header file for ASCOT5.
double real
Definition ascot5.h:85
Header file containing physical and mathematical constants.
#define CONST_PI
pi
Definition consts.h:11
#define CONST_E
Elementary charge [C]
Definition consts.h:32
Header file for diag.c.
Header file for diag_orb.c.
#define DIAG_ORB_MAXPOINCARES
Definition diag_orb.h:15
Header file for dist_5D.c.
Header file for dist_6D.c.
Header file for dist_com.c.
Header file for dist_rho5D.c.
Header file for dist_rho6D.c.
Header file for endcond.c.
@ endcond_therm
Definition endcond.h:21
@ endcond_tormax
Definition endcond.h:26
@ endcond_emin
Definition endcond.h:20
@ endcond_rhomin
Definition endcond.h:23
@ endcond_tlim
Definition endcond.h:19
@ endcond_neutr
Definition endcond.h:29
@ endcond_cpumax
Definition endcond.h:27
@ endcond_polmax
Definition endcond.h:25
@ endcond_rhomax
Definition endcond.h:24
@ endcond_wall
Definition endcond.h:22
@ endcond_ioniz
Definition endcond.h:30
int hdf5_read_double(const char *var, real *ptr, hid_t file, char *qid, const char *errfile, int errline)
Read double-valued data from ASCOT5 HDF5 file.
Header file for hdf5_helpers.h.
int hdf5_options_read_dist5D(hid_t file, dist_5D_data *dist, char *qid)
Helper function to read dist5D settings from HDF5 file.
int hdf5_options_read_distCOM(hid_t file, dist_COM_data *dist, char *qid)
Helper function to read COM dist settings from HDF5 file.
int hdf5_options_read_dist6D(hid_t file, dist_6D_data *dist, char *qid)
Helper function to read dist6D settings from HDF5 file.
int hdf5_options_read_distrho6D(hid_t file, dist_rho6D_data *dist, char *qid)
Helper function to read distrho6D settings from HDF5 file.
int hdf5_options_read(hid_t file, sim_data *sim, char *qid)
Read options and diagnostics settings from HDF5 file.
#define OPTPATH
int hdf5_options_read_diagtrcof(hid_t file, diag_transcoef_data *diagtrcof, char *qid)
Helper function to read transport coefficient settings from HDF5 file.
int hdf5_options_read_distrho5D(hid_t file, dist_rho5D_data *dist, char *qid)
Helper function to read distrho5D settings from HDF5 file.
int hdf5_options_read_diagorb(hid_t file, diag_orb_data *diagorb, char *qid)
Helper function to read orbit diagnostics settings from HDF5 file.
Header file for hdf5_options.c.
#define RADIAL_FILLER_VALUE
#define TOROIDAL_ANGLE_FILLER_VALUE
#define POLOIDAL_ANGLE_FILLER_VALUE
Header file for math.c.
#define math_deg2rad(a)
Convert degrees to radians.
Definition math.h:107
Header file for simulate.c.
@ simulate_mode_fo
Definition simulate.h:33
@ simulate_mode_gc
Definition simulate.h:36
@ simulate_mode_hybrid
Definition simulate.h:41
Diagnostics data struct.
Definition diag.h:21
dist_COM_data distCOM
Definition diag.h:35
int distrho5D_collect
Definition diag.h:25
int diagtrcof_collect
Definition diag.h:28
diag_transcoef_data diagtrcof
Definition diag.h:36
int distrho6D_collect
Definition diag.h:26
diag_orb_data diagorb
Definition diag.h:30
dist_rho6D_data distrho6D
Definition diag.h:34
dist_5D_data dist5D
Definition diag.h:31
int dist5D_collect
Definition diag.h:23
int dist6D_collect
Definition diag.h:24
int distCOM_collect
Definition diag.h:27
dist_6D_data dist6D
Definition diag.h:32
dist_rho5D_data distrho5D
Definition diag.h:33
int diagorb_collect
Definition diag.h:22
Orbit diagnostics data struct.
Definition diag_orb.h:42
real poloidalangles[DIAG_ORB_MAXPOINCARES]
Definition diag_orb.h:78
int ntoroidalplots
Definition diag_orb.h:73
real toroidalangles[DIAG_ORB_MAXPOINCARES]
Definition diag_orb.h:77
real writeInterval
Definition diag_orb.h:72
real radialdistances[DIAG_ORB_MAXPOINCARES]
Definition diag_orb.h:79
int nradialplots
Definition diag_orb.h:75
int record_mode
Definition diag_orb.h:76
int npoloidalplots
Definition diag_orb.h:74
Transport coefficient diagnostics offload data struct.
Histogram parameters.
Definition dist_5D.h:15
real min_time
Definition dist_5D.h:37
real max_r
Definition dist_5D.h:18
real max_pperp
Definition dist_5D.h:34
real min_phi
Definition dist_5D.h:21
real max_phi
Definition dist_5D.h:22
real min_ppara
Definition dist_5D.h:29
real max_z
Definition dist_5D.h:26
real max_time
Definition dist_5D.h:38
int n_ppara
Definition dist_5D.h:28
int n_pperp
Definition dist_5D.h:32
real min_z
Definition dist_5D.h:25
real max_ppara
Definition dist_5D.h:30
real min_r
Definition dist_5D.h:17
real max_q
Definition dist_5D.h:42
real min_pperp
Definition dist_5D.h:33
real min_q
Definition dist_5D.h:41
Histogram parameters on target.
Definition dist_6D.h:15
real max_phi
Definition dist_6D.h:22
real min_phi
Definition dist_6D.h:21
real min_pz
Definition dist_6D.h:37
real max_pz
Definition dist_6D.h:38
real min_time
Definition dist_6D.h:41
real min_q
Definition dist_6D.h:45
real max_pphi
Definition dist_6D.h:34
real max_time
Definition dist_6D.h:42
real min_pphi
Definition dist_6D.h:33
real min_pr
Definition dist_6D.h:29
real max_pr
Definition dist_6D.h:30
real max_z
Definition dist_6D.h:26
real min_r
Definition dist_6D.h:17
real max_r
Definition dist_6D.h:18
real max_q
Definition dist_6D.h:46
real min_z
Definition dist_6D.h:25
Histogram parameters on target.
Definition dist_com.h:16
real max_Ptor
Definition dist_com.h:27
real min_Ptor
Definition dist_com.h:26
real min_Ekin
Definition dist_com.h:22
real max_Ekin
Definition dist_com.h:23
Histogram parameters.
Definition dist_rho5D.h:15
Histogram parameters on target.
Definition dist_rho6D.h:15
Simulation data struct.
Definition simulate.h:57
int enable_orbfol
Definition simulate.h:97
real endcond_min_ekin
Definition simulate.h:118
int endcond_torandpol
Definition simulate.h:123
real endcond_max_rho
Definition simulate.h:117
int record_mode
Definition simulate.h:78
int sim_mode
Definition simulate.h:76
int disable_energyccoll
Definition simulate.h:103
real ada_max_drho
Definition simulate.h:91
real ada_tol_clmbcol
Definition simulate.h:89
real endcond_max_tororb
Definition simulate.h:121
int enable_atomic
Definition simulate.h:100
int disable_gcdiffccoll
Definition simulate.h:107
real endcond_min_thermal
Definition simulate.h:119
real endcond_max_mileage
Definition simulate.h:114
real fix_usrdef_val
Definition simulate.h:82
int disable_pitchccoll
Definition simulate.h:105
int enable_mhd
Definition simulate.h:99
int endcond_active
Definition simulate.h:112
int fix_usrdef_use
Definition simulate.h:81
real endcond_max_polorb
Definition simulate.h:122
int fix_gyrodef_nstep
Definition simulate.h:83
real endcond_max_cputime
Definition simulate.h:115
real endcond_min_rho
Definition simulate.h:116
real endcond_lim_simtime
Definition simulate.h:113
int enable_ada
Definition simulate.h:77
int reverse_time
Definition simulate.h:109
real ada_max_dphi
Definition simulate.h:93
int enable_clmbcol
Definition simulate.h:98
int disable_gctransform
Definition simulate.h:101
real ada_tol_orbfol
Definition simulate.h:87
diag_data diag_data
Definition simulate.h:68