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,31 +1,38 @@
|
|
|
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
|
|
11
|
-
ReactionType = _backend._mechanism_configuration._ReactionType
|
|
10
|
+
Tunneling = _backend._mechanism_configuration._Tunneling
|
|
12
11
|
|
|
12
|
+
original_init = Tunneling.__init__
|
|
13
13
|
|
|
14
|
-
class Tunneling:
|
|
15
|
-
"""
|
|
16
|
-
A class representing a quantum tunneling reaction rate constant.
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
@property
|
|
16
|
+
def type(self):
|
|
17
|
+
return ReactionType.Tunneling
|
|
18
|
+
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
name: Optional[str] = None,
|
|
23
|
+
A: Optional[float] = None,
|
|
24
|
+
B: Optional[float] = None,
|
|
25
|
+
C: Optional[float] = None,
|
|
26
|
+
reactants: Optional[List[Union[Species,
|
|
27
|
+
Tuple[float, Species]]]] = None,
|
|
28
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
29
|
+
gas_phase: Optional[Phase] = None,
|
|
30
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
31
|
+
):
|
|
32
|
+
"""
|
|
33
|
+
Initializes the Tunneling object with the given parameters.
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
Args:
|
|
29
36
|
name (str): The name of the tunneling reaction rate constant.
|
|
30
37
|
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
|
|
31
38
|
B (float): Tunneling parameter [K^-1].
|
|
@@ -35,216 +42,85 @@ class Tunneling:
|
|
|
35
42
|
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
36
43
|
other_properties (Dict[str, Any]): A dictionary of other properties of the tunneling reaction rate constant.
|
|
37
44
|
"""
|
|
45
|
+
original_init(self)
|
|
46
|
+
|
|
47
|
+
self.name = name if name is not None else self.name
|
|
48
|
+
self.A = A if A is not None else self.A
|
|
49
|
+
self.B = B if B is not None else self.B
|
|
50
|
+
self.C = C if C is not None else self.C
|
|
51
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
52
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
53
|
+
self.reactants = (
|
|
54
|
+
[
|
|
55
|
+
(
|
|
56
|
+
ReactionComponent(r.name)
|
|
57
|
+
if isinstance(r, Species)
|
|
58
|
+
else ReactionComponent(r[1].name, r[0])
|
|
59
|
+
)
|
|
60
|
+
for r in reactants
|
|
61
|
+
]
|
|
62
|
+
if reactants is not None
|
|
63
|
+
else self.reactants
|
|
64
|
+
)
|
|
65
|
+
self.products = (
|
|
66
|
+
[
|
|
67
|
+
(
|
|
68
|
+
ReactionComponent(p.name)
|
|
69
|
+
if isinstance(p, Species)
|
|
70
|
+
else ReactionComponent(p[1].name, p[0])
|
|
71
|
+
)
|
|
72
|
+
for p in products
|
|
73
|
+
]
|
|
74
|
+
if products is not None
|
|
75
|
+
else self.products
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def serialize(self) -> Dict:
|
|
80
|
+
"""
|
|
81
|
+
Serialize the Tunneling object to a dictionary using only Python-visible data.
|
|
38
82
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
self.other_properties = other_properties
|
|
84
|
-
|
|
85
|
-
# Property delegation to self._instance
|
|
86
|
-
@property
|
|
87
|
-
def name(self) -> str:
|
|
88
|
-
"""Get the name of the tunneling reaction rate constant."""
|
|
89
|
-
return self._instance.name
|
|
90
|
-
|
|
91
|
-
@name.setter
|
|
92
|
-
def name(self, value: str):
|
|
93
|
-
"""Set the name of the tunneling reaction rate constant."""
|
|
94
|
-
self._instance.name = value
|
|
95
|
-
|
|
96
|
-
@property
|
|
97
|
-
def A(self) -> float:
|
|
98
|
-
"""Get the pre-exponential factor."""
|
|
99
|
-
return self._instance.A
|
|
100
|
-
|
|
101
|
-
@A.setter
|
|
102
|
-
def A(self, value: float):
|
|
103
|
-
"""Set the pre-exponential factor."""
|
|
104
|
-
self._instance.A = value
|
|
105
|
-
|
|
106
|
-
@property
|
|
107
|
-
def B(self) -> float:
|
|
108
|
-
"""Get the tunneling parameter B."""
|
|
109
|
-
return self._instance.B
|
|
110
|
-
|
|
111
|
-
@B.setter
|
|
112
|
-
def B(self, value: float):
|
|
113
|
-
"""Set the tunneling parameter B."""
|
|
114
|
-
self._instance.B = value
|
|
115
|
-
|
|
116
|
-
@property
|
|
117
|
-
def C(self) -> float:
|
|
118
|
-
"""Get the tunneling parameter C."""
|
|
119
|
-
return self._instance.C
|
|
120
|
-
|
|
121
|
-
@C.setter
|
|
122
|
-
def C(self, value: float):
|
|
123
|
-
"""Set the tunneling parameter C."""
|
|
124
|
-
self._instance.C = value
|
|
125
|
-
|
|
126
|
-
@property
|
|
127
|
-
def reactants(self) -> List[Union[Species, Tuple[float, Species]]]:
|
|
128
|
-
"""Get the reactants as Python objects."""
|
|
129
|
-
# Convert from C++ _ReactionComponent objects to Python Species objects
|
|
130
|
-
result = []
|
|
131
|
-
for rc in self._instance.reactants:
|
|
132
|
-
if hasattr(rc, 'coefficient') and rc.coefficient != 1.0:
|
|
133
|
-
# Create a tuple with coefficient and species
|
|
134
|
-
species = Species(name=rc.species_name)
|
|
135
|
-
result.append((rc.coefficient, species))
|
|
136
|
-
else:
|
|
137
|
-
# Just the species
|
|
138
|
-
species = Species(name=rc.species_name)
|
|
139
|
-
result.append(species)
|
|
140
|
-
return result
|
|
141
|
-
|
|
142
|
-
@reactants.setter
|
|
143
|
-
def reactants(self, value: List[Union[Species, Tuple[float, Species]]]):
|
|
144
|
-
"""Set the reactants, converting from Python to C++ objects."""
|
|
145
|
-
cpp_reactants = []
|
|
146
|
-
for r in value:
|
|
147
|
-
if isinstance(r, Species):
|
|
148
|
-
cpp_reactants.append(_ReactionComponent(r.name))
|
|
149
|
-
elif isinstance(r, tuple) and len(r) == 2:
|
|
150
|
-
coefficient, species = r
|
|
151
|
-
cpp_reactants.append(_ReactionComponent(species.name, coefficient))
|
|
152
|
-
else:
|
|
153
|
-
raise ValueError(f"Invalid reactant format: {r}")
|
|
154
|
-
self._instance.reactants = cpp_reactants
|
|
155
|
-
|
|
156
|
-
@property
|
|
157
|
-
def products(self) -> List[Union[Species, Tuple[float, Species]]]:
|
|
158
|
-
"""Get the products as Python objects."""
|
|
159
|
-
# Convert from C++ _ReactionComponent objects to Python Species objects
|
|
160
|
-
result = []
|
|
161
|
-
for rc in self._instance.products:
|
|
162
|
-
if hasattr(rc, 'coefficient') and rc.coefficient != 1.0:
|
|
163
|
-
# Create a tuple with coefficient and species
|
|
164
|
-
species = Species(name=rc.species_name)
|
|
165
|
-
result.append((rc.coefficient, species))
|
|
166
|
-
else:
|
|
167
|
-
# Just the species
|
|
168
|
-
species = Species(name=rc.species_name)
|
|
169
|
-
result.append(species)
|
|
170
|
-
return result
|
|
171
|
-
|
|
172
|
-
@products.setter
|
|
173
|
-
def products(self, value: List[Union[Species, Tuple[float, Species]]]):
|
|
174
|
-
"""Set the products, converting from Python to C++ objects."""
|
|
175
|
-
cpp_products = []
|
|
176
|
-
for p in value:
|
|
177
|
-
if isinstance(p, Species):
|
|
178
|
-
cpp_products.append(_ReactionComponent(p.name))
|
|
179
|
-
elif isinstance(p, tuple) and len(p) == 2:
|
|
180
|
-
coefficient, species = p
|
|
181
|
-
cpp_products.append(_ReactionComponent(species.name, coefficient))
|
|
182
|
-
else:
|
|
183
|
-
raise ValueError(f"Invalid product format: {p}")
|
|
184
|
-
self._instance.products = cpp_products
|
|
185
|
-
|
|
186
|
-
@property
|
|
187
|
-
def gas_phase(self) -> str:
|
|
188
|
-
"""Get the gas phase name."""
|
|
189
|
-
return self._instance.gas_phase
|
|
190
|
-
|
|
191
|
-
@gas_phase.setter
|
|
192
|
-
def gas_phase(self, value: Union[Phase, str]):
|
|
193
|
-
"""Set the gas phase."""
|
|
194
|
-
if isinstance(value, Phase):
|
|
195
|
-
self._instance.gas_phase = value.name
|
|
196
|
-
elif isinstance(value, str):
|
|
197
|
-
self._instance.gas_phase = value
|
|
198
|
-
else:
|
|
199
|
-
raise ValueError(f"Invalid gas_phase type: {type(value)}")
|
|
200
|
-
|
|
201
|
-
@property
|
|
202
|
-
def other_properties(self) -> Dict[str, Any]:
|
|
203
|
-
"""Get the other properties."""
|
|
204
|
-
return self._instance.other_properties
|
|
205
|
-
|
|
206
|
-
@other_properties.setter
|
|
207
|
-
def other_properties(self, value: Dict[str, Any]):
|
|
208
|
-
"""Set the other properties."""
|
|
209
|
-
self._instance.other_properties = value
|
|
210
|
-
|
|
211
|
-
@property
|
|
212
|
-
def type(self):
|
|
213
|
-
"""Get the reaction type."""
|
|
214
|
-
return ReactionType.Tunneling
|
|
215
|
-
|
|
216
|
-
def serialize(self) -> Dict:
|
|
217
|
-
"""
|
|
218
|
-
Serialize the Tunneling object to a dictionary using only Python-visible data.
|
|
219
|
-
|
|
220
|
-
Returns:
|
|
221
|
-
Dict: A dictionary representation of the Tunneling object.
|
|
222
|
-
"""
|
|
223
|
-
serialize_dict = {
|
|
224
|
-
"type": "TUNNELING",
|
|
225
|
-
"name": self._instance.name,
|
|
226
|
-
"A": self._instance.A,
|
|
227
|
-
"B": self._instance.B,
|
|
228
|
-
"C": self._instance.C,
|
|
229
|
-
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(self._instance.reactants),
|
|
230
|
-
"products": ReactionComponentSerializer.serialize_list_reaction_components(self._instance.products),
|
|
231
|
-
"gas phase": self._instance.gas_phase,
|
|
232
|
-
}
|
|
233
|
-
_add_other_properties(serialize_dict, self.other_properties)
|
|
234
|
-
return serialize_dict
|
|
235
|
-
|
|
236
|
-
@staticmethod
|
|
237
|
-
def serialize_static(instance) -> Dict:
|
|
238
|
-
"""
|
|
239
|
-
Static serialize method for compatibility with C++ _Tunneling objects.
|
|
240
|
-
|
|
241
|
-
Args:
|
|
242
|
-
instance: The _Tunneling instance to serialize.
|
|
243
|
-
|
|
244
|
-
Returns:
|
|
245
|
-
Dict: A dictionary representation of the Tunneling object.
|
|
246
|
-
"""
|
|
247
|
-
# Create a temporary Tunneling object and use its serialize method
|
|
248
|
-
temp_tunneling = Tunneling()
|
|
249
|
-
temp_tunneling._instance = instance
|
|
250
|
-
return temp_tunneling.serialize()
|
|
83
|
+
Returns:
|
|
84
|
+
Dict: A dictionary representation of the Tunneling object.
|
|
85
|
+
"""
|
|
86
|
+
serialize_dict = {
|
|
87
|
+
"type": "TUNNELING",
|
|
88
|
+
"name": self.name,
|
|
89
|
+
"A": self.A,
|
|
90
|
+
"B": self.B,
|
|
91
|
+
"C": self.C,
|
|
92
|
+
"reactants": [r.serialize() for r in self.reactants],
|
|
93
|
+
"products": [r.serialize() for r in self.products],
|
|
94
|
+
"gas phase": self.gas_phase,
|
|
95
|
+
}
|
|
96
|
+
_add_other_properties(serialize_dict, self.other_properties)
|
|
97
|
+
return _remove_empty_keys(serialize_dict)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
Tunneling.__doc__ = """
|
|
101
|
+
A class representing a quantum tunneling reaction rate constant.
|
|
102
|
+
|
|
103
|
+
k = A * exp( -B / T ) * exp( C / T^3 )
|
|
104
|
+
|
|
105
|
+
where:
|
|
106
|
+
k = rate constant
|
|
107
|
+
A = pre-exponential factor [(mol m-3)^(n-1)s-1]
|
|
108
|
+
B = tunneling parameter [K^-1]
|
|
109
|
+
C = tunneling parameter [K^-3]
|
|
110
|
+
T = temperature [K]
|
|
111
|
+
n = number of reactants
|
|
112
|
+
|
|
113
|
+
Attributes:
|
|
114
|
+
name (str): The name of the tunneling reaction rate constant.
|
|
115
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
|
|
116
|
+
B (float): Tunneling parameter [K^-1].
|
|
117
|
+
C (float): Tunneling parameter [K^-3].
|
|
118
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
119
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
120
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
121
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the tunneling reaction rate constant.
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
Tunneling.__init__ = __init__
|
|
125
|
+
Tunneling.serialize = serialize
|
|
126
|
+
Tunneling.type = type
|
|
@@ -2,19 +2,35 @@ from typing import Optional, Any, Dict, List, Union, Tuple
|
|
|
2
2
|
from .. import backend
|
|
3
3
|
from .phase import Phase
|
|
4
4
|
from .species import Species
|
|
5
|
-
from .
|
|
6
|
-
from .
|
|
5
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
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
|
+
UserDefined = _backend._mechanism_configuration._UserDefined
|
|
11
11
|
|
|
12
|
+
original_init = UserDefined.__init__
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def type(self):
|
|
17
|
+
return ReactionType.UserDefined
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
name: Optional[str] = None,
|
|
23
|
+
scaling_factor: Optional[float] = None,
|
|
24
|
+
reactants: Optional[List[Union[Species,
|
|
25
|
+
Tuple[float, Species]]]] = None,
|
|
26
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
27
|
+
gas_phase: Optional[Phase] = None,
|
|
28
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
29
|
+
):
|
|
14
30
|
"""
|
|
15
|
-
|
|
31
|
+
Initializes the UserDefined object with the given parameters.
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
Args:
|
|
18
34
|
name (str): The name of the photolysis reaction rate constant.
|
|
19
35
|
scaling_factor (float): The scaling factor for the photolysis rate constant.
|
|
20
36
|
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
@@ -22,67 +38,62 @@ class UserDefined(_UserDefined):
|
|
|
22
38
|
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
23
39
|
other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
|
|
24
40
|
"""
|
|
41
|
+
original_init(self)
|
|
42
|
+
self.name = name if name is not None else self.name
|
|
43
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
44
|
+
self.reactants = (
|
|
45
|
+
[
|
|
46
|
+
(
|
|
47
|
+
ReactionComponent(r.name)
|
|
48
|
+
if isinstance(r, Species)
|
|
49
|
+
else ReactionComponent(r[1].name, r[0])
|
|
50
|
+
)
|
|
51
|
+
for r in reactants
|
|
52
|
+
]
|
|
53
|
+
if reactants is not None
|
|
54
|
+
else self.reactants
|
|
55
|
+
)
|
|
56
|
+
self.products = (
|
|
57
|
+
[
|
|
58
|
+
(
|
|
59
|
+
ReactionComponent(p.name)
|
|
60
|
+
if isinstance(p, Species)
|
|
61
|
+
else ReactionComponent(p[1].name, p[0])
|
|
62
|
+
)
|
|
63
|
+
for p in products
|
|
64
|
+
]
|
|
65
|
+
if products is not None
|
|
66
|
+
else self.products
|
|
67
|
+
)
|
|
68
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
69
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def serialize(self) -> Dict:
|
|
73
|
+
serialize_dict = {
|
|
74
|
+
"type": "USER_DEFINED",
|
|
75
|
+
"name": self.name,
|
|
76
|
+
"scaling factor": self.scaling_factor,
|
|
77
|
+
"reactants": [r.serialize() for r in self.reactants],
|
|
78
|
+
"products": [r.serialize() for r in self.products],
|
|
79
|
+
"gas phase": self.gas_phase,
|
|
80
|
+
}
|
|
81
|
+
_add_other_properties(serialize_dict, self.other_properties)
|
|
82
|
+
return _remove_empty_keys(serialize_dict)
|
|
83
|
+
|
|
25
84
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name: Optional[str] = None,
|
|
29
|
-
scaling_factor: Optional[float] = None,
|
|
30
|
-
reactants: Optional[List[Union[Species,
|
|
31
|
-
Tuple[float, Species]]]] = None,
|
|
32
|
-
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
33
|
-
gas_phase: Optional[Phase] = None,
|
|
34
|
-
other_properties: Optional[Dict[str, Any]] = None,
|
|
35
|
-
):
|
|
36
|
-
"""
|
|
37
|
-
Initializes the UserDefined object with the given parameters.
|
|
85
|
+
UserDefined.__doc__ = """
|
|
86
|
+
A class representing a user-defined reaction rate constant.
|
|
38
87
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
super().__init__()
|
|
48
|
-
self.name = name if name is not None else self.name
|
|
49
|
-
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
50
|
-
self.reactants = (
|
|
51
|
-
[
|
|
52
|
-
(
|
|
53
|
-
_ReactionComponent(r.name)
|
|
54
|
-
if isinstance(r, Species)
|
|
55
|
-
else _ReactionComponent(r[1].name, r[0])
|
|
56
|
-
)
|
|
57
|
-
for r in reactants
|
|
58
|
-
]
|
|
59
|
-
if reactants is not None
|
|
60
|
-
else self.reactants
|
|
61
|
-
)
|
|
62
|
-
self.products = (
|
|
63
|
-
[
|
|
64
|
-
(
|
|
65
|
-
_ReactionComponent(p.name)
|
|
66
|
-
if isinstance(p, Species)
|
|
67
|
-
else _ReactionComponent(p[1].name, p[0])
|
|
68
|
-
)
|
|
69
|
-
for p in products
|
|
70
|
-
]
|
|
71
|
-
if products is not None
|
|
72
|
-
else self.products
|
|
73
|
-
)
|
|
74
|
-
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
75
|
-
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
88
|
+
Attributes:
|
|
89
|
+
name (str): The name of the photolysis reaction rate constant.
|
|
90
|
+
scaling_factor (float): The scaling factor for the photolysis rate constant.
|
|
91
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
92
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
93
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
94
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
|
|
95
|
+
"""
|
|
76
96
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"type": "USER_DEFINED",
|
|
81
|
-
"name": instance.name,
|
|
82
|
-
"scaling factor": instance.scaling_factor,
|
|
83
|
-
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
84
|
-
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
85
|
-
"gas phase": instance.gas_phase,
|
|
86
|
-
}
|
|
87
|
-
_add_other_properties(serialize_dict, instance.other_properties)
|
|
88
|
-
return serialize_dict
|
|
97
|
+
UserDefined.__init__ = __init__
|
|
98
|
+
UserDefined.serialize = serialize
|
|
99
|
+
UserDefined.type = type
|