musica 0.12.0__cp310-cp310-win32.whl → 0.12.2__cp310-cp310-win32.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 +28 -2
- musica/__init__.py +9 -49
- musica/_musica.cp310-win32.pyd +0 -0
- musica/_version.py +1 -1
- musica/backend.py +41 -0
- musica/binding_common.cpp +23 -6
- musica/carma.cpp +911 -0
- musica/carma.py +1729 -0
- musica/constants.py +1 -1
- musica/cpu_binding.cpp +2 -1
- musica/cuda.py +4 -1
- 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 +2 -1
- musica/main.py +89 -0
- musica/mechanism_configuration/__init__.py +1 -1
- musica/mechanism_configuration/aqueous_equilibrium.py +227 -54
- musica/mechanism_configuration/arrhenius.py +228 -42
- musica/mechanism_configuration/branched.py +249 -66
- musica/mechanism_configuration/condensed_phase_arrhenius.py +243 -50
- musica/mechanism_configuration/condensed_phase_photolysis.py +16 -19
- musica/mechanism_configuration/emission.py +10 -6
- musica/mechanism_configuration/first_order_loss.py +133 -26
- musica/mechanism_configuration/henrys_law.py +7 -48
- musica/mechanism_configuration/mechanism_configuration.py +114 -41
- musica/mechanism_configuration/phase.py +6 -2
- musica/mechanism_configuration/photolysis.py +12 -7
- musica/mechanism_configuration/reactions.py +20 -8
- musica/mechanism_configuration/simpol_phase_transfer.py +180 -51
- musica/mechanism_configuration/species.py +23 -4
- musica/mechanism_configuration/surface.py +14 -9
- musica/mechanism_configuration/ternary_chemical_activation.py +352 -0
- musica/mechanism_configuration/troe.py +259 -44
- musica/mechanism_configuration/tunneling.py +196 -49
- musica/mechanism_configuration/user_defined.py +9 -4
- musica/mechanism_configuration/wet_deposition.py +11 -8
- musica/mechanism_configuration.cpp +184 -95
- musica/musica.cpp +48 -61
- musica/test/examples/v1/full_configuration/full_configuration.json +39 -22
- musica/test/examples/v1/full_configuration/full_configuration.yaml +29 -20
- musica/test/{test_analytical.py → integration/test_analytical.py} +0 -1
- 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_sulfate_box_model.py +34 -0
- musica/test/integration/test_tuvx.py +62 -0
- musica/test/unit/test_parser.py +64 -0
- musica/test/{test_serializer.py → unit/test_serializer.py} +2 -2
- musica/test/unit/test_state.py +325 -0
- musica/test/{test_util_full_mechanism.py → unit/test_util_full_mechanism.py} +152 -122
- musica/tools/prepare_build_environment_linux.sh +23 -34
- musica/tools/prepare_build_environment_macos.sh +1 -0
- musica/tuvx.cpp +93 -0
- musica/tuvx.py +199 -0
- musica/types.py +120 -73
- {musica-0.12.0.dist-info → musica-0.12.2.dist-info}/METADATA +41 -39
- musica-0.12.2.dist-info/RECORD +70 -0
- {musica-0.12.0.dist-info → musica-0.12.2.dist-info}/WHEEL +1 -1
- musica-0.12.2.dist-info/entry_points.txt +3 -0
- musica/test/examples/v0/config.json +0 -7
- musica/test/examples/v0/config.yaml +0 -3
- musica/test/examples/v0/reactions.json +0 -193
- musica/test/examples/v0/reactions.yaml +0 -142
- musica/test/examples/v0/species.json +0 -40
- musica/test/examples/v0/species.yaml +0 -19
- musica/test/test_parser.py +0 -57
- musica/test/tuvx.py +0 -10
- musica/tools/prepare_build_environment_windows.sh +0 -22
- musica-0.12.0.dist-info/RECORD +0 -57
- /musica/test/{test_chapman.py → integration/test_chapman.py} +0 -0
- {musica-0.12.0.dist-info → musica-0.12.2.dist-info}/licenses/AUTHORS.md +0 -0
- {musica-0.12.0.dist-info → musica-0.12.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
from
|
|
2
|
-
from musica import _Tunneling, _ReactionComponent
|
|
3
|
-
from .phase import Phase
|
|
4
|
-
from .species import Species
|
|
1
|
+
from .utils import _add_other_properties
|
|
5
2
|
from .reactions import ReactionComponentSerializer
|
|
6
|
-
from .
|
|
3
|
+
from .species import Species
|
|
4
|
+
from .phase import Phase
|
|
5
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
6
|
+
from .. import backend
|
|
7
|
+
|
|
8
|
+
_backend = backend.get_backend()
|
|
9
|
+
_Tunneling = _backend._mechanism_configuration._Tunneling
|
|
10
|
+
_ReactionComponent = _backend._mechanism_configuration._ReactionComponent
|
|
11
|
+
ReactionType = _backend._mechanism_configuration._ReactionType
|
|
7
12
|
|
|
8
13
|
|
|
9
|
-
class Tunneling
|
|
14
|
+
class Tunneling:
|
|
10
15
|
"""
|
|
11
16
|
A class representing a quantum tunneling reaction rate constant.
|
|
12
17
|
|
|
@@ -37,7 +42,8 @@ class Tunneling(_Tunneling):
|
|
|
37
42
|
A: Optional[float] = None,
|
|
38
43
|
B: Optional[float] = None,
|
|
39
44
|
C: Optional[float] = None,
|
|
40
|
-
reactants: Optional[List[Union[Species,
|
|
45
|
+
reactants: Optional[List[Union[Species,
|
|
46
|
+
Tuple[float, Species]]]] = None,
|
|
41
47
|
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
42
48
|
gas_phase: Optional[Phase] = None,
|
|
43
49
|
other_properties: Optional[Dict[str, Any]] = None,
|
|
@@ -55,49 +61,190 @@ class Tunneling(_Tunneling):
|
|
|
55
61
|
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
56
62
|
other_properties (Dict[str, Any]): A dictionary of other properties of the tunneling reaction rate constant.
|
|
57
63
|
"""
|
|
58
|
-
|
|
59
|
-
self.
|
|
60
|
-
self.A = A if A is not None else self.A
|
|
61
|
-
self.B = B if B is not None else self.B
|
|
62
|
-
self.C = C if C is not None else self.C
|
|
63
|
-
self.reactants = (
|
|
64
|
-
[
|
|
65
|
-
(
|
|
66
|
-
_ReactionComponent(r.name)
|
|
67
|
-
if isinstance(r, Species)
|
|
68
|
-
else _ReactionComponent(r[1].name, r[0])
|
|
69
|
-
)
|
|
70
|
-
for r in reactants
|
|
71
|
-
]
|
|
72
|
-
if reactants is not None
|
|
73
|
-
else self.reactants
|
|
74
|
-
)
|
|
75
|
-
self.products = (
|
|
76
|
-
[
|
|
77
|
-
(
|
|
78
|
-
_ReactionComponent(p.name)
|
|
79
|
-
if isinstance(p, Species)
|
|
80
|
-
else _ReactionComponent(p[1].name, p[0])
|
|
81
|
-
)
|
|
82
|
-
for p in products
|
|
83
|
-
]
|
|
84
|
-
if products is not None
|
|
85
|
-
else self.products
|
|
86
|
-
)
|
|
87
|
-
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
88
|
-
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
64
|
+
# Create the internal C++ instance
|
|
65
|
+
self._instance = _Tunneling()
|
|
89
66
|
|
|
90
|
-
|
|
91
|
-
|
|
67
|
+
# Set all parameters
|
|
68
|
+
if name is not None:
|
|
69
|
+
self.name = name
|
|
70
|
+
if A is not None:
|
|
71
|
+
self.A = A
|
|
72
|
+
if B is not None:
|
|
73
|
+
self.B = B
|
|
74
|
+
if C is not None:
|
|
75
|
+
self.C = C
|
|
76
|
+
if reactants is not None:
|
|
77
|
+
self.reactants = reactants
|
|
78
|
+
if products is not None:
|
|
79
|
+
self.products = products
|
|
80
|
+
if gas_phase is not None:
|
|
81
|
+
self.gas_phase = gas_phase
|
|
82
|
+
if other_properties is not None:
|
|
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
|
+
"""
|
|
92
223
|
serialize_dict = {
|
|
93
224
|
"type": "TUNNELING",
|
|
94
|
-
"name":
|
|
95
|
-
"A":
|
|
96
|
-
"B":
|
|
97
|
-
"C":
|
|
98
|
-
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(
|
|
99
|
-
"products": ReactionComponentSerializer.serialize_list_reaction_components(
|
|
100
|
-
"gas phase":
|
|
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,
|
|
101
232
|
}
|
|
102
|
-
_add_other_properties(serialize_dict,
|
|
103
|
-
return
|
|
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()
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
-
from
|
|
2
|
+
from .. import backend
|
|
3
3
|
from .phase import Phase
|
|
4
4
|
from .species import Species
|
|
5
5
|
from .reactions import ReactionComponentSerializer
|
|
6
|
-
from .utils import _add_other_properties
|
|
6
|
+
from .utils import _add_other_properties
|
|
7
|
+
|
|
8
|
+
_backend = backend.get_backend()
|
|
9
|
+
_UserDefined = _backend._mechanism_configuration._UserDefined
|
|
10
|
+
_ReactionComponent = _backend._mechanism_configuration._ReactionComponent
|
|
7
11
|
|
|
8
12
|
|
|
9
13
|
class UserDefined(_UserDefined):
|
|
@@ -23,7 +27,8 @@ class UserDefined(_UserDefined):
|
|
|
23
27
|
self,
|
|
24
28
|
name: Optional[str] = None,
|
|
25
29
|
scaling_factor: Optional[float] = None,
|
|
26
|
-
reactants: Optional[List[Union[Species,
|
|
30
|
+
reactants: Optional[List[Union[Species,
|
|
31
|
+
Tuple[float, Species]]]] = None,
|
|
27
32
|
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
28
33
|
gas_phase: Optional[Phase] = None,
|
|
29
34
|
other_properties: Optional[Dict[str, Any]] = None,
|
|
@@ -80,4 +85,4 @@ class UserDefined(_UserDefined):
|
|
|
80
85
|
"gas phase": instance.gas_phase,
|
|
81
86
|
}
|
|
82
87
|
_add_other_properties(serialize_dict, instance.other_properties)
|
|
83
|
-
return
|
|
88
|
+
return serialize_dict
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
from typing import Optional, Any, Dict
|
|
2
|
-
from
|
|
2
|
+
from .. import backend
|
|
3
3
|
from .phase import Phase
|
|
4
|
-
from .utils import _add_other_properties
|
|
4
|
+
from .utils import _add_other_properties
|
|
5
|
+
|
|
6
|
+
_backend = backend.get_backend()
|
|
7
|
+
_WetDeposition = _backend._mechanism_configuration._WetDeposition
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
class WetDeposition(_WetDeposition):
|
|
@@ -11,7 +14,7 @@ class WetDeposition(_WetDeposition):
|
|
|
11
14
|
Attributes:
|
|
12
15
|
name (str): The name of the wet deposition reaction rate constant.
|
|
13
16
|
scaling_factor (float): The scaling factor for the wet deposition rate constant.
|
|
14
|
-
|
|
17
|
+
condensed_phase (Phase): The condensed phase which undergoes wet deposition.
|
|
15
18
|
unknown_properties (Dict[str, Any]): A dictionary of other properties of the wet deposition reaction rate constant.
|
|
16
19
|
"""
|
|
17
20
|
|
|
@@ -19,7 +22,7 @@ class WetDeposition(_WetDeposition):
|
|
|
19
22
|
self,
|
|
20
23
|
name: Optional[str] = None,
|
|
21
24
|
scaling_factor: Optional[float] = None,
|
|
22
|
-
|
|
25
|
+
condensed_phase: Optional[Phase] = None,
|
|
23
26
|
other_properties: Optional[Dict[str, Any]] = None,
|
|
24
27
|
):
|
|
25
28
|
"""
|
|
@@ -28,13 +31,13 @@ class WetDeposition(_WetDeposition):
|
|
|
28
31
|
Args:
|
|
29
32
|
name (str): The name of the wet deposition reaction rate constant.
|
|
30
33
|
scaling_factor (float): The scaling factor for the wet deposition rate constant.
|
|
31
|
-
|
|
34
|
+
condensed_phase (Phase): The condensed phase which undergoes wet deposition.
|
|
32
35
|
other_properties (Dict[str, Any]): A dictionary of other properties of the wet deposition reaction rate constant.
|
|
33
36
|
"""
|
|
34
37
|
super().__init__()
|
|
35
38
|
self.name = name if name is not None else self.name
|
|
36
39
|
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
37
|
-
self.
|
|
40
|
+
self.condensed_phase = condensed_phase.name if condensed_phase is not None else self.condensed_phase
|
|
38
41
|
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
39
42
|
|
|
40
43
|
@staticmethod
|
|
@@ -43,7 +46,7 @@ class WetDeposition(_WetDeposition):
|
|
|
43
46
|
"type": "WET_DEPOSITION",
|
|
44
47
|
"name": instance.name,
|
|
45
48
|
"scaling factor": instance.scaling_factor,
|
|
46
|
-
"
|
|
49
|
+
"condensed phase": instance.condensed_phase,
|
|
47
50
|
}
|
|
48
51
|
_add_other_properties(serialize_dict, instance.other_properties)
|
|
49
|
-
return
|
|
52
|
+
return serialize_dict
|