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,34 @@
1
+ /*##################################################################################################
2
+ # This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
3
+ # Copyright (C) 2025 University of Illinois Urbana-Champaign #
4
+ # Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
5
+ ##################################################################################################*/
6
+
7
+ #pragma once
8
+ #include "aero_data.hpp"
9
+ #include "bin_grid.hpp"
10
+ #include "env_state.hpp"
11
+ #include "gas_data.hpp"
12
+ #include "gas_state.hpp"
13
+ #include "run_exact_opt.hpp"
14
+ #include "scenario.hpp"
15
+
16
+ extern "C" void f_run_exact(
17
+ const void*,
18
+ const void*,
19
+ const void*,
20
+ const void*,
21
+ const void*,
22
+ const void*,
23
+ const void*
24
+ ) noexcept;
25
+
26
+ void run_exact(
27
+ const BinGrid &bin_grid,
28
+ const GasData &gas_data,
29
+ const AeroData &aero_data,
30
+ const AeroDist &aero_dist,
31
+ const Scenario &scenario,
32
+ const EnvState &env_state,
33
+ const RunExactOpt &run_exact_opt
34
+ );
@@ -0,0 +1,46 @@
1
+ /*##################################################################################################
2
+ # This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
3
+ # Copyright (C) 2025 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 "json_resource.hpp"
11
+ #include "env_state.hpp"
12
+
13
+ extern "C" void f_run_exact_opt_ctor(void *ptr) noexcept;
14
+ extern "C" void f_run_exact_opt_dtor(void *ptr) noexcept;
15
+ extern "C" void f_run_exact_opt_from_json(const void *ptr, const void *env_state_ptr) noexcept;
16
+ extern "C" void f_run_exact_opt_t_max(const void *ptr, double *t_max) noexcept;
17
+
18
+ struct RunExactOpt {
19
+ PMCResource ptr;
20
+
21
+ RunExactOpt(const nlohmann::ordered_json &json, EnvState &env_state) :
22
+ ptr(f_run_exact_opt_ctor, f_run_exact_opt_dtor)
23
+ {
24
+ nlohmann::ordered_json json_copy(json);
25
+
26
+ for (auto key : std::set<std::string>({
27
+ "t_output"
28
+ }))
29
+ if (json_copy.find(key) == json_copy.end())
30
+ json_copy[key] = 0;
31
+
32
+ JSONResourceGuard<InputJSONResource> guard(json_copy);
33
+ f_run_exact_opt_from_json(this->ptr.f_arg(), env_state.ptr.f_arg());
34
+ guard.check_parameters();
35
+ }
36
+
37
+ static auto t_max(const RunExactOpt &self){
38
+ double t_max;
39
+
40
+ f_run_exact_opt_t_max(self.ptr.f_arg(), &t_max);
41
+
42
+ return t_max;
43
+ }
44
+
45
+ };
46
+
@@ -0,0 +1,110 @@
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
+ #include "aero_data.hpp"
9
+ #include "aero_state.hpp"
10
+ #include "env_state.hpp"
11
+ #include "gas_data.hpp"
12
+ #include "gas_state.hpp"
13
+ #include "run_part_opt.hpp"
14
+ #include "scenario.hpp"
15
+ #include "camp_core.hpp"
16
+ #include "photolysis.hpp"
17
+
18
+ extern "C" void f_run_part(
19
+ const void*,
20
+ const void*,
21
+ const void*,
22
+ const void*,
23
+ const void*,
24
+ const void*,
25
+ const void*,
26
+ const void*,
27
+ const void*
28
+ ) noexcept;
29
+
30
+ extern "C" void f_run_part_timestep(
31
+ const void*,
32
+ void*,
33
+ const void*,
34
+ void*,
35
+ const void*,
36
+ void*,
37
+ const void*,
38
+ const void*,
39
+ const void*,
40
+ const int *,
41
+ const double*,
42
+ double*,
43
+ double*,
44
+ int*
45
+ ) noexcept;
46
+
47
+ extern "C" void f_run_part_timeblock(
48
+ const void*,
49
+ void*,
50
+ const void*,
51
+ void*,
52
+ const void*,
53
+ void*,
54
+ const void*,
55
+ const void*,
56
+ const void*,
57
+ const int *,
58
+ const int *,
59
+ const double *,
60
+ double*,
61
+ double*,
62
+ int*
63
+ ) noexcept;
64
+
65
+ void run_part(
66
+ const Scenario &scenario,
67
+ EnvState &env_state,
68
+ const AeroData &aero_data,
69
+ AeroState &aero_state,
70
+ const GasData &gas_data,
71
+ GasState &gas_state,
72
+ const RunPartOpt &run_part_opt,
73
+ const CampCore &camp_core,
74
+ const Photolysis &photolysis
75
+ );
76
+
77
+ std::tuple<double, double, int> run_part_timestep(
78
+ const Scenario &scenario,
79
+ EnvState &env_state,
80
+ const AeroData &aero_data,
81
+ AeroState &aero_state,
82
+ const GasData &gas_data,
83
+ GasState &gas_state,
84
+ const RunPartOpt &run_part_opt,
85
+ const CampCore &camp_core,
86
+ const Photolysis &photolysis,
87
+ const int &i_time,
88
+ const double &t_start,
89
+ double &last_output_time,
90
+ double &last_progress_time,
91
+ int &i_output
92
+ );
93
+
94
+ std::tuple<double, double, int> run_part_timeblock(
95
+ const Scenario &scenario,
96
+ EnvState &env_state,
97
+ const AeroData &aero_data,
98
+ AeroState &aero_state,
99
+ const GasData &gas_data,
100
+ GasState &gas_state,
101
+ const RunPartOpt &run_part_opt,
102
+ const CampCore &camp_core,
103
+ const Photolysis &photolysis,
104
+ const int &i_time,
105
+ const int &i_next,
106
+ const double &t_start,
107
+ double &last_output_time,
108
+ double &last_progress_time,
109
+ int &i_output
110
+ );
@@ -0,0 +1,72 @@
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 "json_resource.hpp"
11
+
12
+ extern "C" void f_run_part_opt_ctor(void *ptr) noexcept;
13
+ extern "C" void f_run_part_opt_dtor(void *ptr) noexcept;
14
+ extern "C" void f_run_part_opt_from_json(const void *ptr) noexcept;
15
+ extern "C" void f_run_part_opt_t_max(const void *ptr, double *t_max) noexcept;
16
+ extern "C" void f_run_part_opt_del_t(const void *ptr, double *del_t) noexcept;
17
+
18
+ struct RunPartOpt {
19
+ PMCResource ptr;
20
+ bool allow_halving, allow_doubling;
21
+
22
+ RunPartOpt(const nlohmann::ordered_json &json) :
23
+ ptr(f_run_part_opt_ctor, f_run_part_opt_dtor)
24
+ {
25
+ nlohmann::ordered_json json_copy(json);
26
+
27
+ if (json_copy.find("do_parallel") != json_copy.end() && json_copy["do_parallel"])
28
+ throw std::runtime_error("setting do_parallel=true not supported in PyPartMC");
29
+ json_copy["do_parallel"] = false;
30
+
31
+ for (auto key : std::set<std::string>({
32
+ "do_mosaic", "do_camp_chem", "do_condensation", "do_nucleation", "do_immersion_freezing",
33
+ }))
34
+ if (json_copy.find(key) == json_copy.end())
35
+ json_copy[key] = false;
36
+
37
+ for (auto key : std::set<std::string>({
38
+ "allow_halving", "allow_doubling"
39
+ }))
40
+ if (json_copy.find(key) == json_copy.end())
41
+ json_copy[key] = true;
42
+ allow_halving = json_copy["allow_halving"];
43
+ allow_doubling = json_copy["allow_doubling"];
44
+
45
+ for (auto key : std::set<std::string>({
46
+ "t_output", "t_progress", "rand_init"
47
+ }))
48
+ if (json_copy.find(key) == json_copy.end())
49
+ json_copy[key] = 0;
50
+
51
+ JSONResourceGuard<InputJSONResource> guard(json_copy);
52
+ f_run_part_opt_from_json(this->ptr.f_arg());
53
+ guard.check_parameters();
54
+ }
55
+
56
+ static auto t_max(const RunPartOpt &self){
57
+ double t_max;
58
+
59
+ f_run_part_opt_t_max(self.ptr.f_arg(), &t_max);
60
+
61
+ return t_max;
62
+ }
63
+
64
+ static auto del_t(const RunPartOpt &self){
65
+ double del_t;
66
+
67
+ f_run_part_opt_del_t(self.ptr.f_arg(), &del_t);
68
+
69
+ return del_t;
70
+ }
71
+ };
72
+
@@ -0,0 +1,34 @@
1
+ /*##################################################################################################
2
+ # This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
3
+ # Copyright (C) 2025 University of Illinois Urbana-Champaign #
4
+ # Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
5
+ ##################################################################################################*/
6
+
7
+ #pragma once
8
+ #include "aero_data.hpp"
9
+ #include "bin_grid.hpp"
10
+ #include "env_state.hpp"
11
+ #include "gas_data.hpp"
12
+ #include "gas_state.hpp"
13
+ #include "run_sect_opt.hpp"
14
+ #include "scenario.hpp"
15
+
16
+ extern "C" void f_run_sect(
17
+ const void*,
18
+ const void*,
19
+ const void*,
20
+ const void*,
21
+ const void*,
22
+ const void*,
23
+ const void*
24
+ ) noexcept;
25
+
26
+ void run_sect(
27
+ const BinGrid &bin_grid,
28
+ const GasData &gas_data,
29
+ const AeroData &aero_data,
30
+ const AeroDist &aero_dist,
31
+ const Scenario &scenario,
32
+ const EnvState &env_state,
33
+ const RunSectOpt &run_sect_opt
34
+ );
@@ -0,0 +1,54 @@
1
+ /*##################################################################################################
2
+ # This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
3
+ # Copyright (C) 2025 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 "json_resource.hpp"
11
+ #include "env_state.hpp"
12
+
13
+ extern "C" void f_run_sect_opt_ctor(void *ptr) noexcept;
14
+ extern "C" void f_run_sect_opt_dtor(void *ptr) noexcept;
15
+ extern "C" void f_run_sect_opt_from_json(const void *ptr, const void *env_state_ptr) noexcept;
16
+ extern "C" void f_run_sect_opt_t_max(const void *ptr, double *t_max) noexcept;
17
+ extern "C" void f_run_sect_opt_del_t(const void *ptr, double *del_t) noexcept;
18
+
19
+ struct RunSectOpt {
20
+ PMCResource ptr;
21
+
22
+ RunSectOpt(const nlohmann::ordered_json &json, EnvState &env_state) :
23
+ ptr(f_run_sect_opt_ctor, f_run_sect_opt_dtor)
24
+ {
25
+ nlohmann::ordered_json json_copy(json);
26
+
27
+ for (auto key : std::set<std::string>({
28
+ "t_output", "t_progress"
29
+ }))
30
+ if (json_copy.find(key) == json_copy.end())
31
+ json_copy[key] = 0;
32
+
33
+ JSONResourceGuard<InputJSONResource> guard(json_copy);
34
+ f_run_sect_opt_from_json(this->ptr.f_arg(), env_state.ptr.f_arg());
35
+ guard.check_parameters();
36
+ }
37
+
38
+ static auto t_max(const RunSectOpt &self){
39
+ double t_max;
40
+
41
+ f_run_sect_opt_t_max(self.ptr.f_arg(), &t_max);
42
+
43
+ return t_max;
44
+ }
45
+
46
+ static auto del_t(const RunSectOpt &self){
47
+ double del_t;
48
+
49
+ f_run_sect_opt_del_t(self.ptr.f_arg(), &del_t);
50
+
51
+ return del_t;
52
+ }
53
+ };
54
+
@@ -0,0 +1,220 @@
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 "aero_data.hpp"
12
+ #include "aero_dist.hpp"
13
+ #include "env_state.hpp"
14
+ #include "gas_data.hpp"
15
+
16
+ extern "C" void f_scenario_ctor(void *ptr) noexcept;
17
+ extern "C" void f_scenario_dtor(void *ptr) noexcept;
18
+ extern "C" void f_scenario_from_json(
19
+ const void *gas_data,
20
+ const void *aero_data,
21
+ const void *scenario
22
+ )
23
+ #ifndef __linux__
24
+ noexcept
25
+ #endif
26
+ ;
27
+ extern "C" void f_scenario_loss_rate(
28
+ const void *scenario,
29
+ const double *vol,
30
+ const double *density,
31
+ const void *aero_data,
32
+ const void *env_state,
33
+ double *rate
34
+ ) noexcept;
35
+ extern "C" void f_scenario_loss_rate_dry_dep(
36
+ const double *vol,
37
+ const double *density,
38
+ const void *aero_data,
39
+ const void *env_state,
40
+ double *rate
41
+ ) noexcept;
42
+ extern "C" void f_scenario_init_env_state(
43
+ const void *scenario,
44
+ void *env_state,
45
+ const double *time
46
+ ) noexcept;
47
+ extern "C" void f_scenario_aero_dist_emission(
48
+ const void *scenario,
49
+ const void *aero_dist,
50
+ const int *idx
51
+ ) noexcept;
52
+ extern "C" void f_scenario_aero_emission_n_times(
53
+ const void *scenario,
54
+ int *n_times
55
+ ) noexcept;
56
+ extern "C" void f_scenario_emission_rates(
57
+ const void *scenario,
58
+ double *rates,
59
+ const int *len
60
+ ) noexcept;
61
+ extern "C" void f_scenario_emission_time(
62
+ const void *scenario,
63
+ double *times,
64
+ const int *len
65
+ ) noexcept;
66
+ extern "C" void f_scenario_aero_dist_background(
67
+ const void *scenario,
68
+ const void *aero_dist,
69
+ const int *idx
70
+ ) noexcept;
71
+ extern "C" void f_scenario_aero_background_n_times(
72
+ const void *scenario,
73
+ int *n_times
74
+ ) noexcept;
75
+ extern "C" void f_scenario_aero_background_rate_scale(
76
+ const void *scenario,
77
+ double *rates,
78
+ const int *len
79
+ ) noexcept;
80
+ extern "C" void f_scenario_aero_background_time(
81
+ const void *scenario,
82
+ double *times,
83
+ const int *len
84
+ ) noexcept;
85
+
86
+ struct Scenario {
87
+ PMCResource ptr;
88
+ const nlohmann::ordered_json json;
89
+
90
+ Scenario(
91
+ const GasData &gas_data,
92
+ const AeroData &aero_data,
93
+ const nlohmann::ordered_json &json
94
+ ) :
95
+ ptr(f_scenario_ctor, f_scenario_dtor),
96
+ json(json)
97
+ {
98
+ // TODO #317 - repeat analogous checks for rates
99
+ for (auto &prof: std::set<std::string>({"height", "temp", "pressure"})) {
100
+ auto prof_key = prof + "_profile";
101
+ if (json.find(prof_key) != json.end()) {
102
+ if (!json[prof_key].is_array() || json[prof_key].size() != 2)
103
+ throw std::runtime_error(prof_key + " expected to be a 2-element list (of single-element dictionaries)");
104
+ for (auto i=0; i<2; ++i)
105
+ if (!json[prof_key][i].is_object() || json[prof_key][i].size() != 1)
106
+ throw std::runtime_error(prof_key + " expected to contain only single-element dicts");
107
+ {
108
+ auto elem = json[prof_key][0];
109
+ if (elem.find("time") == elem.end())
110
+ throw std::runtime_error(prof_key + " first element is expeced to be a single-element dict with 'time' key");
111
+ }
112
+ {
113
+ auto elem = json[prof_key][1];
114
+ if (elem.find(prof) == elem.end())
115
+ throw std::runtime_error(prof_key + " second element is expeced to be a single-element dict with '" + prof + "' key");
116
+ }
117
+ if (
118
+ !json[prof_key][0]["time"].is_array() ||
119
+ !json[prof_key][1][prof].is_array() ||
120
+ json[prof_key][0]["time"].size() != json[prof_key][1][prof].size()
121
+ )
122
+ throw std::runtime_error(prof_key + " 'time' and '" + prof + "' arrays do not have matching size");
123
+ }
124
+ }
125
+
126
+ JSONResourceGuard<InputJSONResource> guard(json, "dist", "mode_name");
127
+ f_scenario_from_json(
128
+ gas_data.ptr.f_arg(),
129
+ aero_data.ptr.f_arg(),
130
+ this->ptr.f_arg()
131
+ );
132
+ guard.check_parameters();
133
+ }
134
+
135
+ static auto __str__(const Scenario &self) {
136
+ return self.json.dump();
137
+ }
138
+
139
+ static void init_env_state(
140
+ const Scenario &self,
141
+ EnvState &env_state,
142
+ const double time
143
+ ) {
144
+ f_scenario_init_env_state(
145
+ self.ptr.f_arg(),
146
+ env_state.ptr.f_arg_non_const(),
147
+ &time
148
+ );
149
+ }
150
+
151
+ static AeroDist* get_aero_emission_dist(const Scenario &self, const AeroData &aero_data, const int &idx) {
152
+ // if (idx < 0 || idx >= AeroDist::get_n_mode(self))
153
+ // throw std::out_of_range("Index out of range");
154
+ AeroDist *ptr = new AeroDist();
155
+ f_scenario_aero_dist_emission(self.ptr.f_arg(), ptr, &idx);
156
+
157
+ return ptr;
158
+ }
159
+
160
+ static auto get_emissions_n_times(const Scenario &self) {
161
+ int len;
162
+ f_scenario_aero_emission_n_times(self.ptr.f_arg(), &len);
163
+
164
+ return len;
165
+ }
166
+
167
+ static auto emission_rate_scale(const Scenario &self) {
168
+ auto fn = f_scenario_emission_rates;
169
+ auto len_fn = f_scenario_aero_emission_n_times;
170
+ return pypartmc::get_array_values(self, fn, len_fn);
171
+ }
172
+
173
+ static auto emission_time(const Scenario &self) {
174
+ auto fn = f_scenario_emission_time;
175
+ auto len_fn = f_scenario_aero_emission_n_times;
176
+ return pypartmc::get_array_values(self, fn, len_fn);
177
+ }
178
+
179
+ static AeroDist* get_aero_background_dist(const Scenario &self, const AeroData &aero_data, const int &idx) {
180
+ AeroDist *ptr = new AeroDist();
181
+ f_scenario_aero_dist_background(self.ptr.f_arg(), ptr, &idx);
182
+
183
+ return ptr;
184
+ }
185
+
186
+ static auto get_aero_dilution_n_times(const Scenario &self) {
187
+ int len;
188
+ f_scenario_aero_background_n_times(self.ptr.f_arg(), &len);
189
+
190
+ return len;
191
+ }
192
+
193
+ static auto aero_dilution_rate(const Scenario &self) {
194
+ auto fn = f_scenario_aero_background_rate_scale;
195
+ auto len_fn = f_scenario_aero_background_n_times;
196
+ return pypartmc::get_array_values(self, fn, len_fn);
197
+ }
198
+
199
+ static auto aero_dilution_time(const Scenario &self) {
200
+ auto fn = f_scenario_aero_background_time;
201
+ auto len_fn = f_scenario_aero_background_n_times;
202
+ return pypartmc::get_array_values(self, fn, len_fn);
203
+ }
204
+
205
+ };
206
+
207
+ double loss_rate(
208
+ const Scenario &scenario,
209
+ const double vol,
210
+ const double density,
211
+ const AeroData &aero_data,
212
+ const EnvState &env_state
213
+ );
214
+
215
+ double loss_rate_dry_dep(
216
+ const double vol,
217
+ const double density,
218
+ const AeroData &aero_data,
219
+ const EnvState &env_state
220
+ );
@@ -0,0 +1,118 @@
1
+ #pragma once
2
+ struct si {static constexpr auto GJ=1000000000.0;
3
+ static constexpr auto GK=1000000000.0;
4
+ static constexpr auto GN=1000000000.0;
5
+ static constexpr auto GPa=1000000000.0;
6
+ static constexpr auto GW=1000000000.0;
7
+ static constexpr auto Gg=1000000.0;
8
+ static constexpr auto Gm=1000000000.0;
9
+ static constexpr auto Gmol=1000000000.0;
10
+ static constexpr auto Gs=1000000000.0;
11
+ static constexpr auto J=1.0;
12
+ static constexpr auto K=1.0;
13
+ static constexpr auto MJ=1000000.0;
14
+ static constexpr auto MK=1000000.0;
15
+ static constexpr auto MN=1000000.0;
16
+ static constexpr auto MPa=1000000.0;
17
+ static constexpr auto MW=1000000.0;
18
+ static constexpr auto Mg=1000.0;
19
+ static constexpr auto Mm=1000000.0;
20
+ static constexpr auto Mmol=1000000.0;
21
+ static constexpr auto Ms=1000000.0;
22
+ static constexpr auto N=1.0;
23
+ static constexpr auto Pa=1.0;
24
+ static constexpr auto TJ=1000000000000.0;
25
+ static constexpr auto TK=1000000000000.0;
26
+ static constexpr auto TN=1000000000000.0;
27
+ static constexpr auto TPa=1000000000000.0;
28
+ static constexpr auto TW=1000000000000.0;
29
+ static constexpr auto Tg=1000000000.0;
30
+ static constexpr auto Tm=1000000000000.0;
31
+ static constexpr auto Tmol=1000000000000.0;
32
+ static constexpr auto Ts=1000000000000.0;
33
+ static constexpr auto W=1.0;
34
+ static constexpr auto cJ=0.01;
35
+ static constexpr auto cK=0.01;
36
+ static constexpr auto cN=0.01;
37
+ static constexpr auto cPa=0.01;
38
+ static constexpr auto cW=0.01;
39
+ static constexpr auto cg=1e-05;
40
+ static constexpr auto cm=0.01;
41
+ static constexpr auto cmol=0.01;
42
+ static constexpr auto cs=0.01;
43
+ static constexpr auto dJ=0.1;
44
+ static constexpr auto dK=0.1;
45
+ static constexpr auto dN=0.1;
46
+ static constexpr auto dPa=0.1;
47
+ static constexpr auto dW=0.1;
48
+ static constexpr auto daJ=10.0;
49
+ static constexpr auto daK=10.0;
50
+ static constexpr auto daN=10.0;
51
+ static constexpr auto daPa=10.0;
52
+ static constexpr auto daW=10.0;
53
+ static constexpr auto dag=0.01;
54
+ static constexpr auto dam=10.0;
55
+ static constexpr auto damol=10.0;
56
+ static constexpr auto das=10.0;
57
+ static constexpr auto dg=0.0001;
58
+ static constexpr auto dm=0.1;
59
+ static constexpr auto dmol=0.1;
60
+ static constexpr auto ds=0.1;
61
+ static constexpr auto g=0.001;
62
+ static constexpr auto hJ=100.0;
63
+ static constexpr auto hK=100.0;
64
+ static constexpr auto hN=100.0;
65
+ static constexpr auto hPa=100.0;
66
+ static constexpr auto hW=100.0;
67
+ static constexpr auto hg=0.1;
68
+ static constexpr auto hm=100.0;
69
+ static constexpr auto hmol=100.0;
70
+ static constexpr auto hs=100.0;
71
+ static constexpr auto kJ=1000.0;
72
+ static constexpr auto kK=1000.0;
73
+ static constexpr auto kN=1000.0;
74
+ static constexpr auto kPa=1000.0;
75
+ static constexpr auto kW=1000.0;
76
+ static constexpr auto kg=1.0;
77
+ static constexpr auto km=1000.0;
78
+ static constexpr auto kmol=1000.0;
79
+ static constexpr auto ks=1000.0;
80
+ static constexpr auto m=1.0;
81
+ static constexpr auto mJ=0.001;
82
+ static constexpr auto mK=0.001;
83
+ static constexpr auto mN=0.001;
84
+ static constexpr auto mPa=0.001;
85
+ static constexpr auto mW=0.001;
86
+ static constexpr auto mg=1e-06;
87
+ static constexpr auto mm=0.001;
88
+ static constexpr auto mmol=0.001;
89
+ static constexpr auto mol=1.0;
90
+ static constexpr auto ms=0.001;
91
+ static constexpr auto nJ=1e-09;
92
+ static constexpr auto nK=1e-09;
93
+ static constexpr auto nN=1e-09;
94
+ static constexpr auto nPa=1e-09;
95
+ static constexpr auto nW=1e-09;
96
+ static constexpr auto ng=1.0000000000000002e-12;
97
+ static constexpr auto nm=1e-09;
98
+ static constexpr auto nmol=1e-09;
99
+ static constexpr auto ns=1e-09;
100
+ static constexpr auto pJ=1e-12;
101
+ static constexpr auto pK=1e-12;
102
+ static constexpr auto pN=1e-12;
103
+ static constexpr auto pPa=1e-12;
104
+ static constexpr auto pW=1e-12;
105
+ static constexpr auto pg=1e-15;
106
+ static constexpr auto pm=1e-12;
107
+ static constexpr auto pmol=1e-12;
108
+ static constexpr auto ps=1e-12;
109
+ static constexpr auto s=1.0;
110
+ static constexpr auto uJ=1e-06;
111
+ static constexpr auto uK=1e-06;
112
+ static constexpr auto uN=1e-06;
113
+ static constexpr auto uPa=1e-06;
114
+ static constexpr auto uW=1e-06;
115
+ static constexpr auto ug=1e-09;
116
+ static constexpr auto um=1e-06;
117
+ static constexpr auto umol=1e-06;
118
+ static constexpr auto us=1e-06;};