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,155 @@
1
+ #pragma once
2
+
3
+ #include <set>
4
+ #include <map>
5
+ #include <string>
6
+ #include <sstream>
7
+ #include "nlohmann/json.hpp"
8
+
9
+ struct InputGuard {
10
+ public:
11
+ InputGuard(const nlohmann::ordered_json &j) {
12
+ process_json(j);
13
+
14
+ this->dict_key_present = false;
15
+ }
16
+
17
+ ~InputGuard() {}
18
+
19
+ void check_used_inputs() {
20
+ for (auto item : this->used_inputs) {
21
+ if (!item.second) {
22
+ std::string err = std::string("WARNING: \"") + item.first + std::string("\" parameter remains unused.");
23
+ throw std::runtime_error(err);
24
+ }
25
+ }
26
+ }
27
+
28
+ void mark_used_input(const std::string &input_name) {
29
+ if (this->prefixes.find(input_name) == this->prefixes.end()) {
30
+ std::string prefix = combine_str_vec(this->curr_prefix);
31
+
32
+ if (!prefix.empty()) {
33
+ this->used_inputs[prefix + "/" + input_name] = true;
34
+ }
35
+ else {
36
+ this->used_inputs[input_name] = true;
37
+ }
38
+ }
39
+ }
40
+
41
+ void update_dict_key(std::string dict_key) {
42
+ this->curr_dict_key = dict_key;
43
+ }
44
+
45
+ void check_read_line(std::string line) {
46
+ if (line == "mode_name") {
47
+ if (this->dict_key_present) {
48
+ this->curr_prefix.pop_back();
49
+ }
50
+ this->curr_prefix.push_back(this->curr_dict_key);
51
+ this->dict_key_present = true;
52
+ }
53
+ else if (line.empty()) {
54
+ this->curr_prefix.pop_back();
55
+ this->dict_key_present = false;
56
+ }
57
+ }
58
+
59
+ void open_spec_file(std::string spec_file_name) {
60
+ this->curr_prefix.push_back(spec_file_name);
61
+ }
62
+
63
+ void close_spec_file() {
64
+ this->curr_prefix.pop_back();
65
+ }
66
+
67
+ private:
68
+ std::map<std::string, bool> used_inputs;
69
+
70
+ std::set<std::string> prefixes;
71
+ std::string curr_dict_key;
72
+ std::vector<std::string> curr_prefix;
73
+
74
+ bool dict_key_present;
75
+
76
+ void process_json(const nlohmann::ordered_json &j) {
77
+ nlohmann::ordered_json flat = j.flatten();
78
+
79
+ // JSON Pointer, as in a string syntax for identifying a specific value in JSON
80
+ std::vector<std::string> json_pointers;
81
+
82
+ for (auto f : flat.items()) {
83
+ json_pointers.push_back(clean_string(f.key()));
84
+ }
85
+
86
+ std::set<std::string> json_pointers_set(json_pointers.begin(), json_pointers.end());
87
+
88
+ for (auto s : json_pointers_set) {
89
+ this->used_inputs[s] = false;
90
+ }
91
+
92
+ get_prefixes(json_pointers_set);
93
+ }
94
+
95
+ std::string clean_string(std::string str) {
96
+ bool after_slash = false;
97
+
98
+ for (size_t i = 0; i < str.size(); i++) {
99
+ if (str.at(i) == '/' && i+1 < str.size()) {
100
+ if (isdigit(str.at(i+1))) {
101
+ after_slash = true;
102
+ str.erase(i, 1);
103
+ i -= 1;
104
+ }
105
+ }
106
+ else if (isdigit(str.at(i)) && after_slash) {
107
+ str.erase(i, 1);
108
+ i -= 1;
109
+ }
110
+ else {
111
+ after_slash = false;
112
+ }
113
+ }
114
+
115
+ str.erase(0, 1);
116
+
117
+ return str;
118
+ }
119
+
120
+ std::string combine_str_vec(std::vector<std::string> vec) {
121
+ if (vec.size() == 0) return "";
122
+
123
+ std::string temp = vec[0];
124
+
125
+ for (size_t i = 1; i < vec.size(); i++) {
126
+ temp += "/";
127
+ temp += vec[i];
128
+ }
129
+
130
+ return temp;
131
+ }
132
+
133
+ void get_prefixes(std::set<std::string> json_pointers_set) {
134
+ std::string temp;
135
+ std::vector<std::string> temp_vec;
136
+
137
+ for (auto s : json_pointers_set) {
138
+ std::stringstream line(s);
139
+
140
+ while(getline(line, temp, '/')) {
141
+ temp_vec.push_back(temp);
142
+ }
143
+
144
+ if (temp_vec.size() > 1) {
145
+ temp_vec.pop_back();
146
+
147
+ for (auto v : temp_vec) {
148
+ this->prefixes.insert(v);
149
+ }
150
+ }
151
+
152
+ temp_vec.clear();
153
+ }
154
+ }
155
+ };
@@ -0,0 +1,363 @@
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 <iostream>
10
+ #include <sstream>
11
+ #include <set>
12
+ #include <stack>
13
+ #include <map>
14
+ #include "nlohmann/json.hpp"
15
+ #include <tcb/span.hpp>
16
+ #include <bpstd/string_view.hpp>
17
+ #include "input_guard.hpp"
18
+
19
+ struct JSONResource {
20
+ private:
21
+ std::set<std::string> vars;
22
+ const nlohmann::ordered_json *json;
23
+ std::stack<const nlohmann::ordered_json*> json_parent;
24
+
25
+ std::unique_ptr<InputGuard> input_guard_ptr;
26
+
27
+ void warn(const std::exception &exception) {
28
+ std::cerr << "WARN: " << exception.what() << std::endl;
29
+ // assert(false);
30
+ }
31
+
32
+ protected:
33
+ size_t index = 0, named_array_read_count = 0;
34
+
35
+ JSONResource() {}
36
+
37
+ JSONResource(const nlohmann::ordered_json &json) {
38
+ this->set_current_json_ptr(&json);
39
+ for (auto &entry : this->json->items()) {
40
+ this->vars.insert(entry.key());
41
+ }
42
+
43
+ input_guard_ptr = std::make_unique<InputGuard>(json);
44
+ };
45
+
46
+ void set_current_json_ptr(const nlohmann::ordered_json *ptr) {
47
+ this->json = ptr;
48
+ }
49
+
50
+ auto dump() const {
51
+ return this->json->dump();
52
+ }
53
+
54
+ template <class T>
55
+ std::string next_dict_key(T last_key, const T key_cond) const noexcept {
56
+ std::string key = "", prev_key = "";
57
+ if (last_key == key_cond)
58
+ last_key = "";
59
+
60
+ for (const auto& item : this->json->items()) {
61
+ if (this->json->is_array()) {
62
+ for (auto &entry : item.value().items()) {
63
+ if (prev_key == last_key) {
64
+ key = entry.key();
65
+ break;
66
+ }
67
+ else
68
+ prev_key = entry.key();
69
+ }
70
+ } else {
71
+ key = item.key();
72
+ }
73
+ }
74
+
75
+ input_guard_ptr->update_dict_key(key);
76
+
77
+ return key;
78
+ }
79
+
80
+ public:
81
+ virtual ~JSONResource() {}
82
+
83
+ auto n_named_array_read_count() noexcept {
84
+ return this->named_array_read_count;
85
+ }
86
+
87
+ void zoom_in(const bpstd::string_view &sub) noexcept {
88
+ auto it = this->json->is_array()
89
+ ? this->json->at(this->json->size()-1).find(sub.to_string())
90
+ : this->json->find(sub.to_string());
91
+
92
+ assert(*it != NULL);
93
+ this->json_parent.push(this->json);
94
+
95
+ if (sub == "dist") // TODO #112: do better than hardcoding "dist"...
96
+ this->set_current_json_ptr(&(it->at(this->n_elements(sub) - this->index--)));
97
+ else
98
+ this->set_current_json_ptr(&(*it));
99
+
100
+ this->named_array_read_count = 0;
101
+ }
102
+
103
+ void zoom_out() noexcept {
104
+ assert(this->json_parent.size() != 0);
105
+ this->set_current_json_ptr(this->json_parent.top());
106
+ this->json_parent.pop();
107
+ }
108
+
109
+ auto zoom_level() const noexcept {
110
+ auto level = this->json_parent.size();
111
+ return level;
112
+ }
113
+
114
+ auto begin() noexcept {
115
+ return this->json->begin();
116
+ }
117
+
118
+ auto first_field_name() noexcept {
119
+ // TODO #112: handle errors
120
+ std::string name = "";
121
+ assert(this->json->size() > 0);
122
+ assert(this->json->begin()->size() > 0);
123
+ for (auto &entry : this->json->at(this->named_array_read_count++).items())
124
+ {
125
+ name = entry.key();
126
+ }
127
+ if (name == "")
128
+ assert(false);
129
+ return name;
130
+ }
131
+
132
+ std::size_t n_elements(const bpstd::string_view &name) const noexcept {
133
+ std::size_t n_elem = 0;
134
+ for (auto i=0u; i<this->json->size(); ++i) {
135
+ for (auto &entry : this->json->at(i).items()) {
136
+ if (entry.key() == name)
137
+ n_elem = entry.value().size();
138
+ }
139
+ }
140
+ return n_elem;
141
+ }
142
+
143
+ auto n_numeric_array_entries() noexcept {
144
+ auto count = 0u;
145
+ for (auto i=0u; i<this->json->size(); ++i) {
146
+ assert(this->json->at(i).is_object());
147
+ assert(this->json->at(i).size() == 1);
148
+ for (auto &entry : this->json->at(i).items())
149
+ if (entry.value().is_array() && (entry.value().size() == 0 || entry.value().at(0).is_number()))
150
+ ++count;
151
+ }
152
+ return count;
153
+ }
154
+
155
+ template <typename T>
156
+ void read_value(
157
+ const bpstd::string_view name,
158
+ T *var
159
+ ) {
160
+ *var = this->find(name.to_string())->get<T>();
161
+ }
162
+
163
+ void read_str(
164
+ const bpstd::string_view &name,
165
+ char* var_data,
166
+ int* var_size
167
+ ) noexcept {
168
+ auto it = this->find(name.to_string());
169
+ if (it == this->json->end())
170
+ {
171
+ assert(false);
172
+ // TODO #112
173
+ return;
174
+ }
175
+ auto value = it->is_array()
176
+ ? name
177
+ : it->begin()->get<bpstd::string_view>(); // TODO #112: is this path used anywhere?
178
+ if ((int)value.size() > *var_size) {
179
+ std::ostringstream oss;
180
+ oss << "provided entry \"" << name << "\" has too many characters";
181
+ this->warn(std::invalid_argument(oss.str()));
182
+ }
183
+ for (auto i = 0u; i < value.size(); ++i)
184
+ var_data[i] = value[i];
185
+ var_size[0] = value.size();
186
+ }
187
+
188
+ template <typename T1, typename T2>
189
+ void read_arr(
190
+ const T1 &name,
191
+ const tcb::span<T2> &values
192
+ ) noexcept {
193
+ for (auto i=0u; i<this->json->size(); ++i) {
194
+ for (auto &entry : this->json->at(i).items()) {
195
+ if (entry.key() == name) {
196
+ for (auto j = 0u; j < values.size(); ++j)
197
+ values[j] = entry.value().at(j);
198
+ return;
199
+ }
200
+ }
201
+ }
202
+ // TODO #112: check size
203
+ }
204
+
205
+ auto varid(const std::string& name) noexcept {
206
+ auto it = this->vars.find(name);
207
+ if (it == this->vars.end()) {
208
+ this->warn(std::logic_error("var not found!"));
209
+ }
210
+ return std::distance(this->vars.begin(), it);
211
+ }
212
+
213
+ template <typename T>
214
+ auto find(const T& entry) noexcept -> decltype(this->json->end()) {
215
+ auto it = this->json->find(entry);
216
+ if (it == this->json->end()) {
217
+ std::ostringstream oss;
218
+ oss << "provided data is missing the \"" << entry << "\" entry";
219
+ this->warn(std::invalid_argument(oss.str()));
220
+ }
221
+ return it;
222
+ }
223
+
224
+ InputGuard *get_input_guard_ptr() {
225
+ return input_guard_ptr.get();
226
+ }
227
+
228
+ virtual std::string str() const = 0;
229
+
230
+ virtual bool read_line(std::string &name, std::string &data) = 0;
231
+
232
+ virtual int read_line_data_size_and_start_enumerating() = 0;
233
+ };
234
+
235
+ struct InputJSONResource: JSONResource {
236
+ private:
237
+ std::string key_cond, key_name;
238
+ std::string last_read_line_key = "";
239
+ std::size_t max_zoom_level;
240
+
241
+ public:
242
+ InputJSONResource(
243
+ const nlohmann::ordered_json &json,
244
+ const std::string key_cond = "",
245
+ const std::string key_name = "",
246
+ const std::size_t max_zoom_level = 3
247
+ ) : JSONResource(json), key_cond(key_cond), key_name(key_name), max_zoom_level(max_zoom_level)
248
+ {
249
+ }
250
+
251
+ std::string str() const {
252
+ throw std::logic_error("str() called on InputJSONResource!");
253
+ }
254
+
255
+ bool read_line(std::string &name, std::string &data) {
256
+ bool subsequent_record = false;
257
+ if (this->zoom_level() == this->max_zoom_level) {
258
+ this->zoom_out();
259
+
260
+ auto key = this->next_dict_key(this->last_read_line_key, this->key_cond);
261
+ if (key == "") {
262
+ if (this->index == 0)
263
+ this->last_read_line_key = "";
264
+ else
265
+ this->last_read_line_key = this->key_cond;
266
+ return true;
267
+ }
268
+ else
269
+ subsequent_record = true;
270
+ }
271
+
272
+ auto key = this->next_dict_key(this->last_read_line_key, this->key_cond);
273
+ if (subsequent_record || (this->key_name != "" && (this->key_cond == this->last_read_line_key))) {
274
+ name = this->key_name;
275
+ this->zoom_in(key);
276
+ } else {
277
+ name = key;
278
+ }
279
+ data = key;
280
+ this->last_read_line_key = key;
281
+
282
+ return false;
283
+ }
284
+
285
+ int read_line_data_size_and_start_enumerating() {
286
+ if (this->zoom_level() == this->max_zoom_level - 2) {
287
+ this->index = this->n_elements(this->key_cond);
288
+ return this->index;
289
+ }
290
+ return 1;
291
+ }
292
+
293
+ static bool unique_keys(const nlohmann::ordered_json &json) {
294
+ std::set<std::string> keys;
295
+ for (auto i=0u; i<json.size(); ++i) {
296
+ for (auto &entry : json.at(i).items()) {
297
+ if (keys.find(entry.key()) != keys.end())
298
+ return false;
299
+ keys.insert(entry.key());
300
+ }
301
+ }
302
+ return true;
303
+ }
304
+ };
305
+
306
+ struct OutputJSONResource: JSONResource {
307
+ std::unique_ptr<nlohmann::ordered_json> guard;
308
+
309
+ OutputJSONResource() : guard(std::make_unique<nlohmann::ordered_json>()) {
310
+ this->set_current_json_ptr(this->guard.get());
311
+ }
312
+
313
+ std::string str() const {
314
+ return this->dump();
315
+ }
316
+
317
+ bool read_line(std::string &, std::string &) {
318
+ throw std::logic_error("read_line() called on OutputJSONResource!");
319
+ }
320
+
321
+ int read_line_data_size_and_start_enumerating() {
322
+ throw std::logic_error("read_line_data_size_and_start_enumerating() called on OutputJSONResource!");
323
+ }
324
+ };
325
+
326
+ std::unique_ptr<JSONResource> &json_resource_ptr();
327
+
328
+ template <typename T>
329
+ struct JSONResourceGuard {
330
+ JSONResourceGuard() {
331
+ json_resource_ptr() = std::make_unique<T>();
332
+ }
333
+
334
+ JSONResourceGuard(const nlohmann::ordered_json & json) {
335
+ json_resource_ptr() = std::make_unique<T>(json);
336
+ }
337
+
338
+ JSONResourceGuard(
339
+ const nlohmann::ordered_json & json,
340
+ const std::string key_cond,
341
+ const std::string key_name
342
+ ) {
343
+ json_resource_ptr() = std::make_unique<T>(json, key_cond, key_name);
344
+ }
345
+
346
+ JSONResourceGuard(
347
+ const nlohmann::ordered_json & json,
348
+ const std::string key_cond,
349
+ const std::string key_name,
350
+ const int max_zoom_level
351
+ ) {
352
+ json_resource_ptr() = std::make_unique<T>(json, key_cond, key_name, max_zoom_level);
353
+ }
354
+
355
+ ~JSONResourceGuard() {
356
+ json_resource_ptr().reset();
357
+ }
358
+
359
+ void check_parameters() {
360
+ json_resource_ptr()->get_input_guard_ptr()->check_used_inputs();
361
+ }
362
+ };
363
+
@@ -0,0 +1,96 @@
1
+ /*##################################################################################################
2
+ # This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
3
+ # Copyright (C) 2022-2025 University of Illinois Urbana-Champaign #
4
+ # Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
5
+ ##################################################################################################*/
6
+
7
+ #pragma once
8
+
9
+ #include "aero_state.hpp"
10
+ #include "aero_binned.hpp"
11
+ #include "aero_data.hpp"
12
+ #include "aero_dist.hpp"
13
+ #include "bin_grid.hpp"
14
+ #include "env_state.hpp"
15
+ #include "gas_data.hpp"
16
+ #include "gas_state.hpp"
17
+
18
+ extern "C" void f_output_state(
19
+ const char *prefix,
20
+ const int *prefix_size,
21
+ const void *aero_data,
22
+ const void *aero_state,
23
+ const void *gas_data,
24
+ const void *gas_state,
25
+ const void *env_state,
26
+ const int *index,
27
+ const double *time,
28
+ const double *del_t,
29
+ const int *i_repeat,
30
+ const bool *record_removals,
31
+ const bool *record_optical
32
+ ) noexcept;
33
+
34
+ extern "C" void f_input_state(
35
+ const char *filename,
36
+ const int *filename_size,
37
+ int *index,
38
+ double *time,
39
+ double *del_t,
40
+ int *i_repeat,
41
+ const void *aero_data,
42
+ const void *aero_state,
43
+ const void *gas_data,
44
+ const void *gas_state,
45
+ const void *env_state
46
+ ) noexcept;
47
+
48
+ extern "C" void f_input_sectional(
49
+ const char *filename,
50
+ const int *filename_size,
51
+ int *index,
52
+ double *time,
53
+ double *del_t,
54
+ const void *bin_grid,
55
+ const void *aero_data,
56
+ const void *aero_binned,
57
+ const void *gas_data,
58
+ const void *gas_state,
59
+ const void *env_state
60
+ ) noexcept;
61
+
62
+ extern "C" void f_input_exact(
63
+ const char *filename,
64
+ const int *filename_size,
65
+ int *index,
66
+ double *time,
67
+ double *del_t,
68
+ const void *bin_grid,
69
+ const void *aero_data,
70
+ const void *aero_binned,
71
+ const void *gas_data,
72
+ const void *gas_state,
73
+ const void *env_state
74
+ ) noexcept;
75
+
76
+ void output_state(
77
+ const std::string &prefix,
78
+ const AeroData &aero_data,
79
+ const AeroState &aero_state,
80
+ const GasData &gas_data,
81
+ const GasState &gas_state,
82
+ const EnvState &env_state
83
+ );
84
+
85
+ std::tuple<std::shared_ptr<AeroData>, AeroState*, std::shared_ptr<GasData>, GasState*, EnvState*> input_state(
86
+ const std::string &name
87
+ );
88
+
89
+ std::tuple<std::shared_ptr<AeroData>, BinGrid*, AeroBinned*, std::shared_ptr<GasData>, GasState*, EnvState*> input_sectional(
90
+ const std::string &name
91
+ );
92
+
93
+ std::tuple<std::shared_ptr<AeroData>, BinGrid*, AeroBinned*, std::shared_ptr<GasData>, GasState*,
94
+ EnvState*> input_exact(
95
+ const std::string &name
96
+ );
@@ -0,0 +1,29 @@
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 "json_resource.hpp"
10
+ #include "pmc_resource.hpp"
11
+ #include "camp_core.hpp"
12
+
13
+ extern "C" void f_photolysis_ctor(void *ptr) noexcept;
14
+ extern "C" void f_photolysis_dtor(void *ptr) noexcept;
15
+ extern "C" void f_photolysis_create(const void *ptr, const void *camp_core) noexcept;
16
+ struct Photolysis {
17
+ PMCResource ptr;
18
+
19
+ Photolysis() :
20
+ ptr(f_photolysis_ctor, f_photolysis_dtor)
21
+ {
22
+ }
23
+
24
+ Photolysis(const CampCore &camp_core) :
25
+ ptr(f_photolysis_ctor, f_photolysis_dtor)
26
+ {
27
+ f_photolysis_create(this->ptr.f_arg(), camp_core.ptr.f_arg());
28
+ }
29
+ };
@@ -0,0 +1,42 @@
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 <iostream>
10
+
11
+ class PMCResource {
12
+ void *ptr;
13
+ void (*f_ctor)(void*);
14
+ void (*f_dtor)(void*);
15
+
16
+ PMCResource(const PMCResource&) = delete;
17
+ PMCResource& operator= (const PMCResource&) = delete;
18
+
19
+ public:
20
+ PMCResource(
21
+ decltype(f_ctor) f_ctor,
22
+ decltype(f_dtor) f_dtor
23
+ ) :
24
+ f_ctor(f_ctor),
25
+ f_dtor(f_dtor)
26
+ {
27
+ this->f_ctor(&this->ptr);
28
+ }
29
+
30
+ ~PMCResource() {
31
+ this->f_dtor(&this->ptr);
32
+ }
33
+
34
+ const void *f_arg() const {
35
+ return &this->ptr;
36
+ }
37
+
38
+ void *f_arg_non_const() {
39
+ return &this->ptr;
40
+ }
41
+ };
42
+
@@ -0,0 +1,12 @@
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
+ extern "C" void f_pmc_srand(const int*);
10
+ extern "C" void f_rand_normal(const double*, const double*, double*);
11
+ void rand_init(int seed);
12
+ double rand_normal(double mean, double stddev);