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
26int hdf5_dist_write_5D(hid_t f, char* path, dist_5D_data* dist) {
27 int abscissa_dim = 7;
28 int ordinate_dim = 1;
29
30 int abscissa_n_slots[7];
31 abscissa_n_slots[0] = dist->n_r;
32 abscissa_n_slots[1] = dist->n_phi;
33 abscissa_n_slots[2] = dist->n_z;
34 abscissa_n_slots[3] = dist->n_ppara;
35 abscissa_n_slots[4] = dist->n_pperp;
36 abscissa_n_slots[5] = dist->n_time;
37 abscissa_n_slots[6] = dist->n_q;
38
39 double abscissa_min[7];
40 abscissa_min[0] = dist->min_r;
41 abscissa_min[1] = math_rad2deg(dist->min_phi);
42 abscissa_min[2] = dist->min_z;
43 abscissa_min[3] = dist->min_ppara;
44 abscissa_min[4] = dist->min_pperp;
45 abscissa_min[5] = dist->min_time;
46 abscissa_min[6] = dist->min_q;
47
48 double abscissa_max[7];
49 abscissa_max[0] = dist->max_r;
50 abscissa_max[1] = math_rad2deg(dist->max_phi);
51 abscissa_max[2] = dist->max_z;
52 abscissa_max[3] = dist->max_ppara;
53 abscissa_max[4] = dist->max_pperp;
54 abscissa_max[5] = dist->max_time;
55 abscissa_max[6] = dist->max_q;
56
57 char* abscissa_names[] = { "r", "phi", "z", "ppar", "pperp", "time",
58 "charge" };
59 char* abscissa_units[] = { "m", "deg", "m", "kg*m/s", "kg*m/s", "s", "e" };
60 char* ordinate_names[] = { "distribution" };
61 char* ordinate_units[] = { "s/(m^5*kg^2*deg*e)" };
62
63 /* Create a group for this distribution and write the data in it */
65 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
66 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
67 ordinate_names, dist->histogram);
68
69 return retval;
70}
71
80int hdf5_dist_write_6D(hid_t f, char* path, dist_6D_data* dist) {
81 int abscissa_dim = 8;
82 int ordinate_dim = 1;
83
84 int abscissa_n_slots[8];
85 abscissa_n_slots[0] = dist->n_r;
86 abscissa_n_slots[1] = dist->n_phi;
87 abscissa_n_slots[2] = dist->n_z;
88 abscissa_n_slots[3] = dist->n_pr;
89 abscissa_n_slots[4] = dist->n_pphi;
90 abscissa_n_slots[5] = dist->n_pz;
91 abscissa_n_slots[6] = dist->n_time;
92 abscissa_n_slots[7] = dist->n_q;
93
94 double abscissa_min[8];
95 abscissa_min[0] = dist->min_r;
96 abscissa_min[1] = math_rad2deg(dist->min_phi);
97 abscissa_min[2] = dist->min_z;
98 abscissa_min[3] = dist->min_pr;
99 abscissa_min[4] = dist->min_pphi;
100 abscissa_min[5] = dist->min_pz;
101 abscissa_min[6] = dist->min_time;
102 abscissa_min[7] = dist->min_q;
103
104 double abscissa_max[8];
105 abscissa_max[0] = dist->max_r;
106 abscissa_max[1] = math_rad2deg(dist->max_phi);
107 abscissa_max[2] = dist->max_z;
108 abscissa_max[3] = dist->max_pr;
109 abscissa_max[4] = dist->max_pphi;
110 abscissa_max[5] = dist->max_pz;
111 abscissa_max[6] = dist->max_time;
112 abscissa_max[7] = dist->max_q;
113
114 char* abscissa_names[] = { "r", "phi", "z", "pr", "pphi", "pz", "time",
115 "charge" };
116 char* abscissa_units[] = { "m", "deg", "m", "kg*m/s", "kg*m/s", "kg*m/s",
117 "s", "e" };
118 char* ordinate_names[] = { "distribution" };
119 char* ordinate_units[] = { "s/(m^6*kg^3*deg*e)" };
120
121 /* Create a group for this distribution and write the data in it */
123 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
124 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
125 ordinate_names, dist->histogram);
126
127 return retval;
128}
129
137int hdf5_dist_write_rho5D(hid_t f, char* path, dist_rho5D_data* dist) {
138 int abscissa_dim = 7;
139 int ordinate_dim = 1;
140
141 int abscissa_n_slots[7];
142 abscissa_n_slots[0] = dist->n_rho;
143 abscissa_n_slots[1] = dist->n_theta;
144 abscissa_n_slots[2] = dist->n_phi;
145 abscissa_n_slots[3] = dist->n_ppara;
146 abscissa_n_slots[4] = dist->n_pperp;
147 abscissa_n_slots[5] = dist->n_time;
148 abscissa_n_slots[6] = dist->n_q;
149
150 double abscissa_min[7];
151 abscissa_min[0] = dist->min_rho;
152 abscissa_min[1] = math_rad2deg(dist->min_theta);
153 abscissa_min[2] = math_rad2deg(dist->min_phi);
154 abscissa_min[3] = dist->min_ppara;
155 abscissa_min[4] = dist->min_pperp;
156 abscissa_min[5] = dist->min_time;
157 abscissa_min[6] = dist->min_q;
158
159 double abscissa_max[7];
160 abscissa_max[0] = dist->max_rho;
161 abscissa_max[1] = math_rad2deg(dist->max_theta);
162 abscissa_max[2] = math_rad2deg(dist->max_phi);
163 abscissa_max[3] = dist->max_ppara;
164 abscissa_max[4] = dist->max_pperp;
165 abscissa_max[5] = dist->max_time;
166 abscissa_max[6] = dist->max_q;
167
168 char* abscissa_names[] = { "rho", "theta", "phi", "ppar", "pperp", "time",
169 "charge" };
170 char* abscissa_units[] = { "1", "deg", "deg", "kg*m/s", "kg*m/s",
171 "s", "e" };
172 char* ordinate_names[] = { "distribution" };
173 char* ordinate_units[] = { "s/(m^2*kg^2*deg^2*e)" };
174
175 /* Create a group for this distribution and write the data in it */
177 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
178 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
179 ordinate_names, dist->histogram);
180
181 return retval;
182}
183
191int hdf5_dist_write_rho6D(hid_t f, char* path, dist_rho6D_data* dist) {
192 int abscissa_dim = 8;
193 int ordinate_dim = 1;
194
195 int abscissa_n_slots[8];
196 abscissa_n_slots[0] = dist->n_rho;
197 abscissa_n_slots[1] = dist->n_theta;
198 abscissa_n_slots[2] = dist->n_phi;
199 abscissa_n_slots[3] = dist->n_pr;
200 abscissa_n_slots[4] = dist->n_pphi;
201 abscissa_n_slots[5] = dist->n_pz;
202 abscissa_n_slots[6] = dist->n_time;
203 abscissa_n_slots[7] = dist->n_q;
204
205 double abscissa_min[8];
206 abscissa_min[0] = dist->min_rho;
207 abscissa_min[1] = math_rad2deg(dist->min_theta);
208 abscissa_min[2] = math_rad2deg(dist->min_phi);
209 abscissa_min[3] = dist->min_pr;
210 abscissa_min[4] = dist->min_pphi;
211 abscissa_min[5] = dist->min_pz;
212 abscissa_min[6] = dist->min_time;
213 abscissa_min[7] = dist->min_q;
214
215 double abscissa_max[8];
216 abscissa_max[0] = dist->max_rho;
217 abscissa_max[1] = math_rad2deg(dist->max_theta);
218 abscissa_max[2] = math_rad2deg(dist->max_phi);
219 abscissa_max[3] = dist->max_pr;
220 abscissa_max[4] = dist->max_pphi;
221 abscissa_max[5] = dist->max_pz;
222 abscissa_max[6] = dist->max_time;
223 abscissa_max[7] = dist->max_q;
224
225 char* abscissa_names[] = { "rho", "theta", "phi", "pr", "pphi", "pz",
226 "time", "charge" };
227 char* abscissa_units[] = { "1", "deg", "deg", "kg*m/s", "kg*m/s", "kg*m/s",
228 "s", "e" };
229 char* ordinate_names[] = { "distribution" };
230 char* ordinate_units[] = { "s^2/(m^3*kg^3*deg^2*e)" };
231
232 /* Create a group for this distribution and write the data in it */
234 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
235 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
236 ordinate_names, dist->histogram);
237
238 return retval;
239}
240
248int hdf5_dist_write_COM(hid_t f, char* path, dist_COM_data* dist) {
249
250 int abscissa_dim = 3;
251 int ordinate_dim = 1;
252
253 int abscissa_n_slots[3];
254 abscissa_n_slots[0] = dist->n_mu;
255 abscissa_n_slots[1] = dist->n_Ekin;
256 abscissa_n_slots[2] = dist->n_Ptor;
257
258 double abscissa_min[3];
259 abscissa_min[0] = dist->min_mu / CONST_E;
260 abscissa_min[1] = dist->min_Ekin / CONST_E;
261 abscissa_min[2] = dist->min_Ptor / CONST_E;
262
263 double abscissa_max[3];
264 abscissa_max[0] = dist->max_mu / CONST_E;
265 abscissa_max[1] = dist->max_Ekin / CONST_E;
266 abscissa_max[2] = dist->max_Ptor / CONST_E;
267
268 char* abscissa_names[] = { "mu", "ekin", "ptor"};
269 char* abscissa_units[] = { "eV/T", "eV", "eV*s"};
270 char* ordinate_names[] = { "distribution" };
271 char* ordinate_units[] = { "T/(eV**3*s)"};
272
273 /* Create a group for this distribution and write the data in it */
275 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
276 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
277 ordinate_names, dist->histogram);
278
279 return retval;
280}
Main header file for ASCOT5.
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_rho6D(hid_t f, char *path, dist_rho6D_data *dist)
Write rho 6D distribution to an existing result group.
Definition hdf5_dist.c:191
int hdf5_dist_write_COM(hid_t f, char *path, dist_COM_data *dist)
Write constants-of-motion distribution to an existing result group.
Definition hdf5_dist.c:248
int hdf5_dist_write_5D(hid_t f, char *path, dist_5D_data *dist)
Write 5D distribution to an existing result group.
Definition hdf5_dist.c:26
int hdf5_dist_write_rho5D(hid_t f, char *path, dist_rho5D_data *dist)
Write rho 5D distribution to an existing result group.
Definition hdf5_dist.c:137
int hdf5_dist_write_6D(hid_t f, char *path, dist_6D_data *dist)
Write 6D distribution to an existing result group.
Definition hdf5_dist.c:80
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.
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 * histogram
Definition dist_5D.h:51
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 * histogram
Definition dist_6D.h:56
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 * histogram
Definition dist_com.h:32
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