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,359 @@
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 "bin_grid.hpp"
12
+ #include "getters.hpp"
13
+
14
+ extern "C" void f_aero_mode_ctor(
15
+ void *ptr
16
+ ) noexcept;
17
+
18
+ extern "C" void f_aero_mode_dtor(
19
+ void *ptr
20
+ ) noexcept;
21
+
22
+ extern "C" void f_aero_mode_get_num_conc(
23
+ const void *ptr,
24
+ double *val
25
+ ) noexcept;
26
+
27
+ extern "C" void f_aero_mode_set_num_conc(
28
+ void *ptr,
29
+ const double *val
30
+ ) noexcept;
31
+
32
+ extern "C" void f_aero_mode_num_conc(
33
+ const void *ptr,
34
+ const void *bin_grid_ptr,
35
+ const void *aero_data_ptr_c,
36
+ void *arr_data,
37
+ const int *arr_size
38
+ ) noexcept;
39
+
40
+ extern "C" void f_aero_mode_get_n_spec(
41
+ const void *ptr,
42
+ int *len
43
+ ) noexcept;
44
+
45
+ extern "C" void f_aero_mode_get_vol_frac(
46
+ const void *ptr,
47
+ void *arr_data,
48
+ const int *arr_size
49
+ ) noexcept;
50
+
51
+ extern "C" void f_aero_mode_set_vol_frac(
52
+ void *ptr,
53
+ const void *arr_data,
54
+ const int *arr_size
55
+ ) noexcept;
56
+
57
+ extern "C" void f_aero_mode_get_vol_frac_std(
58
+ const void *ptr,
59
+ void *arr_data,
60
+ const int *arr_size
61
+ ) noexcept;
62
+
63
+ extern "C" void f_aero_mode_set_vol_frac_std(
64
+ void *ptr,
65
+ const void *arr_data,
66
+ const int *arr_size
67
+ ) noexcept;
68
+
69
+ extern "C" void f_aero_mode_get_char_radius(
70
+ const void *ptr,
71
+ double *val
72
+ ) noexcept;
73
+
74
+ extern "C" void f_aero_mode_set_char_radius(
75
+ void *ptr,
76
+ const double *val
77
+ ) noexcept;
78
+
79
+ extern "C" void f_aero_mode_get_gsd(
80
+ const void *ptr,
81
+ double *val
82
+ ) noexcept;
83
+
84
+ extern "C" void f_aero_mode_set_gsd(
85
+ void *ptr,
86
+ const double *val
87
+ ) noexcept;
88
+
89
+ extern "C" void f_aero_mode_set_type(
90
+ void *ptr,
91
+ const int *val
92
+ ) noexcept;
93
+
94
+ extern "C" void f_aero_mode_get_type(
95
+ const void *ptr,
96
+ int *val
97
+ ) noexcept;
98
+
99
+ extern "C" void f_aero_mode_set_name(
100
+ void *ptr,
101
+ const char *name_data, const int *name_size
102
+ ) noexcept;
103
+
104
+ extern "C" void f_aero_mode_get_name(
105
+ const void *ptr,
106
+ char **name_data, int *name_size
107
+ ) noexcept;
108
+
109
+ extern "C" void f_aero_mode_set_sampled(
110
+ void *ptr,
111
+ const void *rad_data,
112
+ const void *num_conc_data,
113
+ const int *arr_size
114
+ ) noexcept;
115
+
116
+ extern "C" void f_aero_mode_from_json(
117
+ void *ptr,
118
+ void *aero_data_ptr
119
+ ) noexcept;
120
+
121
+ extern "C" void f_aero_mode_get_sample_num_conc(
122
+ const void *ptr,
123
+ void *sample_num_conc_data,
124
+ const int *sample_num_conc_data_size
125
+ ) noexcept;
126
+
127
+ extern "C" void f_aero_mode_get_sample_radius(
128
+ const void *ptr,
129
+ void *sample_radius_data,
130
+ const int *sample_radius_data_size
131
+ ) noexcept;
132
+
133
+ extern "C" void f_aero_mode_get_sample_bins(const void *ptr, int *n_bins) noexcept;
134
+
135
+ struct AeroMode {
136
+ PMCResource ptr;
137
+
138
+ AeroMode() :
139
+ ptr(f_aero_mode_ctor, f_aero_mode_dtor)
140
+ {}
141
+
142
+ AeroMode(AeroData &aero_data, const nlohmann::ordered_json &json) :
143
+ ptr(f_aero_mode_ctor, f_aero_mode_dtor)
144
+ {
145
+ if (json.size() != 1 || !json.is_object() || !json.begin().value().is_object())
146
+ throw std::runtime_error("Single-element dict expected with mode name as key and mode params dict as value");
147
+ check_mode_json(json.begin().value());
148
+ JSONResourceGuard<InputJSONResource> guard(json, "", "mode_name");
149
+ f_aero_mode_from_json(ptr.f_arg_non_const(), aero_data.ptr.f_arg_non_const());
150
+ guard.check_parameters();
151
+ }
152
+
153
+ static void check_mode_json(const nlohmann::ordered_json &mode) {
154
+ for (auto key : std::set<std::string>({"mass_frac", "mode_type"})) // TODO #320: more...
155
+ if (mode.find(key) == mode.end())
156
+ throw std::runtime_error("mode parameters dict must include key '" + key + "'");
157
+ auto mass_frac = mode["mass_frac"];
158
+
159
+ if (!mass_frac.is_array()) // TODO #320: check if all are single-element dicts
160
+ throw std::runtime_error("mass_frac value must be a list of single-element dicts");
161
+ if (!InputJSONResource::unique_keys(mass_frac))
162
+ throw std::runtime_error("mass_frac keys must be unique");
163
+ if (mode["mode_type"] == "sampled") {
164
+ if (mode.find("size_dist") == mode.end())
165
+ throw std::runtime_error("size_dist key must be set for mode_type=sampled");
166
+ auto sd = mode["size_dist"];
167
+ if (
168
+ sd.size() != 2 ||
169
+ !sd[0].is_object() ||
170
+ sd[0].size() != 1 ||
171
+ sd[1].size() != 1 ||
172
+ sd[0].find("diam") == sd[0].end() ||
173
+ sd[1].find("num_conc") == sd[1].end()
174
+ )
175
+ throw std::runtime_error("size_dist value must be an iterable of two single-element dicts (first with 'diam', second with 'num_conc' as keys)");
176
+ auto diam = *sd[0].find("diam");
177
+ auto num_conc = *sd[1].find("num_conc");
178
+ if (diam.size() != num_conc.size() + 1)
179
+ throw std::runtime_error("size_dist['num_conc'] must have len(size_dist['diam'])-1 elements");
180
+ }
181
+ }
182
+
183
+ static auto get_num_conc(const AeroMode &self){
184
+ double val;
185
+ f_aero_mode_get_num_conc(self.ptr.f_arg(), &val);
186
+ return val;
187
+ }
188
+
189
+ static void set_num_conc(AeroMode &self, const double &val){
190
+ f_aero_mode_set_num_conc(self.ptr.f_arg_non_const(), &val);
191
+ }
192
+
193
+ static auto num_dist(const AeroMode &self,
194
+ const BinGrid &bin_grid, const AeroData &aero_data)
195
+ {
196
+ int len;
197
+ f_bin_grid_size(bin_grid.ptr.f_arg(), &len);
198
+ std::valarray<double> data(len);
199
+
200
+ f_aero_mode_num_conc(
201
+ self.ptr.f_arg(),
202
+ bin_grid.ptr.f_arg(),
203
+ aero_data.ptr.f_arg(),
204
+ begin(data),
205
+ &len
206
+ );
207
+
208
+ return data;
209
+ }
210
+
211
+ static void set_vol_frac(AeroMode &self, const std::valarray<double>&data)
212
+ {
213
+ int len = data.size();
214
+ int n_spec;
215
+ f_aero_mode_get_n_spec(self.ptr.f_arg(), &n_spec);
216
+ if (len!=n_spec)
217
+ throw std::runtime_error("AeroData size mismatch");
218
+ f_aero_mode_set_vol_frac(
219
+ self.ptr.f_arg_non_const(),
220
+ begin(data),
221
+ &len
222
+ );
223
+ }
224
+
225
+ static auto get_vol_frac(const AeroMode &self)
226
+ {
227
+ auto fn = f_aero_mode_get_vol_frac;
228
+ auto len_fn = f_aero_mode_get_n_spec;
229
+ return pypartmc::get_array_values(self, fn, len_fn);
230
+ }
231
+
232
+ static void set_vol_frac_std(AeroMode &self, const std::valarray<double>&data)
233
+ {
234
+ int len = data.size();
235
+ int n_spec;
236
+ f_aero_mode_get_n_spec(self.ptr.f_arg(), &n_spec);
237
+ if (len!=n_spec)
238
+ throw std::runtime_error("AeroData size mismatch");
239
+ f_aero_mode_set_vol_frac_std(
240
+ self.ptr.f_arg_non_const(),
241
+ begin(data),
242
+ &len
243
+ );
244
+ }
245
+
246
+ static auto get_vol_frac_std(const AeroMode &self)
247
+ {
248
+ auto fn = f_aero_mode_get_vol_frac_std;
249
+ auto len_fn = f_aero_mode_get_n_spec;
250
+ return pypartmc::get_array_values(self, fn, len_fn);
251
+ }
252
+
253
+ static auto get_char_radius(const AeroMode &self){
254
+ return pypartmc::get_value(self, f_aero_mode_get_char_radius);
255
+ }
256
+
257
+ static void set_char_radius(AeroMode &self, const double &val){
258
+ f_aero_mode_set_char_radius(self.ptr.f_arg_non_const(), &val);
259
+ }
260
+
261
+ static auto get_gsd(const AeroMode &self){
262
+ return pypartmc::get_value(self, f_aero_mode_get_gsd);
263
+ }
264
+
265
+ static void set_gsd(AeroMode &self, const double &val) {
266
+ f_aero_mode_set_gsd(self.ptr.f_arg_non_const(), &val);
267
+ }
268
+
269
+ static void set_sampled(AeroMode &self, const std::valarray<double>&sample_diams,
270
+ const std::valarray<double>&sample_num_conc) {
271
+
272
+ int len = sample_diams.size();
273
+ {
274
+ int len_num_conc = sample_num_conc.size();
275
+ if (len != len_num_conc + 1)
276
+ throw std::runtime_error("Diameter and number size mismatch");
277
+ }
278
+
279
+ f_aero_mode_set_sampled(
280
+ self.ptr.f_arg_non_const(),
281
+ begin(sample_diams),
282
+ begin(sample_num_conc),
283
+ &len
284
+ );
285
+ }
286
+
287
+ static auto types() {
288
+ static auto vec = std::vector<std::string>{
289
+ "log_normal",
290
+ "exp",
291
+ "mono",
292
+ "sampled"
293
+ };
294
+ return vec;
295
+ };
296
+
297
+ static void set_type(AeroMode &self, const std::string &mode_type) {
298
+ auto found = false;
299
+ auto type = 0;
300
+
301
+ for (auto el : AeroMode::types()) {
302
+ ++type;
303
+ if (el == mode_type) {
304
+ found = true;
305
+ break;
306
+ }
307
+ }
308
+
309
+ if (!found)
310
+ throw std::invalid_argument("Invalid mode type.");
311
+
312
+ f_aero_mode_set_type(self.ptr.f_arg_non_const(), &type);
313
+ }
314
+
315
+ static auto get_type(const AeroMode &self) {
316
+ int type;
317
+ f_aero_mode_get_type(self.ptr.f_arg(), &type);
318
+
319
+ if (type <= 0 || (unsigned int)type > AeroMode::types().size())
320
+ throw std::logic_error("Unknown mode type.");
321
+
322
+ return AeroMode::types()[type - 1];
323
+ }
324
+
325
+ static void set_name(AeroMode &self, const std::string &name) {
326
+ int size = name.size();
327
+ f_aero_mode_set_name(self.ptr.f_arg_non_const(), name.c_str(), &size);
328
+ }
329
+
330
+ static auto get_name(const AeroMode &self) {
331
+ std::string name;
332
+ char* f_ptr = NULL;
333
+ int size = 0;
334
+ f_aero_mode_get_name(self.ptr.f_arg(), &f_ptr, &size);
335
+ name.resize(size);
336
+ for (int i = 0; i < size; ++i)
337
+ name[i] = f_ptr[i];
338
+ return name;
339
+ }
340
+
341
+ static auto get_sample_radius(const AeroMode &self) {
342
+ int len;
343
+ f_aero_mode_get_sample_bins(self.ptr.f_arg(), &len);
344
+ len++;
345
+ std::valarray<double> sample_radius(len);
346
+ f_aero_mode_get_sample_radius(
347
+ self.ptr.f_arg(),
348
+ begin(sample_radius),
349
+ &len
350
+ );
351
+ return sample_radius;
352
+ }
353
+
354
+ static auto get_sample_num_conc(const AeroMode &self) {
355
+ auto fn = f_aero_mode_get_sample_num_conc;
356
+ auto len_fn = f_aero_mode_get_sample_bins;
357
+ return pypartmc::get_array_values(self, fn, len_fn);
358
+ }
359
+ };
@@ -0,0 +1,275 @@
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 "env_state.hpp"
12
+ #include <complex>
13
+
14
+ extern "C" void f_aero_particle_ctor(void *ptr) noexcept;
15
+ extern "C" void f_aero_particle_dtor(void *ptr) noexcept;
16
+ extern "C" void f_aero_particle_init(const void *ptr, const void *, const void *arr_data, const int *arr_size) noexcept;
17
+ extern "C" void f_aero_particle_volumes(const void *ptr, void *arr_data, const int *arr_size) noexcept;
18
+ extern "C" void f_aero_particle_volume(const void *ptr, double *vol) noexcept;
19
+ extern "C" void f_aero_particle_species_volume(const void *ptr, const int *i_spec, double *vol) noexcept;
20
+ extern "C" void f_aero_particle_dry_volume(const void *aero_particle_ptr, const void *aero_data_ptr, double *vol) noexcept;
21
+ extern "C" void f_aero_particle_radius(const void *aero_particle_ptr, const void *aero_data_ptr, double *radius) noexcept;
22
+ extern "C" void f_aero_particle_dry_radius(const void *aero_particle_ptr, const void *aero_data_ptr, double *radius) noexcept;
23
+ extern "C" void f_aero_particle_diameter(const void *aero_particle_ptr, const void *aero_data_ptr, double *diameter) noexcept;
24
+ extern "C" void f_aero_particle_dry_diameter(const void *aero_particle_ptr, const void * aero_data_ptr, double *diameter) noexcept;
25
+ extern "C" void f_aero_particle_mass(const void *aero_particle_ptr, const void *aero_data_ptr, double *mass) noexcept;
26
+ extern "C" void f_aero_particle_species_mass(const void *aero_particle_ptr, const int *i_spec, const void *aero_data_ptr, double *mass) noexcept;
27
+ extern "C" void f_aero_particle_species_masses(const void *aero_particle_ptr, const void *aero_data_ptr, void *masses, const int *size_masses) noexcept;
28
+ extern "C" void f_aero_particle_solute_kappa(const void *aero_particle_ptr, const void *aero_data_ptr, void *kappa) noexcept;
29
+ extern "C" void f_aero_particle_moles(const void *aero_particle_ptr, const void *aero_data_ptr, void *moles) noexcept;
30
+ extern "C" void f_aero_particle_mobility_diameter(const void *aero_particle_ptr, const void *aero_data_ptr, const void *env_state_ptr, void *mobility_diameter) noexcept;
31
+ extern "C" void f_aero_particle_density(const void *aero_particle_ptr, const void *aero_data_ptr, void *density) noexcept;
32
+ extern "C" void f_aero_particle_approx_crit_rel_humid(const void *aero_particle_ptr, const void *aero_data_ptr, const void *env_state_ptr, void *approx_crit_rel_humid) noexcept;
33
+ extern "C" void f_aero_particle_crit_rel_humid(const void *aero_particle_ptr, const void *aero_data_ptr, const void *env_state_ptr, void *crit_rel_humid) noexcept;
34
+ extern "C" void f_aero_particle_crit_diameter(const void *aero_particle_ptr, const void *aero_data_ptr, const void *env_state, void *crit_diameter) noexcept;
35
+ extern "C" void f_aero_particle_coagulate(const void *aero_particle_1_ptr, const void *aero_particle_2_ptr, void *new_particle_ptr, const void *aero_data_ptr) noexcept;
36
+ extern "C" void f_aero_particle_zero(void *aero_particle_ptr, const void *aero_data_ptr) noexcept;
37
+ extern "C" void f_aero_particle_set_vols(void *aero_particle_ptr, const int *vol_size, const void *volumes) noexcept;
38
+ extern "C" void f_aero_particle_absorb_cross_sect(const void *aero_particle_ptr, double *val, const int *arr_size) noexcept;
39
+ extern "C" void f_aero_particle_scatter_cross_sect(const void *aero_particle_ptr, double *val, const int *arr_size) noexcept;
40
+ extern "C" void f_aero_particle_asymmetry(const void *aero_particle_ptr, double *val, const int *arr_size) noexcept;
41
+ extern "C" void f_aero_particle_greatest_create_time(const void *aero_particle_ptr, double *val) noexcept;
42
+ extern "C" void f_aero_particle_least_create_time(const void *aero_particle_ptr, double *val) noexcept;
43
+ extern "C" void f_aero_particle_get_component_sources(const void *aero_particle_ptr, void *arr_data, const int *arr_size) noexcept;
44
+ extern "C" void f_aero_particle_id(const void *aero_particle_ptr, int64_t *val) noexcept;
45
+ extern "C" void f_aero_particle_frozen(const void *aero_particle_ptr, bool *val) noexcept;
46
+ extern "C" void f_aero_particle_refract_shell(const void *aero_particle_ptr, std::complex<double> *val, const int *arr_size) noexcept;
47
+ extern "C" void f_aero_particle_refract_core(const void *aero_particle_ptr, std::complex<double> *val, const int *arr_size) noexcept;
48
+ extern "C" void f_aero_particle_set_weight_class(void *ptr, const int *weight_class) noexcept;
49
+ extern "C" void f_aero_particle_get_weight_class(const void *ptr, int *weight_class) noexcept;
50
+ extern "C" void f_aero_particle_set_weight_group(void *ptr, const int *weight_group) noexcept;
51
+ extern "C" void f_aero_particle_get_weight_group(const void *ptr, int *weight_group) noexcept;
52
+ extern "C" void f_aero_particle_new_id(void *ptr) noexcept;
53
+
54
+ struct AeroParticle {
55
+ PMCResource ptr;
56
+ std::shared_ptr<AeroData> aero_data;
57
+
58
+ AeroParticle(
59
+ std::shared_ptr<AeroData> aero_data,
60
+ const std::valarray<double>&data
61
+ ) :
62
+ ptr(f_aero_particle_ctor, f_aero_particle_dtor),
63
+ aero_data(aero_data)
64
+ {
65
+ int len = data.size();
66
+ f_aero_particle_init(ptr.f_arg(), aero_data->ptr.f_arg(), begin(data), &len);
67
+ if (size_t(len) != AeroData::__len__(*aero_data))
68
+ throw std::runtime_error("AeroData size mistmatch");
69
+ }
70
+
71
+ static auto volumes(const AeroParticle &self)
72
+ {
73
+ int len = AeroData::__len__(*self.aero_data);
74
+ auto fn = f_aero_particle_volumes;
75
+ return pypartmc::get_array_values_set_len(self, fn, len);
76
+ }
77
+
78
+ static auto volume(const AeroParticle &self) {
79
+ return pypartmc::get_value<double>(self, f_aero_particle_volume);
80
+ }
81
+
82
+ static auto species_volume(const AeroParticle &self, const int &i_spec) {
83
+ auto fn = f_aero_particle_species_volume;
84
+ return pypartmc::get_derived_value(self, fn, &i_spec);
85
+ }
86
+
87
+ static auto species_volume_by_name(const AeroParticle &self, const std::string &name) {
88
+ const int i_spec = AeroData::spec_by_name(*self.aero_data, name);
89
+ auto fn = f_aero_particle_species_volume;
90
+ return pypartmc::get_derived_value(self, fn, &i_spec);
91
+ }
92
+
93
+ static auto dry_volume(const AeroParticle &self) {
94
+ return pypartmc::get_derived_value(self, f_aero_particle_dry_volume, self.aero_data.get());
95
+ }
96
+
97
+ static auto radius(const AeroParticle &self) {
98
+ return pypartmc::get_derived_value(self, f_aero_particle_radius, self.aero_data.get());
99
+ }
100
+
101
+ static auto dry_radius(const AeroParticle &self) {
102
+ return pypartmc::get_derived_value(self, f_aero_particle_dry_radius, self.aero_data.get());
103
+ }
104
+
105
+ static auto diameter(const AeroParticle &self) {
106
+ return pypartmc::get_derived_value(self, f_aero_particle_diameter, self.aero_data.get());
107
+ }
108
+
109
+ static auto dry_diameter(const AeroParticle &self) {
110
+ return pypartmc::get_derived_value(self, f_aero_particle_dry_diameter, self.aero_data.get());
111
+ }
112
+
113
+ static auto mass(const AeroParticle &self) {
114
+ return pypartmc::get_derived_value(self, f_aero_particle_mass, self.aero_data.get());
115
+ }
116
+
117
+ static auto species_mass(const AeroParticle &self, const int &i_spec) {
118
+ auto fn = f_aero_particle_species_mass;
119
+ return pypartmc::get_derived_value(self, fn, &i_spec, self.aero_data.get());
120
+ }
121
+
122
+ static auto species_mass_by_name(const AeroParticle &self, const std::string &name) {
123
+ auto fn = f_aero_particle_species_mass;
124
+ int i_spec = AeroData::spec_by_name(*self.aero_data, name);
125
+ return pypartmc::get_derived_value(self, fn, &i_spec, self.aero_data.get());
126
+ }
127
+
128
+ static auto species_masses(const AeroParticle &self) {
129
+ int len = AeroData::__len__(*self.aero_data);
130
+ auto fn = f_aero_particle_species_masses;
131
+ return pypartmc::get_array_values_set_len(self, fn, len, self.aero_data.get());
132
+ }
133
+
134
+ static auto solute_kappa(const AeroParticle &self) {
135
+ return pypartmc::get_derived_value(self, f_aero_particle_solute_kappa, self.aero_data.get());
136
+ }
137
+
138
+ static auto moles(const AeroParticle &self) {
139
+ return pypartmc::get_derived_value(self, f_aero_particle_moles, self.aero_data.get());
140
+ }
141
+
142
+ static auto mobility_diameter(const AeroParticle &self, const EnvState &env_state) {
143
+ return pypartmc::get_derived_value(
144
+ self,
145
+ f_aero_particle_mobility_diameter,
146
+ self.aero_data.get(),
147
+ env_state.ptr.f_arg());
148
+ }
149
+
150
+ static auto density(const AeroParticle &self) {
151
+ return pypartmc::get_derived_value(self, f_aero_particle_density, self.aero_data.get());
152
+ }
153
+
154
+ static auto approx_crit_rel_humid(const AeroParticle &self, const EnvState &env_state) {
155
+ return pypartmc::get_derived_value(
156
+ self,
157
+ f_aero_particle_approx_crit_rel_humid,
158
+ self.aero_data.get(),
159
+ env_state.ptr.f_arg());
160
+ }
161
+
162
+ static auto crit_rel_humid(const AeroParticle &self, const EnvState &env_state) {
163
+ return pypartmc::get_derived_value(
164
+ self,
165
+ f_aero_particle_crit_rel_humid,
166
+ self.aero_data.get(),
167
+ env_state.ptr.f_arg());
168
+ }
169
+
170
+ static auto crit_diameter(const AeroParticle &self, const EnvState &env_state) {
171
+ return pypartmc::get_derived_value(
172
+ self,
173
+ f_aero_particle_crit_diameter,
174
+ self.aero_data.get(),
175
+ env_state.ptr.f_arg());
176
+ }
177
+
178
+ static auto coagulate(const AeroParticle &self, const AeroParticle &two) {
179
+ int len = AeroData::__len__(*self.aero_data);
180
+ std::valarray<double> data(len);
181
+ AeroParticle* new_ptr = new AeroParticle(self.aero_data, data);
182
+ f_aero_particle_coagulate(
183
+ self.ptr.f_arg(),
184
+ two.ptr.f_arg(),
185
+ new_ptr,
186
+ self.aero_data->ptr.f_arg()
187
+ );
188
+ return new_ptr;
189
+ }
190
+
191
+ static void zero(AeroParticle &self) {
192
+ f_aero_particle_zero(
193
+ self.ptr.f_arg_non_const(),
194
+ self.aero_data.get()
195
+ );
196
+ }
197
+
198
+ static void set_vols(AeroParticle &self, const std::valarray<double>&volumes) {
199
+ int len = AeroData::__len__(*self.aero_data.get());
200
+ if (volumes.size() != size_t(len))
201
+ throw std::runtime_error("AeroData size mistmatch");
202
+ f_aero_particle_set_vols(
203
+ self.ptr.f_arg_non_const(),
204
+ &len,
205
+ begin(volumes)
206
+ );
207
+ }
208
+
209
+ static auto scatter_cross_sect(const AeroParticle &self) {
210
+ auto fn = f_aero_particle_scatter_cross_sect;
211
+ return pypartmc::get_array_values_set_len(self, fn, n_swbands);
212
+ }
213
+
214
+ static auto absorb_cross_sect(const AeroParticle &self) {
215
+ auto fn = f_aero_particle_absorb_cross_sect;
216
+ return pypartmc::get_array_values_set_len(self, fn, n_swbands);
217
+ }
218
+
219
+ static auto asymmetry(const AeroParticle &self) {
220
+ auto fn = f_aero_particle_asymmetry;
221
+ return pypartmc::get_array_values_set_len(self, fn, n_swbands);
222
+ }
223
+
224
+ static auto sources(const AeroParticle &self) {
225
+ int len = AeroData::n_source(*self.aero_data);
226
+ auto fn = f_aero_particle_get_component_sources;
227
+ return pypartmc::get_array_values_set_len<int>(self, fn, len);
228
+ }
229
+
230
+ static auto least_create_time(const AeroParticle &self) {
231
+ return pypartmc::get_value(self, f_aero_particle_least_create_time);
232
+ }
233
+
234
+ static auto greatest_create_time(const AeroParticle &self) {
235
+ return pypartmc::get_value(self, f_aero_particle_greatest_create_time);
236
+ }
237
+
238
+ static auto id(const AeroParticle &self) {
239
+ return pypartmc::get_value<int64_t>(self, f_aero_particle_id);
240
+ }
241
+
242
+ static auto is_frozen(const AeroParticle &self) {
243
+ return pypartmc::get_value<bool>(self, f_aero_particle_frozen);
244
+ }
245
+
246
+ static auto refract_shell(const AeroParticle &self) {
247
+ auto fn = f_aero_particle_refract_shell;
248
+ return pypartmc::get_array_values_set_len<std::complex<double>>(self, fn, n_swbands);
249
+ }
250
+
251
+ static auto refract_core(const AeroParticle &self) {
252
+ auto fn = f_aero_particle_refract_core;
253
+ return pypartmc::get_array_values_set_len<std::complex<double>>(self, fn, n_swbands);
254
+ }
255
+
256
+ static auto get_weight_class(const AeroParticle &self) {
257
+ return pypartmc::get_value<int>(self, f_aero_particle_get_weight_class);
258
+ }
259
+
260
+ static void set_weight_class(AeroParticle &self, const int weight_class) {
261
+ pypartmc::set_value<int>(self, f_aero_particle_set_weight_class, weight_class);
262
+ }
263
+
264
+ static auto get_weight_group(const AeroParticle &self) {
265
+ return pypartmc::get_value<int>(self, f_aero_particle_get_weight_group);
266
+ }
267
+
268
+ static void set_weight_group(AeroParticle &self, const int weight_group) {
269
+ pypartmc::set_value<int>(self, f_aero_particle_set_weight_group, weight_group);
270
+ }
271
+
272
+ static void new_id(AeroParticle &self) {
273
+ f_aero_particle_new_id(self.ptr.f_arg_non_const());
274
+ }
275
+ };