PyPartMC 2.1.2__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. PyPartMC/_PyPartMC.pyd +0 -0
  2. PyPartMC/__generate_si.py +37 -0
  3. PyPartMC/__init__.py +78 -0
  4. PyPartMC/cmake/PyPartMCConfig.cmake +65 -0
  5. PyPartMC/include/PyPartMC/aero_binned.hpp +117 -0
  6. PyPartMC/include/PyPartMC/aero_data.hpp +283 -0
  7. PyPartMC/include/PyPartMC/aero_dist.hpp +85 -0
  8. PyPartMC/include/PyPartMC/aero_mode.hpp +359 -0
  9. PyPartMC/include/PyPartMC/aero_particle.hpp +275 -0
  10. PyPartMC/include/PyPartMC/aero_state.hpp +664 -0
  11. PyPartMC/include/PyPartMC/bin_grid.hpp +143 -0
  12. PyPartMC/include/PyPartMC/camp_core.hpp +31 -0
  13. PyPartMC/include/PyPartMC/condense.hpp +35 -0
  14. PyPartMC/include/PyPartMC/env_state.hpp +161 -0
  15. PyPartMC/include/PyPartMC/gas_data.hpp +105 -0
  16. PyPartMC/include/PyPartMC/gas_state.hpp +129 -0
  17. PyPartMC/include/PyPartMC/getters.hpp +55 -0
  18. PyPartMC/include/PyPartMC/input_guard.hpp +155 -0
  19. PyPartMC/include/PyPartMC/json_resource.hpp +363 -0
  20. PyPartMC/include/PyPartMC/output.hpp +96 -0
  21. PyPartMC/include/PyPartMC/photolysis.hpp +29 -0
  22. PyPartMC/include/PyPartMC/pmc_resource.hpp +42 -0
  23. PyPartMC/include/PyPartMC/rand.hpp +12 -0
  24. PyPartMC/include/PyPartMC/run_exact.hpp +34 -0
  25. PyPartMC/include/PyPartMC/run_exact_opt.hpp +46 -0
  26. PyPartMC/include/PyPartMC/run_part.hpp +110 -0
  27. PyPartMC/include/PyPartMC/run_part_opt.hpp +72 -0
  28. PyPartMC/include/PyPartMC/run_sect.hpp +34 -0
  29. PyPartMC/include/PyPartMC/run_sect_opt.hpp +54 -0
  30. PyPartMC/include/PyPartMC/scenario.hpp +220 -0
  31. PyPartMC/include/PyPartMC/si.hpp +118 -0
  32. PyPartMC/include/PyPartMC/util.hpp +22 -0
  33. PyPartMC/include/PyPartMC.hpp +28 -0
  34. PyPartMC/include/aero_data_parameters.hpp +27 -0
  35. PyPartMC/include/bpstd/detail/string_view.inl +925 -0
  36. PyPartMC/include/bpstd/string_view.hpp +498 -0
  37. PyPartMC/include/gas_data_parameters.hpp +14 -0
  38. PyPartMC/include/nanobind_json/nanobind_json.h +226 -0
  39. PyPartMC/include/nlohmann/adl_serializer.hpp +55 -0
  40. PyPartMC/include/nlohmann/byte_container_with_subtype.hpp +103 -0
  41. PyPartMC/include/nlohmann/detail/abi_macros.hpp +100 -0
  42. PyPartMC/include/nlohmann/detail/conversions/from_json.hpp +497 -0
  43. PyPartMC/include/nlohmann/detail/conversions/to_chars.hpp +1118 -0
  44. PyPartMC/include/nlohmann/detail/conversions/to_json.hpp +446 -0
  45. PyPartMC/include/nlohmann/detail/exceptions.hpp +257 -0
  46. PyPartMC/include/nlohmann/detail/hash.hpp +129 -0
  47. PyPartMC/include/nlohmann/detail/input/binary_reader.hpp +3009 -0
  48. PyPartMC/include/nlohmann/detail/input/input_adapters.hpp +492 -0
  49. PyPartMC/include/nlohmann/detail/input/json_sax.hpp +727 -0
  50. PyPartMC/include/nlohmann/detail/input/lexer.hpp +1633 -0
  51. PyPartMC/include/nlohmann/detail/input/parser.hpp +519 -0
  52. PyPartMC/include/nlohmann/detail/input/position_t.hpp +37 -0
  53. PyPartMC/include/nlohmann/detail/iterators/internal_iterator.hpp +35 -0
  54. PyPartMC/include/nlohmann/detail/iterators/iter_impl.hpp +751 -0
  55. PyPartMC/include/nlohmann/detail/iterators/iteration_proxy.hpp +242 -0
  56. PyPartMC/include/nlohmann/detail/iterators/iterator_traits.hpp +61 -0
  57. PyPartMC/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +130 -0
  58. PyPartMC/include/nlohmann/detail/iterators/primitive_iterator.hpp +132 -0
  59. PyPartMC/include/nlohmann/detail/json_custom_base_class.hpp +39 -0
  60. PyPartMC/include/nlohmann/detail/json_pointer.hpp +988 -0
  61. PyPartMC/include/nlohmann/detail/json_ref.hpp +78 -0
  62. PyPartMC/include/nlohmann/detail/macro_scope.hpp +482 -0
  63. PyPartMC/include/nlohmann/detail/macro_unscope.hpp +45 -0
  64. PyPartMC/include/nlohmann/detail/meta/call_std/begin.hpp +17 -0
  65. PyPartMC/include/nlohmann/detail/meta/call_std/end.hpp +17 -0
  66. PyPartMC/include/nlohmann/detail/meta/cpp_future.hpp +171 -0
  67. PyPartMC/include/nlohmann/detail/meta/detected.hpp +70 -0
  68. PyPartMC/include/nlohmann/detail/meta/identity_tag.hpp +21 -0
  69. PyPartMC/include/nlohmann/detail/meta/is_sax.hpp +159 -0
  70. PyPartMC/include/nlohmann/detail/meta/std_fs.hpp +29 -0
  71. PyPartMC/include/nlohmann/detail/meta/type_traits.hpp +795 -0
  72. PyPartMC/include/nlohmann/detail/meta/void_t.hpp +24 -0
  73. PyPartMC/include/nlohmann/detail/output/binary_writer.hpp +1838 -0
  74. PyPartMC/include/nlohmann/detail/output/output_adapters.hpp +147 -0
  75. PyPartMC/include/nlohmann/detail/output/serializer.hpp +988 -0
  76. PyPartMC/include/nlohmann/detail/string_concat.hpp +146 -0
  77. PyPartMC/include/nlohmann/detail/string_escape.hpp +72 -0
  78. PyPartMC/include/nlohmann/detail/value_t.hpp +118 -0
  79. PyPartMC/include/nlohmann/json.hpp +5258 -0
  80. PyPartMC/include/nlohmann/json_fwd.hpp +75 -0
  81. PyPartMC/include/nlohmann/ordered_map.hpp +359 -0
  82. PyPartMC/include/nlohmann/thirdparty/hedley/hedley.hpp +2045 -0
  83. PyPartMC/include/nlohmann/thirdparty/hedley/hedley_undef.hpp +158 -0
  84. PyPartMC/include/output_parameters.hpp +25 -0
  85. PyPartMC/include/tcb/span.hpp +617 -0
  86. PyPartMC/include/tl/optional.hpp +2062 -0
  87. PyPartMC/lib/libpartmclib.a +0 -0
  88. pypartmc-2.1.2.dist-info/METADATA +494 -0
  89. pypartmc-2.1.2.dist-info/RECORD +91 -0
  90. pypartmc-2.1.2.dist-info/WHEEL +5 -0
  91. pypartmc-2.1.2.dist-info/licenses/LICENSE +674 -0
@@ -0,0 +1,664 @@
1
+ /*##################################################################################################
2
+ # This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
3
+ # Copyright (C) 2022 University of Illinois Urbana-Champaign #
4
+ # Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
5
+ ##################################################################################################*/
6
+
7
+ #pragma once
8
+
9
+ #include "pmc_resource.hpp"
10
+ #include "aero_data.hpp"
11
+ #include "aero_dist.hpp"
12
+ #include "camp_core.hpp"
13
+ #include "aero_particle.hpp"
14
+ #include "env_state.hpp"
15
+ #include "bin_grid.hpp"
16
+ #include "tl/optional.hpp"
17
+ // #include <optional>
18
+ #include <vector>
19
+
20
+ extern "C" void f_aero_state_ctor(
21
+ void *ptr
22
+ ) noexcept;
23
+
24
+ extern "C" void f_aero_state_dtor(
25
+ void *ptr
26
+ ) noexcept;
27
+
28
+ extern "C" void f_aero_state_init(
29
+ const void *ptr,
30
+ const void *aero_dataptr,
31
+ const double *n_part,
32
+ const char *weight_c
33
+ ) noexcept;
34
+
35
+ extern "C" void f_aero_state_len(
36
+ const void *ptr, int *len
37
+ ) noexcept;
38
+
39
+ extern "C" void f_aero_state_total_num_conc(
40
+ const void *ptr,
41
+ const void *aero_dataptr,
42
+ double *total_num_conc
43
+ ) noexcept;
44
+
45
+ extern "C" void f_aero_state_total_mass_conc(
46
+ const void *ptr,
47
+ const void *aero_dataptr,
48
+ double *total_mass_conc
49
+ ) noexcept;
50
+
51
+ extern "C" void f_aero_state_frozen_fraction(
52
+ const void *ptr,
53
+ const void *aero_dataptr,
54
+ double *frozen_fraction
55
+ ) noexcept;
56
+
57
+ extern "C" void f_aero_state_num_concs(
58
+ const void *ptr,
59
+ const void *aero_dataptr,
60
+ double *num_concs,
61
+ const int *len
62
+ ) noexcept;
63
+
64
+ extern "C" void f_aero_state_masses(
65
+ const void *ptr,
66
+ const void *aero_dataptr,
67
+ double *masses,
68
+ const int *n_parts,
69
+ const int *include_size,
70
+ const int *exclude_size,
71
+ void *include,
72
+ void *exclude
73
+ ) noexcept;
74
+
75
+ extern "C" void f_aero_state_dry_diameters(
76
+ const void *ptr,
77
+ const void *aero_dataptr,
78
+ double *dry_diameters,
79
+ const int *n_parts
80
+ ) noexcept;
81
+
82
+ extern "C" void f_aero_state_mobility_diameters(
83
+ const void *ptr,
84
+ const void *aero_dataptr,
85
+ const void *env_stateptr,
86
+ double *mobility_diameters,
87
+ const int *n_parts
88
+ ) noexcept;
89
+
90
+ extern "C" void f_aero_state_diameters(
91
+ const void *ptr,
92
+ const void *aero_dataptr,
93
+ double *diameters,
94
+ const int *n_parts,
95
+ const int *include_size,
96
+ const int *exclude_size,
97
+ void *include,
98
+ void *exclude
99
+ ) noexcept;
100
+
101
+ extern "C" void f_aero_state_volumes(
102
+ const void *ptr,
103
+ const void *aero_dataptr,
104
+ double *volumes,
105
+ const int *n_parts,
106
+ const int *include_size,
107
+ const int *exclude_size,
108
+ void *include,
109
+ void *exclude
110
+ ) noexcept;
111
+
112
+ extern "C" void f_aero_state_crit_rel_humids(
113
+ const void *ptr,
114
+ const void *aero_dataptr,
115
+ const void *env_stateptr,
116
+ double *crit_rel_humids,
117
+ const int *n_parts
118
+ ) noexcept;
119
+
120
+ extern "C" void f_aero_state_make_dry(
121
+ void *ptr,
122
+ const void *aero_dataptr
123
+ ) noexcept;
124
+
125
+ extern "C" void f_aero_state_mixing_state_metrics(
126
+ const void *aero_state,
127
+ const void *aero_data,
128
+ double *d_alpha,
129
+ double *d_gamma,
130
+ double *chi,
131
+ const int *include_size,
132
+ const int *exclude_size,
133
+ const int *group_size,
134
+ void *include,
135
+ void *exclude,
136
+ void *group
137
+ ) noexcept;
138
+
139
+ extern "C" void f_aero_state_bin_average_comp(
140
+ const void *ptr_c,
141
+ const void *bin_grid_ptr,
142
+ const void *aero_data_ptr
143
+ ) noexcept;
144
+
145
+ extern "C" void f_aero_state_particle(
146
+ const void *ptr_c,
147
+ const void *ptr_particle_c,
148
+ const int *index
149
+ ) noexcept;
150
+
151
+ extern "C" void f_aero_state_rand_particle(
152
+ const void *ptr_c,
153
+ const void *ptr_particle_c
154
+ ) noexcept;
155
+
156
+ extern "C" void f_aero_state_add_aero_dist_sample(
157
+ const void *ptr_c,
158
+ const void *ptr_aero_data_c,
159
+ const void *ptr_aero_dist_c,
160
+ const double *sample_prop,
161
+ const double *create_time,
162
+ const bool *allow_doubling,
163
+ const bool *allow_halving,
164
+ int *n_part_add
165
+ ) noexcept;
166
+
167
+ extern "C" void f_aero_state_add_particle(
168
+ void *ptr_c,
169
+ const void *ptr_aero_data_c,
170
+ const void *ptr_aero_particle_c
171
+ ) noexcept;
172
+
173
+ extern "C" void f_aero_state_copy_weight(
174
+ const void *ptr_c,
175
+ void *ptr_aero_state_to_c
176
+ ) noexcept;
177
+
178
+ extern "C" void f_aero_state_remove_particle(
179
+ void *ptr_c,
180
+ const int *i_part
181
+ ) noexcept;
182
+
183
+ extern "C" void f_aero_state_zero(
184
+ void *ptr_c
185
+ ) noexcept;
186
+
187
+ extern "C" void f_aero_state_ids(
188
+ const void *ptr_c,
189
+ int64_t *ids,
190
+ const int *n_parts
191
+ ) noexcept;
192
+
193
+ extern "C" void f_aero_state_add(
194
+ void *ptr_c,
195
+ const void *delta_ptr_c,
196
+ const void *aero_data_ptr
197
+ ) noexcept;
198
+
199
+ extern "C" void f_aero_state_add_particles(
200
+ void *ptr_c,
201
+ const void *delta_ptr_c,
202
+ const void *aero_data_ptr
203
+ ) noexcept;
204
+
205
+ extern "C" void f_aero_state_sample(
206
+ void *ptr_c,
207
+ void *aero_state_to_ptr_c,
208
+ const void *aero_data_ptr,
209
+ const double *sample_prob
210
+ ) noexcept;
211
+
212
+ extern "C" void f_aero_state_sample_particles(
213
+ void *ptr_c,
214
+ void *aero_state_to_ptr_c,
215
+ const void *aero_data_ptr,
216
+ const double *sample_prob
217
+ ) noexcept;
218
+
219
+ extern "C" void f_aero_state_initialize(
220
+ void *ptr_c,
221
+ const void *aero_data_ptr_c,
222
+ const void *camp_core_ptr_c
223
+ ) noexcept;
224
+
225
+ template <typename arr_t, typename arg_t>
226
+ auto pointer_vec_magic(arr_t &data_vec, const arg_t &arg) {
227
+ std::vector<char*> pointer_vec(data_vec.size());
228
+ if (arg.has_value())
229
+ for (size_t i=0; i < arg.value().size(); ++i)
230
+ strcpy(
231
+ pointer_vec[i] = data_vec[i].data(),
232
+ arg.value()[i].c_str()
233
+ );
234
+ return pointer_vec;
235
+ }
236
+
237
+ // Retrieves an array from a Fortran routine with include/exclude species filters.
238
+ template <typename Func, typename LenF>
239
+ auto get_array_values_filtered(
240
+ const void *self_ptr,
241
+ const void *aero_data_ptr,
242
+ Func f,
243
+ LenF len_fn,
244
+ const tl::optional<std::vector<std::string>> &include,
245
+ const tl::optional<std::vector<std::string>> &exclude
246
+ ) {
247
+ int len;
248
+ len_fn(self_ptr, &len);
249
+ std::valarray<double> arr(len);
250
+
251
+ const int include_size = include.has_value() ? include.value().size() : 0;
252
+ const int exclude_size = exclude.has_value() ? exclude.value().size() : 0;
253
+
254
+ std::vector<std::array<char, AERO_NAME_LEN>>
255
+ include_arr(include_size),
256
+ exclude_arr(exclude_size);
257
+
258
+ f(self_ptr,
259
+ aero_data_ptr,
260
+ begin(arr),
261
+ &len,
262
+ &include_size,
263
+ &exclude_size,
264
+ pointer_vec_magic(include_arr, include).data(),
265
+ pointer_vec_magic(exclude_arr, exclude).data());
266
+
267
+ return arr;
268
+ }
269
+
270
+ static const std::map<bpstd::string_view, char> weight_c{
271
+ //{"none", '-'},
272
+ {"flat", 'f'},
273
+ {"flat_source", 'F'},
274
+ //{"power", 'p'},
275
+ //{"power_source", 'P'},
276
+ {"nummass", 'n'},
277
+ {"nummass_source", 'N'},
278
+ };
279
+
280
+ struct AeroState {
281
+ PMCResource ptr;
282
+ std::shared_ptr<AeroData> aero_data;
283
+ int allow_halving = -1, allow_doubling = -1;
284
+
285
+ const char* check_and_convert_weight(const bpstd::string_view &weight)
286
+ {
287
+ if (weight_c.find(weight) == weight_c.end()) {
288
+ std::ostringstream msg;
289
+ msg << "unknown weighting scheme '" << weight << "', valid options are: ";
290
+ auto index = 0;
291
+ for (auto const& pair: weight_c)
292
+ msg << (!index++ ? "" : ", ") << pair.first;
293
+ throw std::runtime_error(msg.str());
294
+ }
295
+ return &weight_c.at(weight);
296
+ }
297
+
298
+ AeroState(
299
+ std::shared_ptr<AeroData> aero_data,
300
+ const double &n_part,
301
+ const bpstd::string_view &weight
302
+ ):
303
+ ptr(f_aero_state_ctor, f_aero_state_dtor),
304
+ aero_data(aero_data)
305
+ {
306
+ f_aero_state_init(
307
+ ptr.f_arg(),
308
+ aero_data->ptr.f_arg(),
309
+ &n_part,
310
+ check_and_convert_weight(weight)
311
+ );
312
+ }
313
+
314
+ AeroState(
315
+ std::shared_ptr<AeroData> aero_data
316
+ ):
317
+ ptr(f_aero_state_ctor, f_aero_state_dtor),
318
+ aero_data(aero_data)
319
+ {
320
+ }
321
+
322
+ AeroState(
323
+ std::shared_ptr<AeroData> aero_data,
324
+ const double &n_part,
325
+ const bpstd::string_view &weight,
326
+ const CampCore &camp_core
327
+ ):
328
+ ptr(f_aero_state_ctor, f_aero_state_dtor),
329
+ aero_data(aero_data)
330
+ {
331
+ f_aero_state_init(
332
+ ptr.f_arg(),
333
+ aero_data->ptr.f_arg(),
334
+ &n_part,
335
+ check_and_convert_weight(weight)
336
+ );
337
+ f_aero_state_initialize(ptr.f_arg_non_const(), aero_data->ptr.f_arg(),
338
+ camp_core.ptr.f_arg());
339
+ }
340
+
341
+ static std::size_t __len__(const AeroState &self) {
342
+ int len;
343
+ f_aero_state_len(
344
+ self.ptr.f_arg(),
345
+ &len
346
+ );
347
+ return len;
348
+ }
349
+
350
+ static auto total_num_conc(const AeroState &self) {
351
+ double total_num_conc;
352
+ f_aero_state_total_num_conc(
353
+ self.ptr.f_arg(),
354
+ self.aero_data->ptr.f_arg(),
355
+ &total_num_conc
356
+ );
357
+ return total_num_conc;
358
+ }
359
+
360
+ static auto total_mass_conc(const AeroState &self) {
361
+ double total_mass_conc;
362
+ f_aero_state_total_mass_conc(
363
+ self.ptr.f_arg(),
364
+ self.aero_data->ptr.f_arg(),
365
+ &total_mass_conc
366
+ );
367
+ return total_mass_conc;
368
+ }
369
+
370
+ static auto num_concs(const AeroState &self) {
371
+ auto fn = f_aero_state_num_concs;
372
+ auto len_fn = f_aero_state_len;
373
+ auto aero_data_ptr = self.aero_data->ptr.f_arg();
374
+ return pypartmc::get_array_values(self, fn, len_fn, aero_data_ptr);
375
+ }
376
+
377
+ static auto masses(
378
+ const AeroState &self,
379
+ const tl::optional<std::vector<std::string>> &include,
380
+ const tl::optional<std::vector<std::string>> &exclude
381
+ ) {
382
+ return get_array_values_filtered(
383
+ self.ptr.f_arg(),
384
+ self.aero_data->ptr.f_arg(),
385
+ f_aero_state_masses,
386
+ f_aero_state_len,
387
+ include,
388
+ exclude
389
+ );
390
+ }
391
+
392
+ static auto frozen_fraction(const AeroState &self) {
393
+ double frozen_fraction;
394
+ f_aero_state_frozen_fraction(
395
+ self.ptr.f_arg(),
396
+ self.aero_data->ptr.f_arg(),
397
+ &frozen_fraction
398
+ );
399
+ return frozen_fraction;
400
+ }
401
+
402
+ static auto dry_diameters(const AeroState &self) {
403
+ auto fn = f_aero_state_dry_diameters;
404
+ auto len_fn = f_aero_state_len;
405
+ auto aero_data_ptr = self.aero_data->ptr.f_arg();
406
+ return pypartmc::get_array_values(self, fn, len_fn, aero_data_ptr);
407
+ }
408
+
409
+ static auto mobility_diameters(const AeroState &self, const EnvState &env_state) {
410
+ auto fn = f_aero_state_mobility_diameters;
411
+ auto len_fn = f_aero_state_len;
412
+ auto aero_data_ptr = self.aero_data->ptr.f_arg();
413
+ auto env_state_ptr = env_state.ptr.f_arg();
414
+ return pypartmc::get_array_values(self, fn, len_fn, aero_data_ptr, env_state_ptr);
415
+ }
416
+
417
+ static auto diameters(
418
+ const AeroState &self,
419
+ const tl::optional<std::vector<std::string>> &include,
420
+ const tl::optional<std::vector<std::string>> &exclude
421
+ ) {
422
+ return get_array_values_filtered(
423
+ self.ptr.f_arg(),
424
+ self.aero_data->ptr.f_arg(),
425
+ f_aero_state_diameters,
426
+ f_aero_state_len,
427
+ include,
428
+ exclude
429
+ );
430
+ }
431
+
432
+ static auto volumes(
433
+ const AeroState &self,
434
+ const tl::optional<std::vector<std::string>> &include,
435
+ const tl::optional<std::vector<std::string>> &exclude
436
+ ) {
437
+ return get_array_values_filtered(
438
+ self.ptr.f_arg(),
439
+ self.aero_data->ptr.f_arg(),
440
+ f_aero_state_volumes,
441
+ f_aero_state_len,
442
+ include,
443
+ exclude
444
+ );
445
+ }
446
+
447
+ static auto crit_rel_humids(
448
+ const AeroState &self,
449
+ const EnvState &env_state
450
+ ) {
451
+ auto fn = f_aero_state_crit_rel_humids;
452
+ auto len_fn = f_aero_state_len;
453
+ auto aero_data_ptr = self.aero_data->ptr.f_arg();
454
+ auto env_state_ptr = env_state.ptr.f_arg();
455
+ return pypartmc::get_array_values(self, fn, len_fn, aero_data_ptr, env_state_ptr);
456
+ }
457
+
458
+ static void make_dry(
459
+ AeroState &self
460
+ ) {
461
+ f_aero_state_make_dry(
462
+ self.ptr.f_arg_non_const(),
463
+ self.aero_data->ptr.f_arg()
464
+ );
465
+ }
466
+
467
+ static auto ids(const AeroState &self) {
468
+ auto fn = f_aero_state_ids;
469
+ auto len_fn = f_aero_state_len;
470
+ return pypartmc::get_array_values<int64_t>(self, fn, len_fn);
471
+ }
472
+
473
+ static auto mixing_state(
474
+ const AeroState &self,
475
+ const tl::optional<std::vector<std::string>> &include,
476
+ const tl::optional<std::vector<std::string>> &exclude,
477
+ const tl::optional<std::vector<std::string>> &group
478
+ ) {
479
+ int len;
480
+ f_aero_state_len(
481
+ self.ptr.f_arg(),
482
+ &len
483
+ );
484
+ double chi;
485
+ double d_alpha;
486
+ double d_gamma;
487
+
488
+ const int include_size = (include.has_value()) ? include.value().size() : 0;
489
+ const int exclude_size = (exclude.has_value()) ? exclude.value().size() : 0;
490
+ const int group_size = (group.has_value()) ? group.value().size() : 0;
491
+
492
+ std::vector<std::array<char, AERO_NAME_LEN>>
493
+ include_arr(include_size),
494
+ exclude_arr(exclude_size),
495
+ group_arr(group_size);
496
+
497
+ f_aero_state_mixing_state_metrics(
498
+ self.ptr.f_arg(),
499
+ self.aero_data->ptr.f_arg(),
500
+ &d_alpha,
501
+ &d_gamma,
502
+ &chi,
503
+ &include_size,
504
+ &exclude_size,
505
+ &group_size,
506
+ pointer_vec_magic(include_arr, include).data(),
507
+ pointer_vec_magic(exclude_arr, exclude).data(),
508
+ pointer_vec_magic(group_arr, group).data()
509
+ );
510
+
511
+ return std::make_tuple(d_alpha, d_gamma, chi);
512
+ }
513
+
514
+ static void bin_average_comp(
515
+ AeroState &self,
516
+ const BinGrid &bin_grid
517
+ ) {
518
+ f_aero_state_bin_average_comp(
519
+ self.ptr.f_arg(),
520
+ bin_grid.ptr.f_arg(),
521
+ self.aero_data->ptr.f_arg()
522
+ );
523
+ }
524
+
525
+ static AeroParticle* get_particle(
526
+ const AeroState &self,
527
+ const int &idx
528
+ ) {
529
+ if (idx < 0 || idx >= (int)__len__(self))
530
+ throw std::out_of_range("Index out of range");
531
+
532
+ int len = AeroData::__len__(*self.aero_data);
533
+ std::valarray<double> data(len);
534
+
535
+ AeroParticle *ptr = new AeroParticle(self.aero_data, data);
536
+ f_aero_state_particle(self.ptr.f_arg(), ptr, &idx);
537
+
538
+ return ptr;
539
+ }
540
+
541
+ static AeroParticle* get_random_particle(
542
+ const AeroState &self
543
+ ) {
544
+ int len = AeroData::__len__(*self.aero_data);
545
+ std::valarray<double> data(len);
546
+
547
+ AeroParticle *ptr = new AeroParticle(self.aero_data, data);
548
+ f_aero_state_rand_particle(self.ptr.f_arg(), ptr);
549
+
550
+ return ptr;
551
+ }
552
+
553
+ static int dist_sample(
554
+ AeroState &self,
555
+ const AeroDist &aero_dist,
556
+ const double &sample_prop,
557
+ const double &create_time,
558
+ const bool &allow_doubling,
559
+ const bool &allow_halving
560
+ ) {
561
+ int n_part_add = 0;
562
+
563
+ if (
564
+ (self.allow_doubling != -1 && self.allow_doubling != allow_doubling) ||
565
+ (self.allow_halving != -1 && self.allow_halving != allow_halving)
566
+ )
567
+ throw std::runtime_error("dist_sample() called with different halving/doubling settings then in last call");
568
+
569
+ self.allow_doubling = allow_doubling;
570
+ self.allow_halving = allow_halving;
571
+
572
+ f_aero_state_add_aero_dist_sample(
573
+ self.ptr.f_arg(),
574
+ self.aero_data->ptr.f_arg(),
575
+ aero_dist.ptr.f_arg(),
576
+ &sample_prop,
577
+ &create_time,
578
+ &allow_doubling,
579
+ &allow_halving,
580
+ &n_part_add
581
+ );
582
+ return n_part_add;
583
+ }
584
+
585
+ static void add_particle(
586
+ AeroState &self,
587
+ const AeroParticle &particle
588
+ ) {
589
+
590
+ f_aero_state_add_particle(self.ptr.f_arg_non_const(),
591
+ self.aero_data->ptr.f_arg(),
592
+ particle.ptr.f_arg()
593
+ );
594
+
595
+ }
596
+
597
+ static void copy_weight(
598
+ AeroState &self,
599
+ const AeroState &aero_state_from
600
+ ) {
601
+
602
+ f_aero_state_copy_weight(aero_state_from.ptr.f_arg(),
603
+ self.ptr.f_arg_non_const()
604
+ );
605
+ }
606
+
607
+ static void remove_particle(
608
+ AeroState &self,
609
+ const int &i_part
610
+ ) {
611
+ f_aero_state_remove_particle(self.ptr.f_arg_non_const(), &i_part);
612
+ }
613
+
614
+ static void zero(
615
+ AeroState &self
616
+ ) {
617
+ f_aero_state_zero(self.ptr.f_arg_non_const());
618
+ }
619
+
620
+ static void add(
621
+ AeroState &self,
622
+ const AeroState &delta
623
+ ) {
624
+ f_aero_state_add(self.ptr.f_arg_non_const(),
625
+ delta.ptr.f_arg(),
626
+ self.aero_data->ptr.f_arg()
627
+ );
628
+ }
629
+
630
+ static void add_particles(
631
+ AeroState &self,
632
+ const AeroState &delta
633
+ ) {
634
+ f_aero_state_add_particles(self.ptr.f_arg_non_const(),
635
+ delta.ptr.f_arg(),
636
+ self.aero_data->ptr.f_arg()
637
+ );
638
+ }
639
+
640
+ static void sample(
641
+ AeroState &self,
642
+ AeroState &aero_state_sample,
643
+ const double sample_prob
644
+ ) {
645
+ f_aero_state_sample(self.ptr.f_arg_non_const(),
646
+ aero_state_sample.ptr.f_arg_non_const(),
647
+ self.aero_data->ptr.f_arg(),
648
+ &sample_prob
649
+ );
650
+ }
651
+
652
+ static void sample_particles(
653
+ AeroState &self,
654
+ AeroState &aero_state_sample,
655
+ const double sample_prob
656
+ ) {
657
+ f_aero_state_sample_particles(self.ptr.f_arg_non_const(),
658
+ aero_state_sample.ptr.f_arg_non_const(),
659
+ self.aero_data->ptr.f_arg(),
660
+ &sample_prob
661
+ );
662
+ }
663
+
664
+ };