musica 0.12.2__cp312-cp312-win_amd64.whl → 0.13.0__cp312-cp312-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.
Potentially problematic release.
This version of musica might be problematic. Click here for more details.
- musica/CMakeLists.txt +4 -0
- musica/_musica.cp312-win_amd64.pyd +0 -0
- musica/_version.py +1 -1
- musica/binding_common.cpp +6 -9
- musica/binding_common.hpp +17 -1
- musica/grid.cpp +206 -0
- musica/grid.py +98 -0
- musica/grid_map.cpp +117 -0
- musica/grid_map.py +167 -0
- musica/mechanism_configuration/__init__.py +18 -1
- musica/mechanism_configuration/ancillary.py +6 -0
- musica/mechanism_configuration/arrhenius.py +111 -269
- musica/mechanism_configuration/branched.py +116 -275
- musica/mechanism_configuration/emission.py +63 -52
- musica/mechanism_configuration/first_order_loss.py +73 -157
- musica/mechanism_configuration/mechanism.py +93 -0
- musica/mechanism_configuration/phase.py +44 -33
- musica/mechanism_configuration/phase_species.py +58 -0
- musica/mechanism_configuration/photolysis.py +77 -67
- musica/mechanism_configuration/reaction_component.py +54 -0
- musica/mechanism_configuration/reactions.py +17 -58
- musica/mechanism_configuration/species.py +45 -71
- musica/mechanism_configuration/surface.py +78 -74
- musica/mechanism_configuration/taylor_series.py +136 -0
- musica/mechanism_configuration/ternary_chemical_activation.py +138 -330
- musica/mechanism_configuration/troe.py +138 -330
- musica/mechanism_configuration/tunneling.py +105 -229
- musica/mechanism_configuration/user_defined.py +79 -68
- musica/mechanism_configuration.cpp +54 -162
- musica/musica.cpp +2 -5
- musica/profile.cpp +294 -0
- musica/profile.py +93 -0
- musica/profile_map.cpp +117 -0
- musica/profile_map.py +167 -0
- musica/test/examples/v1/full_configuration/full_configuration.json +91 -233
- musica/test/examples/v1/full_configuration/full_configuration.yaml +191 -290
- musica/test/integration/test_chapman.py +2 -2
- musica/test/integration/test_tuvx.py +72 -15
- musica/test/unit/test_grid.py +137 -0
- musica/test/unit/test_grid_map.py +126 -0
- musica/test/unit/test_parser.py +10 -10
- musica/test/unit/test_profile.py +169 -0
- musica/test/unit/test_profile_map.py +137 -0
- musica/test/unit/test_serializer.py +17 -16
- musica/test/unit/test_state.py +17 -4
- musica/test/unit/test_util_full_mechanism.py +78 -298
- musica/tuvx.cpp +94 -15
- musica/tuvx.py +92 -22
- musica/types.py +13 -5
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/METADATA +14 -14
- musica-0.13.0.dist-info/RECORD +80 -0
- musica/mechanism_configuration/aqueous_equilibrium.py +0 -274
- musica/mechanism_configuration/condensed_phase_arrhenius.py +0 -309
- musica/mechanism_configuration/condensed_phase_photolysis.py +0 -88
- musica/mechanism_configuration/henrys_law.py +0 -44
- musica/mechanism_configuration/mechanism_configuration.py +0 -234
- musica/mechanism_configuration/simpol_phase_transfer.py +0 -217
- musica/mechanism_configuration/wet_deposition.py +0 -52
- musica-0.12.2.dist-info/RECORD +0 -70
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/WHEEL +0 -0
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/entry_points.txt +0 -0
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/licenses/AUTHORS.md +0 -0
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,22 +1,127 @@
|
|
|
1
|
-
from .utils import _add_other_properties
|
|
2
|
-
from .reactions import ReactionComponentSerializer
|
|
1
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
3
2
|
from .species import Species
|
|
4
3
|
from .phase import Phase
|
|
5
4
|
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
6
5
|
from .. import backend
|
|
6
|
+
from .reaction_component import ReactionComponent
|
|
7
|
+
from .ancillary import ReactionType
|
|
7
8
|
|
|
8
9
|
_backend = backend.get_backend()
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Branched = _backend._mechanism_configuration._Branched
|
|
11
|
+
|
|
12
|
+
original_init = Branched.__init__
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def type(self):
|
|
17
|
+
"""Get the reaction type."""
|
|
18
|
+
return ReactionType.Branched
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
name: Optional[str] = None,
|
|
24
|
+
X: Optional[float] = None,
|
|
25
|
+
Y: Optional[float] = None,
|
|
26
|
+
a0: Optional[float] = None,
|
|
27
|
+
n: Optional[float] = None,
|
|
28
|
+
reactants: Optional[List[Union[Species,
|
|
29
|
+
Tuple[float, Species]]]] = None,
|
|
30
|
+
nitrate_products: Optional[List[Union[Species,
|
|
31
|
+
Tuple[float, Species]]]] = None,
|
|
32
|
+
alkoxy_products: Optional[List[Union[Species,
|
|
33
|
+
Tuple[float, Species]]]] = None,
|
|
34
|
+
gas_phase: Optional[Phase] = None,
|
|
35
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
36
|
+
):
|
|
37
|
+
"""
|
|
38
|
+
Initializes the Branched object with the given parameters.
|
|
12
39
|
|
|
40
|
+
Args:
|
|
41
|
+
name (str): The name of the branched reaction rate constant.
|
|
42
|
+
X (float): Pre-exponential branching factor [(mol m-3)^-(n-1)s-1].
|
|
43
|
+
Y (float): Exponential branching factor [K-1].
|
|
44
|
+
a0 (float): Z parameter [unitless].
|
|
45
|
+
n (float): A parameter [unitless].
|
|
46
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
47
|
+
nitrate_products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the nitrate branch.
|
|
48
|
+
alkoxy_products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the alkoxy branch.
|
|
49
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
50
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the branched reaction rate constant.
|
|
51
|
+
"""
|
|
52
|
+
original_init(self)
|
|
53
|
+
|
|
54
|
+
self.name = name if name is not None else self.name
|
|
55
|
+
self.X = X if X is not None else self.X
|
|
56
|
+
self.Y = Y if Y is not None else self.Y
|
|
57
|
+
self.a0 = a0 if a0 is not None else self.a0
|
|
58
|
+
self.n = n if n is not None else self.n
|
|
59
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
60
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
61
|
+
self.reactants = (
|
|
62
|
+
[
|
|
63
|
+
(
|
|
64
|
+
ReactionComponent(r.name)
|
|
65
|
+
if isinstance(r, Species)
|
|
66
|
+
else ReactionComponent(r[1].name, r[0])
|
|
67
|
+
)
|
|
68
|
+
for r in reactants
|
|
69
|
+
]
|
|
70
|
+
if reactants is not None
|
|
71
|
+
else self.reactants
|
|
72
|
+
)
|
|
73
|
+
self.nitrate_products = (
|
|
74
|
+
[
|
|
75
|
+
(
|
|
76
|
+
ReactionComponent(p.name)
|
|
77
|
+
if isinstance(p, Species)
|
|
78
|
+
else ReactionComponent(p[1].name, p[0])
|
|
79
|
+
)
|
|
80
|
+
for p in nitrate_products
|
|
81
|
+
]
|
|
82
|
+
if nitrate_products is not None
|
|
83
|
+
else self.nitrate_products
|
|
84
|
+
)
|
|
85
|
+
self.alkoxy_products = (
|
|
86
|
+
[
|
|
87
|
+
(
|
|
88
|
+
ReactionComponent(p.name)
|
|
89
|
+
if isinstance(p, Species)
|
|
90
|
+
else ReactionComponent(p[1].name, p[0])
|
|
91
|
+
)
|
|
92
|
+
for p in alkoxy_products
|
|
93
|
+
]
|
|
94
|
+
if alkoxy_products is not None
|
|
95
|
+
else self.alkoxy_products
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def serialize(self) -> Dict:
|
|
100
|
+
"""
|
|
101
|
+
Serialize the Branched object to a dictionary using only Python-visible data.
|
|
13
102
|
|
|
14
|
-
|
|
103
|
+
Returns:
|
|
104
|
+
Dict: A dictionary representation of the Branched object.
|
|
15
105
|
"""
|
|
106
|
+
serialize_dict = {
|
|
107
|
+
"type": "BRANCHED_NO_RO2",
|
|
108
|
+
"name": self.name,
|
|
109
|
+
"X": self.X,
|
|
110
|
+
"Y": self.Y,
|
|
111
|
+
"a0": self.a0,
|
|
112
|
+
"n": self.n,
|
|
113
|
+
"reactants": [r.serialize() for r in self.reactants],
|
|
114
|
+
"nitrate products": [r.serialize() for r in self.nitrate_products],
|
|
115
|
+
"alkoxy products": [r.serialize() for r in self.alkoxy_products],
|
|
116
|
+
"gas phase": self.gas_phase,
|
|
117
|
+
}
|
|
118
|
+
_add_other_properties(serialize_dict, self.other_properties)
|
|
119
|
+
return _remove_empty_keys(serialize_dict)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
Branched.__doc__ = """
|
|
16
123
|
A class representing a branched reaction rate constant.
|
|
17
124
|
|
|
18
|
-
(TODO: get details from MusicBox)
|
|
19
|
-
|
|
20
125
|
Attributes:
|
|
21
126
|
name (str): The name of the branched reaction rate constant.
|
|
22
127
|
X (float): Pre-exponential branching factor [(mol m-3)^-(n-1)s-1].
|
|
@@ -30,270 +135,6 @@ class Branched:
|
|
|
30
135
|
other_properties (Dict[str, Any]): A dictionary of other properties of the branched reaction rate constant.
|
|
31
136
|
"""
|
|
32
137
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
X: Optional[float] = None,
|
|
37
|
-
Y: Optional[float] = None,
|
|
38
|
-
a0: Optional[float] = None,
|
|
39
|
-
n: Optional[float] = None,
|
|
40
|
-
reactants: Optional[List[Union[Species,
|
|
41
|
-
Tuple[float, Species]]]] = None,
|
|
42
|
-
nitrate_products: Optional[List[Union[Species,
|
|
43
|
-
Tuple[float, Species]]]] = None,
|
|
44
|
-
alkoxy_products: Optional[List[Union[Species,
|
|
45
|
-
Tuple[float, Species]]]] = None,
|
|
46
|
-
gas_phase: Optional[Phase] = None,
|
|
47
|
-
other_properties: Optional[Dict[str, Any]] = None,
|
|
48
|
-
):
|
|
49
|
-
"""
|
|
50
|
-
Initializes the Branched object with the given parameters.
|
|
51
|
-
|
|
52
|
-
Args:
|
|
53
|
-
name (str): The name of the branched reaction rate constant.
|
|
54
|
-
X (float): Pre-exponential branching factor [(mol m-3)^-(n-1)s-1].
|
|
55
|
-
Y (float): Exponential branching factor [K-1].
|
|
56
|
-
a0 (float): Z parameter [unitless].
|
|
57
|
-
n (float): A parameter [unitless].
|
|
58
|
-
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
59
|
-
nitrate_products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the nitrate branch.
|
|
60
|
-
alkoxy_products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the alkoxy branch.
|
|
61
|
-
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
62
|
-
other_properties (Dict[str, Any]): A dictionary of other properties of the branched reaction rate constant.
|
|
63
|
-
"""
|
|
64
|
-
# Create the internal C++ instance
|
|
65
|
-
self._instance = _Branched()
|
|
66
|
-
|
|
67
|
-
# Set all parameters
|
|
68
|
-
if name is not None:
|
|
69
|
-
self.name = name
|
|
70
|
-
if X is not None:
|
|
71
|
-
self.X = X
|
|
72
|
-
if Y is not None:
|
|
73
|
-
self.Y = Y
|
|
74
|
-
if a0 is not None:
|
|
75
|
-
self.a0 = a0
|
|
76
|
-
if n is not None:
|
|
77
|
-
self.n = n
|
|
78
|
-
if reactants is not None:
|
|
79
|
-
self.reactants = reactants
|
|
80
|
-
if nitrate_products is not None:
|
|
81
|
-
self.nitrate_products = nitrate_products
|
|
82
|
-
if alkoxy_products is not None:
|
|
83
|
-
self.alkoxy_products = alkoxy_products
|
|
84
|
-
if gas_phase is not None:
|
|
85
|
-
self.gas_phase = gas_phase
|
|
86
|
-
if other_properties is not None:
|
|
87
|
-
self.other_properties = other_properties
|
|
88
|
-
|
|
89
|
-
# Property delegation to self._instance
|
|
90
|
-
@property
|
|
91
|
-
def name(self) -> str:
|
|
92
|
-
"""Get the name of the branched reaction rate constant."""
|
|
93
|
-
return self._instance.name
|
|
94
|
-
|
|
95
|
-
@name.setter
|
|
96
|
-
def name(self, value: str):
|
|
97
|
-
"""Set the name of the branched reaction rate constant."""
|
|
98
|
-
self._instance.name = value
|
|
99
|
-
|
|
100
|
-
@property
|
|
101
|
-
def X(self) -> float:
|
|
102
|
-
"""Get the pre-exponential branching factor."""
|
|
103
|
-
return self._instance.X
|
|
104
|
-
|
|
105
|
-
@X.setter
|
|
106
|
-
def X(self, value: float):
|
|
107
|
-
"""Set the pre-exponential branching factor."""
|
|
108
|
-
self._instance.X = value
|
|
109
|
-
|
|
110
|
-
@property
|
|
111
|
-
def Y(self) -> float:
|
|
112
|
-
"""Get the exponential branching factor."""
|
|
113
|
-
return self._instance.Y
|
|
114
|
-
|
|
115
|
-
@Y.setter
|
|
116
|
-
def Y(self, value: float):
|
|
117
|
-
"""Set the exponential branching factor."""
|
|
118
|
-
self._instance.Y = value
|
|
119
|
-
|
|
120
|
-
@property
|
|
121
|
-
def a0(self) -> float:
|
|
122
|
-
"""Get the Z parameter."""
|
|
123
|
-
return self._instance.a0
|
|
124
|
-
|
|
125
|
-
@a0.setter
|
|
126
|
-
def a0(self, value: float):
|
|
127
|
-
"""Set the Z parameter."""
|
|
128
|
-
self._instance.a0 = value
|
|
129
|
-
|
|
130
|
-
@property
|
|
131
|
-
def n(self) -> float:
|
|
132
|
-
"""Get the A parameter."""
|
|
133
|
-
return self._instance.n
|
|
134
|
-
|
|
135
|
-
@n.setter
|
|
136
|
-
def n(self, value: float):
|
|
137
|
-
"""Set the A parameter."""
|
|
138
|
-
self._instance.n = value
|
|
139
|
-
|
|
140
|
-
@property
|
|
141
|
-
def reactants(self) -> List[Union[Species, Tuple[float, Species]]]:
|
|
142
|
-
"""Get the reactants as Python objects."""
|
|
143
|
-
# Convert from C++ _ReactionComponent objects to Python Species objects
|
|
144
|
-
result = []
|
|
145
|
-
for rc in self._instance.reactants:
|
|
146
|
-
if hasattr(rc, 'coefficient') and rc.coefficient != 1.0:
|
|
147
|
-
# Create a tuple with coefficient and species
|
|
148
|
-
species = Species(name=rc.species_name)
|
|
149
|
-
result.append((rc.coefficient, species))
|
|
150
|
-
else:
|
|
151
|
-
# Just the species
|
|
152
|
-
species = Species(name=rc.species_name)
|
|
153
|
-
result.append(species)
|
|
154
|
-
return result
|
|
155
|
-
|
|
156
|
-
@reactants.setter
|
|
157
|
-
def reactants(self, value: List[Union[Species, Tuple[float, Species]]]):
|
|
158
|
-
"""Set the reactants, converting from Python to C++ objects."""
|
|
159
|
-
cpp_reactants = []
|
|
160
|
-
for r in value:
|
|
161
|
-
if isinstance(r, Species):
|
|
162
|
-
cpp_reactants.append(_ReactionComponent(r.name))
|
|
163
|
-
elif isinstance(r, tuple) and len(r) == 2:
|
|
164
|
-
coefficient, species = r
|
|
165
|
-
cpp_reactants.append(_ReactionComponent(species.name, coefficient))
|
|
166
|
-
else:
|
|
167
|
-
raise ValueError(f"Invalid reactant format: {r}")
|
|
168
|
-
self._instance.reactants = cpp_reactants
|
|
169
|
-
|
|
170
|
-
@property
|
|
171
|
-
def nitrate_products(self) -> List[Union[Species, Tuple[float, Species]]]:
|
|
172
|
-
"""Get the nitrate products as Python objects."""
|
|
173
|
-
# Convert from C++ _ReactionComponent objects to Python Species objects
|
|
174
|
-
result = []
|
|
175
|
-
for rc in self._instance.nitrate_products:
|
|
176
|
-
if hasattr(rc, 'coefficient') and rc.coefficient != 1.0:
|
|
177
|
-
# Create a tuple with coefficient and species
|
|
178
|
-
species = Species(name=rc.species_name)
|
|
179
|
-
result.append((rc.coefficient, species))
|
|
180
|
-
else:
|
|
181
|
-
# Just the species
|
|
182
|
-
species = Species(name=rc.species_name)
|
|
183
|
-
result.append(species)
|
|
184
|
-
return result
|
|
185
|
-
|
|
186
|
-
@nitrate_products.setter
|
|
187
|
-
def nitrate_products(self, value: List[Union[Species, Tuple[float, Species]]]):
|
|
188
|
-
"""Set the nitrate products, converting from Python to C++ objects."""
|
|
189
|
-
cpp_products = []
|
|
190
|
-
for p in value:
|
|
191
|
-
if isinstance(p, Species):
|
|
192
|
-
cpp_products.append(_ReactionComponent(p.name))
|
|
193
|
-
elif isinstance(p, tuple) and len(p) == 2:
|
|
194
|
-
coefficient, species = p
|
|
195
|
-
cpp_products.append(_ReactionComponent(species.name, coefficient))
|
|
196
|
-
else:
|
|
197
|
-
raise ValueError(f"Invalid nitrate product format: {p}")
|
|
198
|
-
self._instance.nitrate_products = cpp_products
|
|
199
|
-
|
|
200
|
-
@property
|
|
201
|
-
def alkoxy_products(self) -> List[Union[Species, Tuple[float, Species]]]:
|
|
202
|
-
"""Get the alkoxy products as Python objects."""
|
|
203
|
-
# Convert from C++ _ReactionComponent objects to Python Species objects
|
|
204
|
-
result = []
|
|
205
|
-
for rc in self._instance.alkoxy_products:
|
|
206
|
-
if hasattr(rc, 'coefficient') and rc.coefficient != 1.0:
|
|
207
|
-
# Create a tuple with coefficient and species
|
|
208
|
-
species = Species(name=rc.species_name)
|
|
209
|
-
result.append((rc.coefficient, species))
|
|
210
|
-
else:
|
|
211
|
-
# Just the species
|
|
212
|
-
species = Species(name=rc.species_name)
|
|
213
|
-
result.append(species)
|
|
214
|
-
return result
|
|
215
|
-
|
|
216
|
-
@alkoxy_products.setter
|
|
217
|
-
def alkoxy_products(self, value: List[Union[Species, Tuple[float, Species]]]):
|
|
218
|
-
"""Set the alkoxy products, converting from Python to C++ objects."""
|
|
219
|
-
cpp_products = []
|
|
220
|
-
for p in value:
|
|
221
|
-
if isinstance(p, Species):
|
|
222
|
-
cpp_products.append(_ReactionComponent(p.name))
|
|
223
|
-
elif isinstance(p, tuple) and len(p) == 2:
|
|
224
|
-
coefficient, species = p
|
|
225
|
-
cpp_products.append(_ReactionComponent(species.name, coefficient))
|
|
226
|
-
else:
|
|
227
|
-
raise ValueError(f"Invalid alkoxy product format: {p}")
|
|
228
|
-
self._instance.alkoxy_products = cpp_products
|
|
229
|
-
|
|
230
|
-
@property
|
|
231
|
-
def gas_phase(self) -> str:
|
|
232
|
-
"""Get the gas phase name."""
|
|
233
|
-
return self._instance.gas_phase
|
|
234
|
-
|
|
235
|
-
@gas_phase.setter
|
|
236
|
-
def gas_phase(self, value: Union[Phase, str]):
|
|
237
|
-
"""Set the gas phase."""
|
|
238
|
-
if isinstance(value, Phase):
|
|
239
|
-
self._instance.gas_phase = value.name
|
|
240
|
-
elif isinstance(value, str):
|
|
241
|
-
self._instance.gas_phase = value
|
|
242
|
-
else:
|
|
243
|
-
raise ValueError(f"Invalid gas_phase type: {type(value)}")
|
|
244
|
-
|
|
245
|
-
@property
|
|
246
|
-
def other_properties(self) -> Dict[str, Any]:
|
|
247
|
-
"""Get the other properties."""
|
|
248
|
-
return self._instance.other_properties
|
|
249
|
-
|
|
250
|
-
@other_properties.setter
|
|
251
|
-
def other_properties(self, value: Dict[str, Any]):
|
|
252
|
-
"""Set the other properties."""
|
|
253
|
-
self._instance.other_properties = value
|
|
254
|
-
|
|
255
|
-
@property
|
|
256
|
-
def type(self):
|
|
257
|
-
"""Get the reaction type."""
|
|
258
|
-
return ReactionType.Branched
|
|
259
|
-
|
|
260
|
-
def serialize(self) -> Dict:
|
|
261
|
-
"""
|
|
262
|
-
Serialize the Branched object to a dictionary using only Python-visible data.
|
|
263
|
-
|
|
264
|
-
Returns:
|
|
265
|
-
Dict: A dictionary representation of the Branched object.
|
|
266
|
-
"""
|
|
267
|
-
serialize_dict = {
|
|
268
|
-
"type": "BRANCHED_NO_RO2",
|
|
269
|
-
"name": self.name,
|
|
270
|
-
"X": self.X,
|
|
271
|
-
"Y": self.Y,
|
|
272
|
-
"a0": self.a0,
|
|
273
|
-
"n": self.n,
|
|
274
|
-
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(
|
|
275
|
-
self._instance.reactants),
|
|
276
|
-
"nitrate products": ReactionComponentSerializer.serialize_list_reaction_components(
|
|
277
|
-
self._instance.nitrate_products),
|
|
278
|
-
"alkoxy products": ReactionComponentSerializer.serialize_list_reaction_components(
|
|
279
|
-
self._instance.alkoxy_products),
|
|
280
|
-
"gas phase": self.gas_phase,
|
|
281
|
-
}
|
|
282
|
-
_add_other_properties(serialize_dict, self.other_properties)
|
|
283
|
-
return serialize_dict
|
|
284
|
-
|
|
285
|
-
@staticmethod
|
|
286
|
-
def serialize_static(instance) -> Dict:
|
|
287
|
-
"""
|
|
288
|
-
Static serialize method for compatibility with C++ _Branched objects.
|
|
289
|
-
|
|
290
|
-
Args:
|
|
291
|
-
instance: The _Branched instance to serialize.
|
|
292
|
-
|
|
293
|
-
Returns:
|
|
294
|
-
Dict: A dictionary representation of the Branched object.
|
|
295
|
-
"""
|
|
296
|
-
# Create a temporary Branched object and use its instance serialize method
|
|
297
|
-
temp_branched = Branched()
|
|
298
|
-
temp_branched._instance = instance
|
|
299
|
-
return temp_branched.serialize()
|
|
138
|
+
Branched.__init__ = __init__
|
|
139
|
+
Branched.serialize = serialize
|
|
140
|
+
Branched.type = type
|
|
@@ -1,71 +1,82 @@
|
|
|
1
|
-
from .utils import _add_other_properties
|
|
2
|
-
from .reactions import ReactionComponentSerializer
|
|
1
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
3
2
|
from .species import Species
|
|
4
3
|
from .phase import Phase
|
|
5
4
|
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
6
5
|
from .. import backend
|
|
6
|
+
from .reaction_component import ReactionComponent
|
|
7
|
+
from .ancillary import ReactionType
|
|
7
8
|
|
|
8
9
|
_backend = backend.get_backend()
|
|
9
|
-
|
|
10
|
-
_ReactionComponent = _backend._mechanism_configuration._ReactionComponent
|
|
10
|
+
Emission = _backend._mechanism_configuration._Emission
|
|
11
11
|
|
|
12
|
+
original_init = Emission.__init__
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def type(self):
|
|
17
|
+
return ReactionType.Emission
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
name: Optional[str] = None,
|
|
23
|
+
scaling_factor: Optional[float] = None,
|
|
24
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
25
|
+
gas_phase: Optional[Phase] = None,
|
|
26
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
27
|
+
):
|
|
14
28
|
"""
|
|
15
|
-
|
|
29
|
+
Initializes the Emission object with the given parameters.
|
|
16
30
|
|
|
17
|
-
|
|
31
|
+
Args:
|
|
18
32
|
name (str): The name of the emission reaction rate constant.
|
|
19
33
|
scaling_factor (float): The scaling factor for the emission rate constant.
|
|
20
34
|
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
21
35
|
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
22
36
|
other_properties (Dict[str, Any]): A dictionary of other properties of the emission reaction rate constant.
|
|
23
37
|
"""
|
|
38
|
+
original_init(self)
|
|
39
|
+
self.name = name if name is not None else self.name
|
|
40
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
41
|
+
self.products = (
|
|
42
|
+
[
|
|
43
|
+
(
|
|
44
|
+
ReactionComponent(p.name)
|
|
45
|
+
if isinstance(p, Species)
|
|
46
|
+
else ReactionComponent(p[1].name, p[0])
|
|
47
|
+
)
|
|
48
|
+
for p in products
|
|
49
|
+
]
|
|
50
|
+
if products is not None
|
|
51
|
+
else self.products
|
|
52
|
+
)
|
|
53
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
54
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def serialize(self) -> Dict:
|
|
58
|
+
serialize_dict = {
|
|
59
|
+
"type": "EMISSION",
|
|
60
|
+
"name": self.name,
|
|
61
|
+
"scaling factor": self.scaling_factor,
|
|
62
|
+
"products": [r.serialize() for r in self.products],
|
|
63
|
+
"gas phase": self.gas_phase,
|
|
64
|
+
}
|
|
65
|
+
_add_other_properties(serialize_dict, self.other_properties)
|
|
66
|
+
return serialize_dict
|
|
67
|
+
|
|
24
68
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
name: Optional[str] = None,
|
|
28
|
-
scaling_factor: Optional[float] = None,
|
|
29
|
-
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
30
|
-
gas_phase: Optional[Phase] = None,
|
|
31
|
-
other_properties: Optional[Dict[str, Any]] = None,
|
|
32
|
-
):
|
|
33
|
-
"""
|
|
34
|
-
Initializes the Emission object with the given parameters.
|
|
69
|
+
Emission.__doc__ = """
|
|
70
|
+
A class representing an emission reaction rate constant.
|
|
35
71
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
super().__init__()
|
|
44
|
-
self.name = name if name is not None else self.name
|
|
45
|
-
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
46
|
-
self.products = (
|
|
47
|
-
[
|
|
48
|
-
(
|
|
49
|
-
_ReactionComponent(p.name)
|
|
50
|
-
if isinstance(p, Species)
|
|
51
|
-
else _ReactionComponent(p[1].name, p[0])
|
|
52
|
-
)
|
|
53
|
-
for p in products
|
|
54
|
-
]
|
|
55
|
-
if products is not None
|
|
56
|
-
else self.products
|
|
57
|
-
)
|
|
58
|
-
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
59
|
-
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
72
|
+
Attributes:
|
|
73
|
+
name (str): The name of the emission reaction rate constant.
|
|
74
|
+
scaling_factor (float): The scaling factor for the emission rate constant.
|
|
75
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
76
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
77
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the emission reaction rate constant.
|
|
78
|
+
"""
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"type": "EMISSION",
|
|
65
|
-
"name": instance.name,
|
|
66
|
-
"scaling factor": instance.scaling_factor,
|
|
67
|
-
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
68
|
-
"gas phase": instance.gas_phase,
|
|
69
|
-
}
|
|
70
|
-
_add_other_properties(serialize_dict, instance.other_properties)
|
|
71
|
-
return serialize_dict
|
|
80
|
+
Emission.__init__ = __init__
|
|
81
|
+
Emission.serialize = serialize
|
|
82
|
+
Emission.type = type
|