ASCOT5
Loading...
Searching...
No Matches
hdf5_dist.c
Go to the documentation of this file.
1
5#include <stdlib.h>
6#include <hdf5.h>
7#include "../ascot5.h"
8#include "../diag/dist_5D.h"
9#include "../diag/dist_6D.h"
10#include "../diag/dist_rho5D.h"
11#include "../diag/dist_rho6D.h"
12#include "../diag/dist_com.h"
13#include "../math.h"
14#include "../consts.h"
15#include "hdf5_histogram.h"
16#include "hdf5_helpers.h"
17#include "hdf5_dist.h"
18
27int hdf5_dist_write_5D(hid_t f, char* path, dist_5D_offload_data* dist,
28 real* hist) {
29 int abscissa_dim = 7;
30 int ordinate_dim = 1;
31
32 int abscissa_n_slots[7];
33 abscissa_n_slots[0] = dist->n_r;
34 abscissa_n_slots[1] = dist->n_phi;
35 abscissa_n_slots[2] = dist->n_z;
36 abscissa_n_slots[3] = dist->n_ppara;
37 abscissa_n_slots[4] = dist->n_pperp;
38 abscissa_n_slots[5] = dist->n_time;
39 abscissa_n_slots[6] = dist->n_q;
40
41 double abscissa_min[7];
42 abscissa_min[0] = dist->min_r;
43 abscissa_min[1] = math_rad2deg(dist->min_phi);
44 abscissa_min[2] = dist->min_z;
45 abscissa_min[3] = dist->min_ppara;
46 abscissa_min[4] = dist->min_pperp;
47 abscissa_min[5] = dist->min_time;
48 abscissa_min[6] = dist->min_q;
49
50 double abscissa_max[7];
51 abscissa_max[0] = dist->max_r;
52 abscissa_max[1] = math_rad2deg(dist->max_phi);
53 abscissa_max[2] = dist->max_z;
54 abscissa_max[3] = dist->max_ppara;
55 abscissa_max[4] = dist->max_pperp;
56 abscissa_max[5] = dist->max_time;
57 abscissa_max[6] = dist->max_q;
58
59 char* abscissa_names[] = { "r", "phi", "z", "ppar", "pperp", "time",
60 "charge" };
61 char* abscissa_units[] = { "m", "deg", "m", "kg*m/s", "kg*m/s", "s", "e" };
62 char* ordinate_names[] = { "distribution" };
63 char* ordinate_units[] = { "s/(m^5*kg^2*deg*e)" };
64
65 /* Create a group for this distribution and write the data in it */
67 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
68 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
69 ordinate_names, hist);
70
71 return retval;
72}
73
82int hdf5_dist_write_6D(hid_t f, char* path, dist_6D_offload_data* dist,
83 real* hist) {
84 int abscissa_dim = 8;
85 int ordinate_dim = 1;
86
87 int abscissa_n_slots[8];
88 abscissa_n_slots[0] = dist->n_r;
89 abscissa_n_slots[1] = dist->n_phi;
90 abscissa_n_slots[2] = dist->n_z;
91 abscissa_n_slots[3] = dist->n_pr;
92 abscissa_n_slots[4] = dist->n_pphi;
93 abscissa_n_slots[5] = dist->n_pz;
94 abscissa_n_slots[6] = dist->n_time;
95 abscissa_n_slots[7] = dist->n_q;
96
97 double abscissa_min[8];
98 abscissa_min[0] = dist->min_r;
99 abscissa_min[1] = math_rad2deg(dist->min_phi);
100 abscissa_min[2] = dist->min_z;
101 abscissa_min[3] = dist->min_pr;
102 abscissa_min[4] = dist->min_pphi;
103 abscissa_min[5] = dist->min_pz;
104 abscissa_min[6] = dist->min_time;
105 abscissa_min[7] = dist->min_q;
106
107 double abscissa_max[8];
108 abscissa_max[0] = dist->max_r;
109 abscissa_max[1] = math_rad2deg(dist->max_phi);
110 abscissa_max[2] = dist->max_z;
111 abscissa_max[3] = dist->max_pr;
112 abscissa_max[4] = dist->max_pphi;
113 abscissa_max[5] = dist->max_pz;
114 abscissa_max[6] = dist->max_time;
115 abscissa_max[7] = dist->max_q;
116
117 char* abscissa_names[] = { "r", "phi", "z", "pr", "pphi", "pz", "time",
118 "charge" };
119 char* abscissa_units[] = { "m", "deg", "m", "kg*m/s", "kg*m/s", "kg*m/s",
120 "s", "e" };
121 char* ordinate_names[] = { "distribution" };
122 char* ordinate_units[] = { "s/(m^6*kg^3*deg*e)" };
123
124 /* Create a group for this distribution and write the data in it */
126 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
127 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
128 ordinate_names, hist);
129
130 return retval;
131}
132
141int hdf5_dist_write_rho5D(hid_t f, char* path, dist_rho5D_offload_data* dist,
142 real* hist) {
143 int abscissa_dim = 7;
144 int ordinate_dim = 1;
145
146 int abscissa_n_slots[7];
147 abscissa_n_slots[0] = dist->n_rho;
148 abscissa_n_slots[1] = dist->n_theta;
149 abscissa_n_slots[2] = dist->n_phi;
150 abscissa_n_slots[3] = dist->n_ppara;
151 abscissa_n_slots[4] = dist->n_pperp;
152 abscissa_n_slots[5] = dist->n_time;
153 abscissa_n_slots[6] = dist->n_q;
154
155 double abscissa_min[7];
156 abscissa_min[0] = dist->min_rho;
157 abscissa_min[1] = math_rad2deg(dist->min_theta);
158 abscissa_min[2] = math_rad2deg(dist->min_phi);
159 abscissa_min[3] = dist->min_ppara;
160 abscissa_min[4] = dist->min_pperp;
161 abscissa_min[5] = dist->min_time;
162 abscissa_min[6] = dist->min_q;
163
164 double abscissa_max[7];
165 abscissa_max[0] = dist->max_rho;
166 abscissa_max[1] = math_rad2deg(dist->max_theta);
167 abscissa_max[2] = math_rad2deg(dist->max_phi);
168 abscissa_max[3] = dist->max_ppara;
169 abscissa_max[4] = dist->max_pperp;
170 abscissa_max[5] = dist->max_time;
171 abscissa_max[6] = dist->max_q;
172
173 char* abscissa_names[] = { "rho", "theta", "phi", "ppar", "pperp", "time",
174 "charge" };
175 char* abscissa_units[] = { "1", "deg", "deg", "kg*m/s", "kg*m/s",
176 "s", "e" };
177 char* ordinate_names[] = { "distribution" };
178 char* ordinate_units[] = { "s/(m^2*kg^2*deg^2*e)" };
179
180 /* Create a group for this distribution and write the data in it */
182 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
183 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
184 ordinate_names, hist);
185
186 return retval;
187}
188
197int hdf5_dist_write_rho6D(hid_t f, char* path, dist_rho6D_offload_data* dist,
198 real* hist) {
199 int abscissa_dim = 8;
200 int ordinate_dim = 1;
201
202 int abscissa_n_slots[8];
203 abscissa_n_slots[0] = dist->n_rho;
204 abscissa_n_slots[1] = dist->n_theta;
205 abscissa_n_slots[2] = dist->n_phi;
206 abscissa_n_slots[3] = dist->n_pr;
207 abscissa_n_slots[4] = dist->n_pphi;
208 abscissa_n_slots[5] = dist->n_pz;
209 abscissa_n_slots[6] = dist->n_time;
210 abscissa_n_slots[7] = dist->n_q;
211
212 double abscissa_min[8];
213 abscissa_min[0] = dist->min_rho;
214 abscissa_min[1] = math_rad2deg(dist->min_theta);
215 abscissa_min[2] = math_rad2deg(dist->min_phi);
216 abscissa_min[3] = dist->min_pr;
217 abscissa_min[4] = dist->min_pphi;
218 abscissa_min[5] = dist->min_pz;
219 abscissa_min[6] = dist->min_time;
220 abscissa_min[7] = dist->min_q;
221
222 double abscissa_max[8];
223 abscissa_max[0] = dist->max_rho;
224 abscissa_max[1] = math_rad2deg(dist->max_theta);
225 abscissa_max[2] = math_rad2deg(dist->max_phi);
226 abscissa_max[3] = dist->max_pr;
227 abscissa_max[4] = dist->max_pphi;
228 abscissa_max[5] = dist->max_pz;
229 abscissa_max[6] = dist->max_time;
230 abscissa_max[7] = dist->max_q;
231
232 char* abscissa_names[] = { "rho", "theta", "phi", "pr", "pphi", "pz",
233 "time", "charge" };
234 char* abscissa_units[] = { "1", "deg", "deg", "kg*m/s", "kg*m/s", "kg*m/s",
235 "s", "e" };
236 char* ordinate_names[] = { "distribution" };
237 char* ordinate_units[] = { "s^2/(m^3*kg^3*deg^2*e)" };
238
239 /* Create a group for this distribution and write the data in it */
241 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
242 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
243 ordinate_names, hist);
244
245 return retval;
246}
247
256int hdf5_dist_write_COM(hid_t f, char* path, dist_COM_offload_data* dist,
257 real* hist) {
258
259 int abscissa_dim = 3;
260 int ordinate_dim = 1;
261
262 int abscissa_n_slots[3];
263 abscissa_n_slots[0] = dist->n_mu;
264 abscissa_n_slots[1] = dist->n_Ekin;
265 abscissa_n_slots[2] = dist->n_Ptor;
266
267 double abscissa_min[3];
268 abscissa_min[0] = dist->min_mu / CONST_E;
269 abscissa_min[1] = dist->min_Ekin / CONST_E;
270 abscissa_min[2] = dist->min_Ptor / CONST_E;
271
272 double abscissa_max[3];
273 abscissa_max[0] = dist->max_mu / CONST_E;
274 abscissa_max[1] = dist->max_Ekin / CONST_E;
275 abscissa_max[2] = dist->max_Ptor / CONST_E;
276
277 char* abscissa_names[] = { "mu", "ekin", "ptor"};
278 char* abscissa_units[] = { "eV/T", "eV", "eV*s"};
279 char* ordinate_names[] = { "distribution" };
280 char* ordinate_units[] = { "T/(eV**3*s)"};
281
282 /* Create a group for this distribution and write the data in it */
284 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
285 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
286 ordinate_names, hist);
287
288 return retval;
289}
Main header file for ASCOT5.
double real
Definition ascot5.h:85
Header file containing physical and mathematical constants.
#define CONST_E
Elementary charge [C]
Definition consts.h:32
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.
int hdf5_dist_write_6D(hid_t f, char *path, dist_6D_offload_data *dist, real *hist)
Write 6D distribution to an existing result group.
Definition hdf5_dist.c:82
int hdf5_dist_write_rho5D(hid_t f, char *path, dist_rho5D_offload_data *dist, real *hist)
Write rho 5D distribution to an existing result group.
Definition hdf5_dist.c:141
int hdf5_dist_write_COM(hid_t f, char *path, dist_COM_offload_data *dist, real *hist)
Write constants-of-motion distribution to an existing result group.
Definition hdf5_dist.c:256
int hdf5_dist_write_rho6D(hid_t f, char *path, dist_rho6D_offload_data *dist, real *hist)
Write rho 6D distribution to an existing result group.
Definition hdf5_dist.c:197
int hdf5_dist_write_5D(hid_t f, char *path, dist_5D_offload_data *dist, real *hist)
Write 5D distribution to an existing result group.
Definition hdf5_dist.c:27
Header file for hdf5_helpers.h.
int hdf5_histogram_write_uniform_double(hid_t f, const char *path, int abscissaDim, int ordinateDim, int *abscissaNslots, double *abscissaMin, double *abscissaMax, char **abscissaUnits, char **abscissaNames, char **ordinateUnits, char **ordinateNames, double *ordinate)
Write a histogram with uniform grid to HDF5 file.
Header file for hdf5_histogram.c.
Header file for math.c.
#define math_rad2deg(a)
Convert radians to degrees.
Definition math.h:110
Histogram parameters that will be offloaded to target.
Definition dist_5D.h:15
Histogram parameters that will be offloaded to target.
Definition dist_6D.h:15
Histogram parameters that will be offloaded to target.
Definition dist_com.h:16
Histogram parameters that will be offloaded to target.
Definition dist_rho5D.h:15
Histogram parameters that will be offloaded to target.
Definition dist_rho6D.h:15