musica 0.12.2__cp311-cp311-manylinux_2_26_i686.manylinux_2_28_i686.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.
Potentially problematic release.
This version of musica might be problematic. Click here for more details.
- musica/CMakeLists.txt +68 -0
- musica/__init__.py +11 -0
- musica/_musica.cpython-311-i386-linux-gnu.so +0 -0
- musica/_version.py +1 -0
- musica/backend.py +41 -0
- musica/binding_common.cpp +33 -0
- musica/binding_common.hpp +7 -0
- musica/carma.cpp +911 -0
- musica/carma.py +1729 -0
- musica/constants.py +3 -0
- musica/cpu_binding.cpp +11 -0
- musica/cuda.cpp +12 -0
- musica/cuda.py +13 -0
- musica/examples/__init__.py +1 -0
- musica/examples/carma_aluminum.py +124 -0
- musica/examples/carma_sulfate.py +246 -0
- musica/examples/examples.py +165 -0
- musica/examples/sulfate_box_model.py +439 -0
- musica/examples/ts1_latin_hypercube.py +245 -0
- musica/gpu_binding.cpp +11 -0
- musica/main.py +89 -0
- musica/mechanism_configuration/__init__.py +1 -0
- musica/mechanism_configuration/aqueous_equilibrium.py +274 -0
- musica/mechanism_configuration/arrhenius.py +307 -0
- musica/mechanism_configuration/branched.py +299 -0
- musica/mechanism_configuration/condensed_phase_arrhenius.py +309 -0
- musica/mechanism_configuration/condensed_phase_photolysis.py +88 -0
- musica/mechanism_configuration/emission.py +71 -0
- musica/mechanism_configuration/first_order_loss.py +174 -0
- musica/mechanism_configuration/henrys_law.py +44 -0
- musica/mechanism_configuration/mechanism_configuration.py +234 -0
- musica/mechanism_configuration/phase.py +47 -0
- musica/mechanism_configuration/photolysis.py +88 -0
- musica/mechanism_configuration/reactions.py +73 -0
- musica/mechanism_configuration/simpol_phase_transfer.py +217 -0
- musica/mechanism_configuration/species.py +91 -0
- musica/mechanism_configuration/surface.py +94 -0
- musica/mechanism_configuration/ternary_chemical_activation.py +352 -0
- musica/mechanism_configuration/troe.py +352 -0
- musica/mechanism_configuration/tunneling.py +250 -0
- musica/mechanism_configuration/user_defined.py +88 -0
- musica/mechanism_configuration/utils.py +10 -0
- musica/mechanism_configuration/wet_deposition.py +52 -0
- musica/mechanism_configuration.cpp +607 -0
- musica/musica.cpp +201 -0
- musica/test/examples/v1/full_configuration/full_configuration.json +466 -0
- musica/test/examples/v1/full_configuration/full_configuration.yaml +295 -0
- musica/test/integration/test_analytical.py +324 -0
- musica/test/integration/test_carma.py +227 -0
- musica/test/integration/test_carma_aluminum.py +12 -0
- musica/test/integration/test_carma_sulfate.py +17 -0
- musica/test/integration/test_chapman.py +139 -0
- musica/test/integration/test_sulfate_box_model.py +34 -0
- musica/test/integration/test_tuvx.py +62 -0
- musica/test/unit/test_parser.py +64 -0
- musica/test/unit/test_serializer.py +69 -0
- musica/test/unit/test_state.py +325 -0
- musica/test/unit/test_util_full_mechanism.py +698 -0
- musica/tools/prepare_build_environment_linux.sh +32 -0
- musica/tools/prepare_build_environment_macos.sh +1 -0
- musica/tools/repair_wheel_gpu.sh +40 -0
- musica/tuvx.cpp +93 -0
- musica/tuvx.py +199 -0
- musica/types.py +407 -0
- musica-0.12.2.dist-info/METADATA +473 -0
- musica-0.12.2.dist-info/RECORD +70 -0
- musica-0.12.2.dist-info/WHEEL +6 -0
- musica-0.12.2.dist-info/entry_points.txt +3 -0
- musica-0.12.2.dist-info/licenses/AUTHORS.md +59 -0
- musica-0.12.2.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def _remove_empty_keys(dictionary: Dict) -> Dict:
|
|
5
|
+
return {k: v for k, v in dictionary.items() if v is not None and v != "" and v != [] and v != {}}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _add_other_properties(serialize_dict: Dict, other_properties: Dict) -> None:
|
|
9
|
+
for key in other_properties:
|
|
10
|
+
serialize_dict[key] = other_properties[key]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict
|
|
2
|
+
from .. import backend
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .utils import _add_other_properties
|
|
5
|
+
|
|
6
|
+
_backend = backend.get_backend()
|
|
7
|
+
_WetDeposition = _backend._mechanism_configuration._WetDeposition
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class WetDeposition(_WetDeposition):
|
|
11
|
+
"""
|
|
12
|
+
A class representing a wet deposition reaction rate constant.
|
|
13
|
+
|
|
14
|
+
Attributes:
|
|
15
|
+
name (str): The name of the wet deposition reaction rate constant.
|
|
16
|
+
scaling_factor (float): The scaling factor for the wet deposition rate constant.
|
|
17
|
+
condensed_phase (Phase): The condensed phase which undergoes wet deposition.
|
|
18
|
+
unknown_properties (Dict[str, Any]): A dictionary of other properties of the wet deposition reaction rate constant.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
name: Optional[str] = None,
|
|
24
|
+
scaling_factor: Optional[float] = None,
|
|
25
|
+
condensed_phase: Optional[Phase] = None,
|
|
26
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
27
|
+
):
|
|
28
|
+
"""
|
|
29
|
+
Initializes the WetDeposition object with the given parameters.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
name (str): The name of the wet deposition reaction rate constant.
|
|
33
|
+
scaling_factor (float): The scaling factor for the wet deposition rate constant.
|
|
34
|
+
condensed_phase (Phase): The condensed phase which undergoes wet deposition.
|
|
35
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the wet deposition reaction rate constant.
|
|
36
|
+
"""
|
|
37
|
+
super().__init__()
|
|
38
|
+
self.name = name if name is not None else self.name
|
|
39
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
40
|
+
self.condensed_phase = condensed_phase.name if condensed_phase is not None else self.condensed_phase
|
|
41
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
42
|
+
|
|
43
|
+
@staticmethod
|
|
44
|
+
def serialize(instance) -> Dict:
|
|
45
|
+
serialize_dict = {
|
|
46
|
+
"type": "WET_DEPOSITION",
|
|
47
|
+
"name": instance.name,
|
|
48
|
+
"scaling factor": instance.scaling_factor,
|
|
49
|
+
"condensed phase": instance.condensed_phase,
|
|
50
|
+
}
|
|
51
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
52
|
+
return serialize_dict
|
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
// Copyright (C) 2025 University Corporation for Atmospheric Research
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#include <musica/micm/parse.hpp>
|
|
4
|
+
|
|
5
|
+
#include <mechanism_configuration/constants.hpp>
|
|
6
|
+
#include <mechanism_configuration/v1/parser.hpp>
|
|
7
|
+
#include <mechanism_configuration/v1/reaction_types.hpp>
|
|
8
|
+
#include <mechanism_configuration/v1/types.hpp>
|
|
9
|
+
#include <mechanism_configuration/v1/validation.hpp>
|
|
10
|
+
#include <pybind11/pybind11.h>
|
|
11
|
+
#include <pybind11/stl.h>
|
|
12
|
+
|
|
13
|
+
#include <variant>
|
|
14
|
+
|
|
15
|
+
namespace py = pybind11;
|
|
16
|
+
namespace constants = mechanism_configuration::constants;
|
|
17
|
+
namespace validation = mechanism_configuration::v1::validation;
|
|
18
|
+
using namespace mechanism_configuration::v1::types;
|
|
19
|
+
|
|
20
|
+
enum class ReactionType
|
|
21
|
+
{
|
|
22
|
+
Arrhenius,
|
|
23
|
+
Branched,
|
|
24
|
+
CondensedPhaseArrhenius,
|
|
25
|
+
CondensedPhasePhotolysis,
|
|
26
|
+
Emission,
|
|
27
|
+
FirstOrderLoss,
|
|
28
|
+
SimpolPhaseTransfer,
|
|
29
|
+
AqueousEquilibrium,
|
|
30
|
+
WetDeposition,
|
|
31
|
+
HenrysLaw,
|
|
32
|
+
Photolysis,
|
|
33
|
+
Surface,
|
|
34
|
+
Troe,
|
|
35
|
+
TernaryChemicalActivation,
|
|
36
|
+
Tunneling,
|
|
37
|
+
UserDefined
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
struct ReactionsIterator
|
|
41
|
+
{
|
|
42
|
+
using VariantType = std::variant<
|
|
43
|
+
Arrhenius,
|
|
44
|
+
Branched,
|
|
45
|
+
CondensedPhaseArrhenius,
|
|
46
|
+
CondensedPhasePhotolysis,
|
|
47
|
+
Emission,
|
|
48
|
+
FirstOrderLoss,
|
|
49
|
+
SimpolPhaseTransfer,
|
|
50
|
+
AqueousEquilibrium,
|
|
51
|
+
WetDeposition,
|
|
52
|
+
HenrysLaw,
|
|
53
|
+
Photolysis,
|
|
54
|
+
Surface,
|
|
55
|
+
Troe,
|
|
56
|
+
TernaryChemicalActivation,
|
|
57
|
+
Tunneling,
|
|
58
|
+
UserDefined>;
|
|
59
|
+
|
|
60
|
+
std::vector<std::vector<VariantType>> reaction_lists;
|
|
61
|
+
size_t outer_index = 0;
|
|
62
|
+
size_t inner_index = 0;
|
|
63
|
+
|
|
64
|
+
ReactionsIterator(Reactions &reactions)
|
|
65
|
+
: reaction_lists{
|
|
66
|
+
std::vector<VariantType>(reactions.arrhenius.begin(), reactions.arrhenius.end()),
|
|
67
|
+
std::vector<VariantType>(reactions.branched.begin(), reactions.branched.end()),
|
|
68
|
+
std::vector<VariantType>(reactions.condensed_phase_arrhenius.begin(), reactions.condensed_phase_arrhenius.end()),
|
|
69
|
+
std::vector<VariantType>(reactions.condensed_phase_photolysis.begin(), reactions.condensed_phase_photolysis.end()),
|
|
70
|
+
std::vector<VariantType>(reactions.emission.begin(), reactions.emission.end()),
|
|
71
|
+
std::vector<VariantType>(reactions.first_order_loss.begin(), reactions.first_order_loss.end()),
|
|
72
|
+
std::vector<VariantType>(reactions.simpol_phase_transfer.begin(), reactions.simpol_phase_transfer.end()),
|
|
73
|
+
std::vector<VariantType>(reactions.aqueous_equilibrium.begin(), reactions.aqueous_equilibrium.end()),
|
|
74
|
+
std::vector<VariantType>(reactions.wet_deposition.begin(), reactions.wet_deposition.end()),
|
|
75
|
+
std::vector<VariantType>(reactions.henrys_law.begin(), reactions.henrys_law.end()),
|
|
76
|
+
std::vector<VariantType>(reactions.photolysis.begin(), reactions.photolysis.end()),
|
|
77
|
+
std::vector<VariantType>(reactions.surface.begin(), reactions.surface.end()),
|
|
78
|
+
std::vector<VariantType>(reactions.troe.begin(), reactions.troe.end()),
|
|
79
|
+
std::vector<VariantType>(
|
|
80
|
+
reactions.ternary_chemical_activation.begin(),
|
|
81
|
+
reactions.ternary_chemical_activation.end()),
|
|
82
|
+
std::vector<VariantType>(reactions.tunneling.begin(), reactions.tunneling.end()),
|
|
83
|
+
std::vector<VariantType>(reactions.user_defined.begin(), reactions.user_defined.end())
|
|
84
|
+
}
|
|
85
|
+
{
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
py::object next()
|
|
89
|
+
{
|
|
90
|
+
while (outer_index < reaction_lists.size())
|
|
91
|
+
{
|
|
92
|
+
const auto &vec = reaction_lists[outer_index];
|
|
93
|
+
if (inner_index < vec.size())
|
|
94
|
+
{
|
|
95
|
+
return std::visit([](auto &&arg) { return py::cast(arg); }, vec[inner_index++]);
|
|
96
|
+
}
|
|
97
|
+
++outer_index;
|
|
98
|
+
inner_index = 0;
|
|
99
|
+
}
|
|
100
|
+
throw py::stop_iteration();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
std::vector<ReactionComponent> get_reaction_components(const py::list &components)
|
|
105
|
+
{
|
|
106
|
+
std::vector<ReactionComponent> reaction_components;
|
|
107
|
+
for (const auto &item : components)
|
|
108
|
+
{
|
|
109
|
+
if (py::isinstance<Species>(item))
|
|
110
|
+
{
|
|
111
|
+
ReactionComponent component;
|
|
112
|
+
component.species_name = item.cast<Species>().name;
|
|
113
|
+
reaction_components.push_back(component);
|
|
114
|
+
}
|
|
115
|
+
else if (py::isinstance<py::tuple>(item) && py::len(item.cast<py::tuple>()) == 2)
|
|
116
|
+
{
|
|
117
|
+
auto item_tuple = item.cast<py::tuple>();
|
|
118
|
+
if (py::isinstance<py::float_>(item_tuple[0]) && py::isinstance<Species>(item_tuple[1]))
|
|
119
|
+
{
|
|
120
|
+
ReactionComponent component;
|
|
121
|
+
component.species_name = item_tuple[1].cast<Species>().name;
|
|
122
|
+
component.coefficient = item_tuple[0].cast<double>();
|
|
123
|
+
reaction_components.push_back(component);
|
|
124
|
+
}
|
|
125
|
+
else if (py::isinstance<py::int_>(item_tuple[0]) && py::isinstance<Species>(item_tuple[1]))
|
|
126
|
+
{
|
|
127
|
+
ReactionComponent component;
|
|
128
|
+
component.species_name = item_tuple[1].cast<Species>().name;
|
|
129
|
+
component.coefficient = item_tuple[0].cast<int>();
|
|
130
|
+
reaction_components.push_back(component);
|
|
131
|
+
}
|
|
132
|
+
else
|
|
133
|
+
{
|
|
134
|
+
throw py::value_error("Invalid tuple format. Expected (float, Species).");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
{
|
|
139
|
+
throw py::value_error("Invalid type for reactant. Expected a Species or a tuple of (float, Species).");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
std::unordered_set<std::string> component_names;
|
|
143
|
+
for (const auto &component : reaction_components)
|
|
144
|
+
{
|
|
145
|
+
if (!component_names.insert(component.species_name).second)
|
|
146
|
+
{
|
|
147
|
+
throw py::value_error("Duplicate reaction component name found: " + component.species_name);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return reaction_components;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
Reactions create_reactions(const py::list &reactions)
|
|
154
|
+
{
|
|
155
|
+
Reactions reaction_obj;
|
|
156
|
+
for (const auto &item : reactions)
|
|
157
|
+
{
|
|
158
|
+
if (py::isinstance<Arrhenius>(item))
|
|
159
|
+
{
|
|
160
|
+
reaction_obj.arrhenius.push_back(item.cast<Arrhenius>());
|
|
161
|
+
}
|
|
162
|
+
else if (py::isinstance<Branched>(item))
|
|
163
|
+
{
|
|
164
|
+
reaction_obj.branched.push_back(item.cast<Branched>());
|
|
165
|
+
}
|
|
166
|
+
else if (py::isinstance<CondensedPhaseArrhenius>(item))
|
|
167
|
+
{
|
|
168
|
+
reaction_obj.condensed_phase_arrhenius.push_back(item.cast<CondensedPhaseArrhenius>());
|
|
169
|
+
}
|
|
170
|
+
else if (py::isinstance<CondensedPhasePhotolysis>(item))
|
|
171
|
+
{
|
|
172
|
+
reaction_obj.condensed_phase_photolysis.push_back(item.cast<CondensedPhasePhotolysis>());
|
|
173
|
+
}
|
|
174
|
+
else if (py::isinstance<Emission>(item))
|
|
175
|
+
{
|
|
176
|
+
reaction_obj.emission.push_back(item.cast<Emission>());
|
|
177
|
+
}
|
|
178
|
+
else if (py::isinstance<FirstOrderLoss>(item))
|
|
179
|
+
{
|
|
180
|
+
reaction_obj.first_order_loss.push_back(item.cast<FirstOrderLoss>());
|
|
181
|
+
}
|
|
182
|
+
else if (py::isinstance<SimpolPhaseTransfer>(item))
|
|
183
|
+
{
|
|
184
|
+
reaction_obj.simpol_phase_transfer.push_back(item.cast<SimpolPhaseTransfer>());
|
|
185
|
+
}
|
|
186
|
+
else if (py::isinstance<AqueousEquilibrium>(item))
|
|
187
|
+
{
|
|
188
|
+
reaction_obj.aqueous_equilibrium.push_back(item.cast<AqueousEquilibrium>());
|
|
189
|
+
}
|
|
190
|
+
else if (py::isinstance<WetDeposition>(item))
|
|
191
|
+
{
|
|
192
|
+
reaction_obj.wet_deposition.push_back(item.cast<WetDeposition>());
|
|
193
|
+
}
|
|
194
|
+
else if (py::isinstance<HenrysLaw>(item))
|
|
195
|
+
{
|
|
196
|
+
reaction_obj.henrys_law.push_back(item.cast<HenrysLaw>());
|
|
197
|
+
}
|
|
198
|
+
else if (py::isinstance<Photolysis>(item))
|
|
199
|
+
{
|
|
200
|
+
reaction_obj.photolysis.push_back(item.cast<Photolysis>());
|
|
201
|
+
}
|
|
202
|
+
else if (py::isinstance<Surface>(item))
|
|
203
|
+
{
|
|
204
|
+
reaction_obj.surface.push_back(item.cast<Surface>());
|
|
205
|
+
}
|
|
206
|
+
else if (py::isinstance<Troe>(item))
|
|
207
|
+
{
|
|
208
|
+
reaction_obj.troe.push_back(item.cast<Troe>());
|
|
209
|
+
}
|
|
210
|
+
else if (py::isinstance<TernaryChemicalActivation>(item))
|
|
211
|
+
{
|
|
212
|
+
reaction_obj.ternary_chemical_activation.push_back(item.cast<TernaryChemicalActivation>());
|
|
213
|
+
}
|
|
214
|
+
else if (py::isinstance<Tunneling>(item))
|
|
215
|
+
{
|
|
216
|
+
reaction_obj.tunneling.push_back(item.cast<Tunneling>());
|
|
217
|
+
}
|
|
218
|
+
else if (py::isinstance<UserDefined>(item))
|
|
219
|
+
{
|
|
220
|
+
reaction_obj.user_defined.push_back(item.cast<UserDefined>());
|
|
221
|
+
}
|
|
222
|
+
else
|
|
223
|
+
{
|
|
224
|
+
throw py::value_error("Invalid reaction type.");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return reaction_obj;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
void bind_mechanism_configuration(py::module_ &mechanism_configuration)
|
|
231
|
+
{
|
|
232
|
+
py::enum_<ReactionType>(mechanism_configuration, "_ReactionType")
|
|
233
|
+
.value("Arrhenius", ReactionType::Arrhenius)
|
|
234
|
+
.value("Branched", ReactionType::Branched)
|
|
235
|
+
.value("CondensedPhaseArrhenius", ReactionType::CondensedPhaseArrhenius)
|
|
236
|
+
.value("CondensedPhasePhotolysis", ReactionType::CondensedPhasePhotolysis)
|
|
237
|
+
.value("Emission", ReactionType::Emission)
|
|
238
|
+
.value("FirstOrderLoss", ReactionType::FirstOrderLoss)
|
|
239
|
+
.value("SimpolPhaseTransfer", ReactionType::SimpolPhaseTransfer)
|
|
240
|
+
.value("AqueousEquilibrium", ReactionType::AqueousEquilibrium)
|
|
241
|
+
.value("WetDeposition", ReactionType::WetDeposition)
|
|
242
|
+
.value("HenrysLaw", ReactionType::HenrysLaw)
|
|
243
|
+
.value("Photolysis", ReactionType::Photolysis)
|
|
244
|
+
.value("Surface", ReactionType::Surface)
|
|
245
|
+
.value("Troe", ReactionType::Troe)
|
|
246
|
+
.value("TernaryChemicalActivation", ReactionType::TernaryChemicalActivation)
|
|
247
|
+
.value("Tunneling", ReactionType::Tunneling)
|
|
248
|
+
.value("UserDefined", ReactionType::UserDefined);
|
|
249
|
+
|
|
250
|
+
py::class_<Species>(mechanism_configuration, "_Species")
|
|
251
|
+
.def(py::init<>())
|
|
252
|
+
.def_readwrite("name", &Species::name)
|
|
253
|
+
.def_readwrite("absolute_tolerance", &Species::absolute_tolerance)
|
|
254
|
+
.def_readwrite("diffusion_coefficient_m2_s", &Species::diffusion_coefficient)
|
|
255
|
+
.def_readwrite("molecular_weight_kg_mol", &Species::molecular_weight)
|
|
256
|
+
.def_readwrite("HLC_298K_mol_m3_Pa", &Species::henrys_law_constant_298)
|
|
257
|
+
.def_readwrite("HLC_exponential_factor_K", &Species::henrys_law_constant_exponential_factor)
|
|
258
|
+
.def_readwrite("N_star", &Species::n_star)
|
|
259
|
+
.def_readwrite("density_kg_m3", &Species::density)
|
|
260
|
+
.def_readwrite("tracer_type", &Species::tracer_type)
|
|
261
|
+
.def_readwrite("constant_concentration_mol_m3", &Species::constant_concentration)
|
|
262
|
+
.def_readwrite("constant_mixing_ratio_mol_mol", &Species::constant_mixing_ratio)
|
|
263
|
+
.def_readwrite("is_third_body", &Species::is_third_body)
|
|
264
|
+
.def_readwrite("other_properties", &Species::unknown_properties)
|
|
265
|
+
.def("__str__", [](const Species &s) { return s.name; })
|
|
266
|
+
.def("__repr__", [](const Species &s) { return "<Species: " + s.name + ">"; });
|
|
267
|
+
|
|
268
|
+
py::class_<Phase>(mechanism_configuration, "_Phase")
|
|
269
|
+
.def(py::init<>())
|
|
270
|
+
.def_readwrite("name", &Phase::name)
|
|
271
|
+
.def_readwrite("species", &Phase::species)
|
|
272
|
+
.def_readwrite("other_properties", &Phase::unknown_properties)
|
|
273
|
+
.def("__str__", [](const Phase &p) { return p.name; })
|
|
274
|
+
.def("__repr__", [](const Phase &p) { return "<Phase: " + p.name + ">"; });
|
|
275
|
+
|
|
276
|
+
py::class_<ReactionComponent>(mechanism_configuration, "_ReactionComponent")
|
|
277
|
+
.def(py::init<>())
|
|
278
|
+
.def(py::init(
|
|
279
|
+
[](const std::string &species_name)
|
|
280
|
+
{
|
|
281
|
+
ReactionComponent rc;
|
|
282
|
+
rc.species_name = species_name;
|
|
283
|
+
return rc;
|
|
284
|
+
}))
|
|
285
|
+
.def(py::init(
|
|
286
|
+
[](const std::string &species_name, double coefficient)
|
|
287
|
+
{
|
|
288
|
+
ReactionComponent rc;
|
|
289
|
+
rc.species_name = species_name;
|
|
290
|
+
rc.coefficient = coefficient;
|
|
291
|
+
return rc;
|
|
292
|
+
}))
|
|
293
|
+
.def_readwrite("species_name", &ReactionComponent::species_name)
|
|
294
|
+
.def_readwrite("coefficient", &ReactionComponent::coefficient)
|
|
295
|
+
.def_readwrite("other_properties", &ReactionComponent::unknown_properties)
|
|
296
|
+
.def("__str__", [](const ReactionComponent &rc) { return rc.species_name; })
|
|
297
|
+
.def("__repr__", [](const ReactionComponent &rc) { return "<ReactionComponent: " + rc.species_name + ">"; });
|
|
298
|
+
|
|
299
|
+
py::class_<Arrhenius>(mechanism_configuration, "_Arrhenius")
|
|
300
|
+
.def(py::init<>())
|
|
301
|
+
.def_readwrite("A", &Arrhenius::A)
|
|
302
|
+
.def_readwrite("B", &Arrhenius::B)
|
|
303
|
+
.def_readwrite("C", &Arrhenius::C)
|
|
304
|
+
.def_readwrite("D", &Arrhenius::D)
|
|
305
|
+
.def_readwrite("E", &Arrhenius::E)
|
|
306
|
+
.def_readwrite("reactants", &Arrhenius::reactants)
|
|
307
|
+
.def_readwrite("products", &Arrhenius::products)
|
|
308
|
+
.def_readwrite("name", &Arrhenius::name)
|
|
309
|
+
.def_readwrite("gas_phase", &Arrhenius::gas_phase)
|
|
310
|
+
.def_readwrite("other_properties", &Arrhenius::unknown_properties)
|
|
311
|
+
.def("__str__", [](const Arrhenius &a) { return a.name; })
|
|
312
|
+
.def("__repr__", [](const Arrhenius &a) { return "<Arrhenius: " + a.name + ">"; })
|
|
313
|
+
.def_property_readonly("type", [](const Arrhenius &) { return ReactionType::Arrhenius; });
|
|
314
|
+
|
|
315
|
+
py::class_<CondensedPhaseArrhenius>(mechanism_configuration, "_CondensedPhaseArrhenius")
|
|
316
|
+
.def(py::init<>())
|
|
317
|
+
.def_readwrite("A", &CondensedPhaseArrhenius::A)
|
|
318
|
+
.def_readwrite("B", &CondensedPhaseArrhenius::B)
|
|
319
|
+
.def_readwrite("C", &CondensedPhaseArrhenius::C)
|
|
320
|
+
.def_readwrite("D", &CondensedPhaseArrhenius::D)
|
|
321
|
+
.def_readwrite("E", &CondensedPhaseArrhenius::E)
|
|
322
|
+
.def_readwrite("reactants", &CondensedPhaseArrhenius::reactants)
|
|
323
|
+
.def_readwrite("products", &CondensedPhaseArrhenius::products)
|
|
324
|
+
.def_readwrite("name", &CondensedPhaseArrhenius::name)
|
|
325
|
+
.def_readwrite("condensed_phase", &CondensedPhaseArrhenius::condensed_phase)
|
|
326
|
+
.def_readwrite("other_properties", &CondensedPhaseArrhenius::unknown_properties)
|
|
327
|
+
.def("__str__", [](const CondensedPhaseArrhenius &cpa) { return cpa.name; })
|
|
328
|
+
.def("__repr__", [](const CondensedPhaseArrhenius &cpa) { return "<CondensedPhaseArrhenius: " + cpa.name + ">"; })
|
|
329
|
+
.def_property_readonly("type", [](const CondensedPhaseArrhenius &) { return ReactionType::CondensedPhaseArrhenius; });
|
|
330
|
+
|
|
331
|
+
py::class_<Troe>(mechanism_configuration, "_Troe")
|
|
332
|
+
.def(py::init<>())
|
|
333
|
+
.def_readwrite("k0_A", &Troe::k0_A)
|
|
334
|
+
.def_readwrite("k0_B", &Troe::k0_B)
|
|
335
|
+
.def_readwrite("k0_C", &Troe::k0_C)
|
|
336
|
+
.def_readwrite("kinf_A", &Troe::kinf_A)
|
|
337
|
+
.def_readwrite("kinf_B", &Troe::kinf_B)
|
|
338
|
+
.def_readwrite("kinf_C", &Troe::kinf_C)
|
|
339
|
+
.def_readwrite("Fc", &Troe::Fc)
|
|
340
|
+
.def_readwrite("N", &Troe::N)
|
|
341
|
+
.def_readwrite("reactants", &Troe::reactants)
|
|
342
|
+
.def_readwrite("products", &Troe::products)
|
|
343
|
+
.def_readwrite("name", &Troe::name)
|
|
344
|
+
.def_readwrite("gas_phase", &Troe::gas_phase)
|
|
345
|
+
.def_readwrite("other_properties", &Troe::unknown_properties)
|
|
346
|
+
.def("__str__", [](const Troe &t) { return t.name; })
|
|
347
|
+
.def("__repr__", [](const Troe &t) { return "<Troe: " + t.name + ">"; })
|
|
348
|
+
.def_property_readonly("type", [](const Troe &) { return ReactionType::Troe; });
|
|
349
|
+
|
|
350
|
+
py::class_<TernaryChemicalActivation>(mechanism_configuration, "_TernaryChemicalActivation")
|
|
351
|
+
.def(py::init<>())
|
|
352
|
+
.def_readwrite("k0_A", &TernaryChemicalActivation::k0_A)
|
|
353
|
+
.def_readwrite("k0_B", &TernaryChemicalActivation::k0_B)
|
|
354
|
+
.def_readwrite("k0_C", &TernaryChemicalActivation::k0_C)
|
|
355
|
+
.def_readwrite("kinf_A", &TernaryChemicalActivation::kinf_A)
|
|
356
|
+
.def_readwrite("kinf_B", &TernaryChemicalActivation::kinf_B)
|
|
357
|
+
.def_readwrite("kinf_C", &TernaryChemicalActivation::kinf_C)
|
|
358
|
+
.def_readwrite("Fc", &TernaryChemicalActivation::Fc)
|
|
359
|
+
.def_readwrite("N", &TernaryChemicalActivation::N)
|
|
360
|
+
.def_readwrite("reactants", &TernaryChemicalActivation::reactants)
|
|
361
|
+
.def_readwrite("products", &TernaryChemicalActivation::products)
|
|
362
|
+
.def_readwrite("name", &TernaryChemicalActivation::name)
|
|
363
|
+
.def_readwrite("gas_phase", &TernaryChemicalActivation::gas_phase)
|
|
364
|
+
.def_readwrite("other_properties", &TernaryChemicalActivation::unknown_properties)
|
|
365
|
+
.def("__str__", [](const TernaryChemicalActivation &t) { return t.name; })
|
|
366
|
+
.def("__repr__", [](const TernaryChemicalActivation &t) { return "<TernaryChemicalActivation: " + t.name + ">"; })
|
|
367
|
+
.def_property_readonly(
|
|
368
|
+
"type", [](const TernaryChemicalActivation &) { return ReactionType::TernaryChemicalActivation; });
|
|
369
|
+
|
|
370
|
+
py::class_<Branched>(mechanism_configuration, "_Branched")
|
|
371
|
+
.def(py::init<>())
|
|
372
|
+
.def_readwrite("X", &Branched::X)
|
|
373
|
+
.def_readwrite("Y", &Branched::Y)
|
|
374
|
+
.def_readwrite("a0", &Branched::a0)
|
|
375
|
+
.def_readwrite("n", &Branched::n)
|
|
376
|
+
.def_readwrite("reactants", &Branched::reactants)
|
|
377
|
+
.def_readwrite("nitrate_products", &Branched::nitrate_products)
|
|
378
|
+
.def_readwrite("alkoxy_products", &Branched::alkoxy_products)
|
|
379
|
+
.def_readwrite("name", &Branched::name)
|
|
380
|
+
.def_readwrite("gas_phase", &Branched::gas_phase)
|
|
381
|
+
.def_readwrite("other_properties", &Branched::unknown_properties)
|
|
382
|
+
.def("__str__", [](const Branched &b) { return b.name; })
|
|
383
|
+
.def("__repr__", [](const Branched &b) { return "<Branched: " + b.name + ">"; })
|
|
384
|
+
.def_property_readonly("type", [](const Branched &) { return ReactionType::Branched; });
|
|
385
|
+
|
|
386
|
+
py::class_<Tunneling>(mechanism_configuration, "_Tunneling")
|
|
387
|
+
.def(py::init<>())
|
|
388
|
+
.def_readwrite("A", &Tunneling::A)
|
|
389
|
+
.def_readwrite("B", &Tunneling::B)
|
|
390
|
+
.def_readwrite("C", &Tunneling::C)
|
|
391
|
+
.def_readwrite("reactants", &Tunneling::reactants)
|
|
392
|
+
.def_readwrite("products", &Tunneling::products)
|
|
393
|
+
.def_readwrite("name", &Tunneling::name)
|
|
394
|
+
.def_readwrite("gas_phase", &Tunneling::gas_phase)
|
|
395
|
+
.def_readwrite("other_properties", &Tunneling::unknown_properties)
|
|
396
|
+
.def("__str__", [](const Tunneling &t) { return t.name; })
|
|
397
|
+
.def("__repr__", [](const Tunneling &t) { return "<Tunneling: " + t.name + ">"; })
|
|
398
|
+
.def_property_readonly("type", [](const Tunneling &) { return ReactionType::Tunneling; });
|
|
399
|
+
|
|
400
|
+
py::class_<Surface>(mechanism_configuration, "_Surface")
|
|
401
|
+
.def(py::init<>())
|
|
402
|
+
.def_readwrite("reaction_probability", &Surface::reaction_probability)
|
|
403
|
+
.def_readwrite("gas_phase_species", &Surface::gas_phase_species)
|
|
404
|
+
.def_readwrite("gas_phase_products", &Surface::gas_phase_products)
|
|
405
|
+
.def_readwrite("name", &Surface::name)
|
|
406
|
+
.def_readwrite("gas_phase", &Surface::gas_phase)
|
|
407
|
+
.def_readwrite("condensed_phase", &Surface::condensed_phase)
|
|
408
|
+
.def_readwrite("other_properties", &Surface::unknown_properties)
|
|
409
|
+
.def("__str__", [](const Surface &s) { return s.name; })
|
|
410
|
+
.def("__repr__", [](const Surface &s) { return "<Surface: " + s.name + ">"; })
|
|
411
|
+
.def_property_readonly("type", [](const Surface &) { return ReactionType::Surface; });
|
|
412
|
+
|
|
413
|
+
py::class_<Photolysis>(mechanism_configuration, "_Photolysis")
|
|
414
|
+
.def(py::init<>())
|
|
415
|
+
.def_readwrite("scaling_factor", &Photolysis::scaling_factor)
|
|
416
|
+
.def_readwrite("reactants", &Photolysis::reactants)
|
|
417
|
+
.def_readwrite("products", &Photolysis::products)
|
|
418
|
+
.def_readwrite("name", &Photolysis::name)
|
|
419
|
+
.def_readwrite("gas_phase", &Photolysis::gas_phase)
|
|
420
|
+
.def_readwrite("other_properties", &Photolysis::unknown_properties)
|
|
421
|
+
.def("__str__", [](const Photolysis &p) { return p.name; })
|
|
422
|
+
.def("__repr__", [](const Photolysis &p) { return "<Photolysis: " + p.name + ">"; })
|
|
423
|
+
.def_property_readonly("type", [](const Photolysis &) { return ReactionType::Photolysis; });
|
|
424
|
+
|
|
425
|
+
py::class_<CondensedPhasePhotolysis>(mechanism_configuration, "_CondensedPhasePhotolysis")
|
|
426
|
+
.def(py::init<>())
|
|
427
|
+
.def_readwrite("scaling_factor", &CondensedPhasePhotolysis::scaling_factor)
|
|
428
|
+
.def_readwrite("reactants", &CondensedPhasePhotolysis::reactants)
|
|
429
|
+
.def_readwrite("products", &CondensedPhasePhotolysis::products)
|
|
430
|
+
.def_readwrite("name", &CondensedPhasePhotolysis::name)
|
|
431
|
+
.def_readwrite("condensed_phase", &CondensedPhasePhotolysis::condensed_phase)
|
|
432
|
+
.def_readwrite("other_properties", &CondensedPhasePhotolysis::unknown_properties)
|
|
433
|
+
.def("__str__", [](const CondensedPhasePhotolysis &cpp) { return cpp.name; })
|
|
434
|
+
.def("__repr__", [](const CondensedPhasePhotolysis &cpp) { return "<CondensedPhasePhotolysis: " + cpp.name + ">"; })
|
|
435
|
+
.def_property_readonly(
|
|
436
|
+
"type", [](const CondensedPhasePhotolysis &) { return ReactionType::CondensedPhasePhotolysis; });
|
|
437
|
+
|
|
438
|
+
py::class_<Emission>(mechanism_configuration, "_Emission")
|
|
439
|
+
.def(py::init<>())
|
|
440
|
+
.def_readwrite("scaling_factor", &Emission::scaling_factor)
|
|
441
|
+
.def_readwrite("products", &Emission::products)
|
|
442
|
+
.def_readwrite("name", &Emission::name)
|
|
443
|
+
.def_readwrite("gas_phase", &Emission::gas_phase)
|
|
444
|
+
.def_readwrite("other_properties", &Emission::unknown_properties)
|
|
445
|
+
.def("__str__", [](const Emission &e) { return e.name; })
|
|
446
|
+
.def("__repr__", [](const Emission &e) { return "<Emission: " + e.name + ">"; })
|
|
447
|
+
.def_property_readonly("type", [](const Emission &) { return ReactionType::Emission; });
|
|
448
|
+
|
|
449
|
+
py::class_<FirstOrderLoss>(mechanism_configuration, "_FirstOrderLoss")
|
|
450
|
+
.def(py::init<>())
|
|
451
|
+
.def_readwrite("scaling_factor", &FirstOrderLoss::scaling_factor)
|
|
452
|
+
.def_readwrite("reactants", &FirstOrderLoss::reactants)
|
|
453
|
+
.def_readwrite("name", &FirstOrderLoss::name)
|
|
454
|
+
.def_readwrite("gas_phase", &FirstOrderLoss::gas_phase)
|
|
455
|
+
.def_readwrite("other_properties", &FirstOrderLoss::unknown_properties)
|
|
456
|
+
.def("__str__", [](const FirstOrderLoss &fol) { return fol.name; })
|
|
457
|
+
.def("__repr__", [](const FirstOrderLoss &fol) { return "<FirstOrderLoss: " + fol.name + ">"; })
|
|
458
|
+
.def_property_readonly("type", [](const FirstOrderLoss &) { return ReactionType::FirstOrderLoss; });
|
|
459
|
+
|
|
460
|
+
py::class_<AqueousEquilibrium>(mechanism_configuration, "_AqueousEquilibrium")
|
|
461
|
+
.def(py::init<>())
|
|
462
|
+
.def_readwrite("name", &AqueousEquilibrium::name)
|
|
463
|
+
.def_readwrite("condensed_phase", &AqueousEquilibrium::condensed_phase)
|
|
464
|
+
.def_readwrite("condensed_phase_water", &AqueousEquilibrium::condensed_phase_water)
|
|
465
|
+
.def_readwrite("reactants", &AqueousEquilibrium::reactants)
|
|
466
|
+
.def_readwrite("products", &AqueousEquilibrium::products)
|
|
467
|
+
.def_readwrite("A", &AqueousEquilibrium::A)
|
|
468
|
+
.def_readwrite("C", &AqueousEquilibrium::C)
|
|
469
|
+
.def_readwrite("k_reverse", &AqueousEquilibrium::k_reverse)
|
|
470
|
+
.def_readwrite("other_properties", &AqueousEquilibrium::unknown_properties)
|
|
471
|
+
.def("__str__", [](const AqueousEquilibrium &ae) { return ae.name; })
|
|
472
|
+
.def("__repr__", [](const AqueousEquilibrium &ae) { return "<AqueousEquilibrium: " + ae.name + ">"; })
|
|
473
|
+
.def_property_readonly("type", [](const AqueousEquilibrium &) { return ReactionType::AqueousEquilibrium; });
|
|
474
|
+
|
|
475
|
+
py::class_<WetDeposition>(mechanism_configuration, "_WetDeposition")
|
|
476
|
+
.def(py::init<>())
|
|
477
|
+
.def_readwrite("scaling_factor", &WetDeposition::scaling_factor)
|
|
478
|
+
.def_readwrite("name", &WetDeposition::name)
|
|
479
|
+
.def_readwrite("condensed_phase", &WetDeposition::condensed_phase)
|
|
480
|
+
.def_readwrite("other_properties", &WetDeposition::unknown_properties)
|
|
481
|
+
.def("__str__", [](const WetDeposition &wd) { return wd.name; })
|
|
482
|
+
.def("__repr__", [](const WetDeposition &wd) { return "<WetDeposition: " + wd.name + ">"; })
|
|
483
|
+
.def_property_readonly("type", [](const WetDeposition &) { return ReactionType::WetDeposition; });
|
|
484
|
+
|
|
485
|
+
py::class_<HenrysLaw>(mechanism_configuration, "_HenrysLaw")
|
|
486
|
+
.def(py::init<>())
|
|
487
|
+
.def_readwrite("name", &HenrysLaw::name)
|
|
488
|
+
.def_readwrite("other_properties", &HenrysLaw::unknown_properties)
|
|
489
|
+
.def("__str__", [](const HenrysLaw &hl) { return hl.name; })
|
|
490
|
+
.def("__repr__", [](const HenrysLaw &hl) { return "<HenrysLaw: " + hl.name + ">"; })
|
|
491
|
+
.def_property_readonly("type", [](const HenrysLaw &) { return ReactionType::HenrysLaw; });
|
|
492
|
+
|
|
493
|
+
py::class_<SimpolPhaseTransfer>(mechanism_configuration, "_SimpolPhaseTransfer")
|
|
494
|
+
.def(py::init<>())
|
|
495
|
+
.def_readwrite("gas_phase", &SimpolPhaseTransfer::gas_phase)
|
|
496
|
+
.def_readwrite("gas_phase_species", &SimpolPhaseTransfer::gas_phase_species)
|
|
497
|
+
.def_readwrite("condensed_phase", &SimpolPhaseTransfer::condensed_phase)
|
|
498
|
+
.def_readwrite("condensed_phase_species", &SimpolPhaseTransfer::condensed_phase_species)
|
|
499
|
+
.def_readwrite("name", &SimpolPhaseTransfer::name)
|
|
500
|
+
.def_readwrite("B", &SimpolPhaseTransfer::B)
|
|
501
|
+
.def_readwrite("other_properties", &SimpolPhaseTransfer::unknown_properties)
|
|
502
|
+
.def("__str__", [](const SimpolPhaseTransfer &spt) { return spt.name; })
|
|
503
|
+
.def("__repr__", [](const SimpolPhaseTransfer &spt) { return "<SimpolPhaseTransfer: " + spt.name + ">"; })
|
|
504
|
+
.def_property_readonly("type", [](const SimpolPhaseTransfer &) { return ReactionType::SimpolPhaseTransfer; });
|
|
505
|
+
|
|
506
|
+
py::class_<UserDefined>(mechanism_configuration, "_UserDefined")
|
|
507
|
+
.def(py::init<>())
|
|
508
|
+
.def_readwrite("scaling_factor", &UserDefined::scaling_factor)
|
|
509
|
+
.def_readwrite("reactants", &UserDefined::reactants)
|
|
510
|
+
.def_readwrite("products", &UserDefined::products)
|
|
511
|
+
.def_readwrite("name", &UserDefined::name)
|
|
512
|
+
.def_readwrite("gas_phase", &UserDefined::gas_phase)
|
|
513
|
+
.def_readwrite("other_properties", &UserDefined::unknown_properties)
|
|
514
|
+
.def("__str__", [](const UserDefined &p) { return p.name; })
|
|
515
|
+
.def("__repr__", [](const UserDefined &p) { return "<UserDefined: " + p.name + ">"; })
|
|
516
|
+
.def_property_readonly("type", [](const UserDefined &) { return ReactionType::UserDefined; });
|
|
517
|
+
|
|
518
|
+
py::class_<Reactions>(mechanism_configuration, "_Reactions")
|
|
519
|
+
.def(py::init<>())
|
|
520
|
+
.def(py::init([](const py::list &reactions) { return create_reactions(reactions); }))
|
|
521
|
+
.def_readwrite("arrhenius", &Reactions::arrhenius)
|
|
522
|
+
.def_readwrite("branched", &Reactions::branched)
|
|
523
|
+
.def_readwrite("condensed_phase_arrhenius", &Reactions::condensed_phase_arrhenius)
|
|
524
|
+
.def_readwrite("condensed_phase_photolysis", &Reactions::condensed_phase_photolysis)
|
|
525
|
+
.def_readwrite("emission", &Reactions::emission)
|
|
526
|
+
.def_readwrite("first_order_loss", &Reactions::first_order_loss)
|
|
527
|
+
.def_readwrite("simpol_phase_transfer", &Reactions::simpol_phase_transfer)
|
|
528
|
+
.def_readwrite("aqueous_equilibrium", &Reactions::aqueous_equilibrium)
|
|
529
|
+
.def_readwrite("wet_deposition", &Reactions::wet_deposition)
|
|
530
|
+
.def_readwrite("henrys_law", &Reactions::henrys_law)
|
|
531
|
+
.def_readwrite("photolysis", &Reactions::photolysis)
|
|
532
|
+
.def_readwrite("surface", &Reactions::surface)
|
|
533
|
+
.def_readwrite("troe", &Reactions::troe)
|
|
534
|
+
.def_readwrite("ternary_chemical_activation", &Reactions::ternary_chemical_activation)
|
|
535
|
+
.def_readwrite("tunneling", &Reactions::tunneling)
|
|
536
|
+
.def_readwrite("user_defined", &Reactions::user_defined)
|
|
537
|
+
.def(
|
|
538
|
+
"__len__",
|
|
539
|
+
[](const Reactions &r)
|
|
540
|
+
{
|
|
541
|
+
return r.arrhenius.size() + r.branched.size() + r.condensed_phase_arrhenius.size() +
|
|
542
|
+
r.condensed_phase_photolysis.size() + r.emission.size() + r.first_order_loss.size() +
|
|
543
|
+
r.simpol_phase_transfer.size() + r.aqueous_equilibrium.size() + r.wet_deposition.size() +
|
|
544
|
+
r.henrys_law.size() + r.photolysis.size() + r.surface.size() + r.troe.size() + r.tunneling.size() +
|
|
545
|
+
r.user_defined.size();
|
|
546
|
+
})
|
|
547
|
+
.def("__str__", [](const Reactions &r) { return "Reactions"; })
|
|
548
|
+
.def("__repr__", [](const Reactions &r) { return "<Reactions>"; })
|
|
549
|
+
.def("__iter__", [](Reactions &r) { return ReactionsIterator(r); });
|
|
550
|
+
|
|
551
|
+
py::class_<ReactionsIterator>(mechanism_configuration, "_ReactionsIterator")
|
|
552
|
+
.def("__iter__", [](ReactionsIterator &it) -> ReactionsIterator & { return it; })
|
|
553
|
+
.def("__next__", &ReactionsIterator::next);
|
|
554
|
+
|
|
555
|
+
py::class_<Mechanism>(mechanism_configuration, "_Mechanism")
|
|
556
|
+
.def(py::init<>())
|
|
557
|
+
.def_readwrite("name", &Mechanism::name)
|
|
558
|
+
.def_readwrite("species", &Mechanism::species)
|
|
559
|
+
.def_readwrite("phases", &Mechanism::phases)
|
|
560
|
+
.def_readwrite("reactions", &Mechanism::reactions)
|
|
561
|
+
.def_readwrite("version", &Mechanism::version)
|
|
562
|
+
.def("__str__", [](const Mechanism &m) { return m.name; })
|
|
563
|
+
.def("__repr__", [](const Mechanism &m) { return "<Mechanism: " + m.name + ">"; });
|
|
564
|
+
|
|
565
|
+
py::class_<mechanism_configuration::Version>(mechanism_configuration, "_Version")
|
|
566
|
+
.def(py::init<>())
|
|
567
|
+
.def(py::init<unsigned int, unsigned int, unsigned int>())
|
|
568
|
+
.def(py::init<std::string>())
|
|
569
|
+
.def_readwrite("major", &mechanism_configuration::Version::major)
|
|
570
|
+
.def_readwrite("minor", &mechanism_configuration::Version::minor)
|
|
571
|
+
.def_readwrite("patch", &mechanism_configuration::Version::patch)
|
|
572
|
+
.def("to_string", &mechanism_configuration::Version::to_string)
|
|
573
|
+
.def("__str__", &mechanism_configuration::Version::to_string)
|
|
574
|
+
.def("__repr__", [](const mechanism_configuration::Version &v) { return "<Version: " + v.to_string() + ">"; });
|
|
575
|
+
|
|
576
|
+
using V1Parser = mechanism_configuration::v1::Parser;
|
|
577
|
+
|
|
578
|
+
py::class_<V1Parser>(mechanism_configuration, "_Parser")
|
|
579
|
+
.def(py::init<>())
|
|
580
|
+
.def(
|
|
581
|
+
"parse",
|
|
582
|
+
[](V1Parser &self, const std::string &path)
|
|
583
|
+
{
|
|
584
|
+
auto parsed = self.Parse(std::filesystem::path(path));
|
|
585
|
+
if (parsed)
|
|
586
|
+
{
|
|
587
|
+
return *parsed;
|
|
588
|
+
}
|
|
589
|
+
else
|
|
590
|
+
{
|
|
591
|
+
std::string error = "Error parsing file: " + path + "\n";
|
|
592
|
+
for (auto &e : parsed.errors)
|
|
593
|
+
{
|
|
594
|
+
error += e.second + "\n";
|
|
595
|
+
}
|
|
596
|
+
throw std::runtime_error(error);
|
|
597
|
+
}
|
|
598
|
+
})
|
|
599
|
+
.def(
|
|
600
|
+
"parse_and_convert_v0",
|
|
601
|
+
[](V1Parser &self, const std::string &path)
|
|
602
|
+
{
|
|
603
|
+
mechanism_configuration::v1::types::Mechanism mechanism = musica::ConvertV0MechanismToV1(path);
|
|
604
|
+
return mechanism;
|
|
605
|
+
},
|
|
606
|
+
"Parse a v0 mechanism configuration file");
|
|
607
|
+
}
|