musica 0.11.1.3__cp39-cp39-macosx_11_0_arm64.whl → 0.12.0__cp39-cp39-macosx_11_0_arm64.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 +35 -40
- musica/__init__.py +51 -3
- musica/_musica.cpython-39-darwin.so +0 -0
- musica/_version.py +1 -1
- musica/binding_common.cpp +16 -0
- musica/binding_common.hpp +7 -0
- musica/constants.py +3 -0
- musica/cpu_binding.cpp +10 -0
- musica/cuda.cpp +12 -0
- musica/cuda.py +10 -0
- musica/gpu_binding.cpp +10 -0
- musica/mechanism_configuration/__init__.py +1 -0
- musica/mechanism_configuration/aqueous_equilibrium.py +101 -0
- musica/mechanism_configuration/arrhenius.py +121 -0
- musica/mechanism_configuration/branched.py +116 -0
- musica/mechanism_configuration/condensed_phase_arrhenius.py +116 -0
- musica/mechanism_configuration/condensed_phase_photolysis.py +91 -0
- musica/mechanism_configuration/emission.py +67 -0
- musica/mechanism_configuration/first_order_loss.py +67 -0
- musica/mechanism_configuration/henrys_law.py +85 -0
- musica/mechanism_configuration/mechanism_configuration.py +161 -0
- musica/mechanism_configuration/phase.py +43 -0
- musica/mechanism_configuration/photolysis.py +83 -0
- musica/mechanism_configuration/reactions.py +61 -0
- musica/mechanism_configuration/simpol_phase_transfer.py +88 -0
- musica/mechanism_configuration/species.py +72 -0
- musica/mechanism_configuration/surface.py +89 -0
- musica/mechanism_configuration/troe.py +137 -0
- musica/mechanism_configuration/tunneling.py +103 -0
- musica/mechanism_configuration/user_defined.py +83 -0
- musica/mechanism_configuration/utils.py +10 -0
- musica/mechanism_configuration/wet_deposition.py +49 -0
- musica/mechanism_configuration.cpp +0 -1
- musica/musica.cpp +1 -1
- musica/test/examples/v1/{full_configuration.json → full_configuration/full_configuration.json} +30 -15
- musica/test/examples/v1/{full_configuration.yaml → full_configuration/full_configuration.yaml} +16 -1
- musica/test/test_analytical.py +14 -12
- musica/test/test_chapman.py +18 -2
- musica/test/test_parser.py +4 -640
- musica/test/test_serializer.py +69 -0
- musica/test/test_util_full_mechanism.py +668 -0
- musica/tools/prepare_build_environment_linux.sh +8 -6
- musica/tools/repair_wheel_gpu.sh +25 -16
- musica/types.py +4 -6
- {musica-0.11.1.3.dist-info → musica-0.12.0.dist-info}/METADATA +179 -43
- musica-0.12.0.dist-info/RECORD +57 -0
- {musica-0.11.1.3.dist-info → musica-0.12.0.dist-info}/WHEEL +1 -1
- musica-0.12.0.dist-info/licenses/AUTHORS.md +59 -0
- musica/binding.cpp +0 -19
- musica/lib/libmusica.a +0 -0
- musica/lib/libyaml-cpp.a +0 -0
- musica/mechanism_configuration.py +0 -1291
- musica-0.11.1.3.dist-info/RECORD +0 -30
- {musica-0.11.1.3.dist-info → musica-0.12.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _UserDefined, _ReactionComponent
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .species import Species
|
|
5
|
+
from .reactions import ReactionComponentSerializer
|
|
6
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UserDefined(_UserDefined):
|
|
10
|
+
"""
|
|
11
|
+
A class representing a user-defined reaction rate constant.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
name (str): The name of the photolysis reaction rate constant.
|
|
15
|
+
scaling_factor (float): The scaling factor for the photolysis rate constant.
|
|
16
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
17
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
18
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
19
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
name: Optional[str] = None,
|
|
25
|
+
scaling_factor: Optional[float] = None,
|
|
26
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
27
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
28
|
+
gas_phase: Optional[Phase] = None,
|
|
29
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
30
|
+
):
|
|
31
|
+
"""
|
|
32
|
+
Initializes the UserDefined object with the given parameters.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
name (str): The name of the photolysis reaction rate constant.
|
|
36
|
+
scaling_factor (float): The scaling factor for the photolysis rate constant.
|
|
37
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
38
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
39
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
40
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
|
|
41
|
+
"""
|
|
42
|
+
super().__init__()
|
|
43
|
+
self.name = name if name is not None else self.name
|
|
44
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
45
|
+
self.reactants = (
|
|
46
|
+
[
|
|
47
|
+
(
|
|
48
|
+
_ReactionComponent(r.name)
|
|
49
|
+
if isinstance(r, Species)
|
|
50
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
51
|
+
)
|
|
52
|
+
for r in reactants
|
|
53
|
+
]
|
|
54
|
+
if reactants is not None
|
|
55
|
+
else self.reactants
|
|
56
|
+
)
|
|
57
|
+
self.products = (
|
|
58
|
+
[
|
|
59
|
+
(
|
|
60
|
+
_ReactionComponent(p.name)
|
|
61
|
+
if isinstance(p, Species)
|
|
62
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
63
|
+
)
|
|
64
|
+
for p in products
|
|
65
|
+
]
|
|
66
|
+
if products is not None
|
|
67
|
+
else self.products
|
|
68
|
+
)
|
|
69
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
70
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
71
|
+
|
|
72
|
+
@staticmethod
|
|
73
|
+
def serialize(instance) -> Dict:
|
|
74
|
+
serialize_dict = {
|
|
75
|
+
"type": "USER_DEFINED",
|
|
76
|
+
"name": instance.name,
|
|
77
|
+
"scaling factor": instance.scaling_factor,
|
|
78
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
79
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
80
|
+
"gas phase": instance.gas_phase,
|
|
81
|
+
}
|
|
82
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
83
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -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,49 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict
|
|
2
|
+
from musica import _WetDeposition
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class WetDeposition(_WetDeposition):
|
|
8
|
+
"""
|
|
9
|
+
A class representing a wet deposition reaction rate constant.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
name (str): The name of the wet deposition reaction rate constant.
|
|
13
|
+
scaling_factor (float): The scaling factor for the wet deposition rate constant.
|
|
14
|
+
aerosol_phase (Phase): The aerosol phase which undergoes wet deposition.
|
|
15
|
+
unknown_properties (Dict[str, Any]): A dictionary of other properties of the wet deposition reaction rate constant.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
name: Optional[str] = None,
|
|
21
|
+
scaling_factor: Optional[float] = None,
|
|
22
|
+
aerosol_phase: Optional[Phase] = None,
|
|
23
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
24
|
+
):
|
|
25
|
+
"""
|
|
26
|
+
Initializes the WetDeposition object with the given parameters.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
name (str): The name of the wet deposition reaction rate constant.
|
|
30
|
+
scaling_factor (float): The scaling factor for the wet deposition rate constant.
|
|
31
|
+
aerosol_phase (Phase): The aerosol phase which undergoes wet deposition.
|
|
32
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the wet deposition reaction rate constant.
|
|
33
|
+
"""
|
|
34
|
+
super().__init__()
|
|
35
|
+
self.name = name if name is not None else self.name
|
|
36
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
37
|
+
self.aerosol_phase = aerosol_phase.name if aerosol_phase is not None else self.aerosol_phase
|
|
38
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
39
|
+
|
|
40
|
+
@staticmethod
|
|
41
|
+
def serialize(instance) -> Dict:
|
|
42
|
+
serialize_dict = {
|
|
43
|
+
"type": "WET_DEPOSITION",
|
|
44
|
+
"name": instance.name,
|
|
45
|
+
"scaling factor": instance.scaling_factor,
|
|
46
|
+
"aerosol phase": instance.aerosol_phase,
|
|
47
|
+
}
|
|
48
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
49
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -374,7 +374,6 @@ void bind_mechanism_configuration(py::module_ & mechanism_configuration)
|
|
|
374
374
|
py::class_<AqueousEquilibrium>(mechanism_configuration, "_AqueousEquilibrium")
|
|
375
375
|
.def(py::init<>())
|
|
376
376
|
.def_readwrite("name", &AqueousEquilibrium::name)
|
|
377
|
-
.def_readwrite("gas_phase", &AqueousEquilibrium::gas_phase)
|
|
378
377
|
.def_readwrite("aerosol_phase", &AqueousEquilibrium::aerosol_phase)
|
|
379
378
|
.def_readwrite("aerosol_phase_water", &AqueousEquilibrium::aerosol_phase_water)
|
|
380
379
|
.def_readwrite("reactants", &AqueousEquilibrium::reactants)
|
musica/musica.cpp
CHANGED
musica/test/examples/v1/{full_configuration.json → full_configuration/full_configuration.json}
RENAMED
|
@@ -108,7 +108,8 @@
|
|
|
108
108
|
"aerosol phase": "aqueous aerosol",
|
|
109
109
|
"aerosol-phase species": "H2O2_aq",
|
|
110
110
|
"aerosol-phase water": "H2O_aq",
|
|
111
|
-
"name": "my henry's law"
|
|
111
|
+
"name": "my henry's law",
|
|
112
|
+
"__irrelevant": "2"
|
|
112
113
|
},
|
|
113
114
|
{
|
|
114
115
|
"type": "SIMPOL_PHASE_TRANSFER",
|
|
@@ -122,7 +123,8 @@
|
|
|
122
123
|
1.96E-03,
|
|
123
124
|
-4.96E-01
|
|
124
125
|
],
|
|
125
|
-
"name": "my simpol"
|
|
126
|
+
"name": "my simpol",
|
|
127
|
+
"__irrelevant": "2"
|
|
126
128
|
},
|
|
127
129
|
{
|
|
128
130
|
"type": "AQUEOUS_EQUILIBRIUM",
|
|
@@ -147,7 +149,8 @@
|
|
|
147
149
|
"coefficient": 1
|
|
148
150
|
}
|
|
149
151
|
],
|
|
150
|
-
"name": "my aqueous eq"
|
|
152
|
+
"name": "my aqueous eq",
|
|
153
|
+
"__irrelevant": "2"
|
|
151
154
|
},
|
|
152
155
|
{
|
|
153
156
|
"type": "CONDENSED_PHASE_ARRHENIUS",
|
|
@@ -174,7 +177,8 @@
|
|
|
174
177
|
"coefficient": 1
|
|
175
178
|
}
|
|
176
179
|
],
|
|
177
|
-
"name": "my condensed arrhenius"
|
|
180
|
+
"name": "my condensed arrhenius",
|
|
181
|
+
"__irrelevant": "2"
|
|
178
182
|
},
|
|
179
183
|
{
|
|
180
184
|
"type": "CONDENSED_PHASE_ARRHENIUS",
|
|
@@ -220,7 +224,8 @@
|
|
|
220
224
|
}
|
|
221
225
|
],
|
|
222
226
|
"scaling factor": 12.3,
|
|
223
|
-
"name": "condensed photo B"
|
|
227
|
+
"name": "condensed photo B",
|
|
228
|
+
"__irrelevant": "2"
|
|
224
229
|
},
|
|
225
230
|
{
|
|
226
231
|
"type": "EMISSION",
|
|
@@ -232,7 +237,8 @@
|
|
|
232
237
|
}
|
|
233
238
|
],
|
|
234
239
|
"name": "my emission",
|
|
235
|
-
"scaling factor": 12.3
|
|
240
|
+
"scaling factor": 12.3,
|
|
241
|
+
"__irrelevant": "2"
|
|
236
242
|
},
|
|
237
243
|
{
|
|
238
244
|
"type": "FIRST_ORDER_LOSS",
|
|
@@ -244,7 +250,8 @@
|
|
|
244
250
|
}
|
|
245
251
|
],
|
|
246
252
|
"name": "my first order loss",
|
|
247
|
-
"scaling factor": 12.3
|
|
253
|
+
"scaling factor": 12.3,
|
|
254
|
+
"__irrelevant": "2"
|
|
248
255
|
},
|
|
249
256
|
{
|
|
250
257
|
"type": "PHOTOLYSIS",
|
|
@@ -262,7 +269,8 @@
|
|
|
262
269
|
}
|
|
263
270
|
],
|
|
264
271
|
"name": "photo B",
|
|
265
|
-
"scaling factor": 12.3
|
|
272
|
+
"scaling factor": 12.3,
|
|
273
|
+
"__irrelevant": "2"
|
|
266
274
|
},
|
|
267
275
|
{
|
|
268
276
|
"type": "SURFACE",
|
|
@@ -280,7 +288,8 @@
|
|
|
280
288
|
}
|
|
281
289
|
],
|
|
282
290
|
"aerosol phase": "surface reacting phase",
|
|
283
|
-
"name": "my surface"
|
|
291
|
+
"name": "my surface",
|
|
292
|
+
"__irrelevant": "2"
|
|
284
293
|
},
|
|
285
294
|
{
|
|
286
295
|
"type": "TROE",
|
|
@@ -309,7 +318,8 @@
|
|
|
309
318
|
"kinf_C": 24,
|
|
310
319
|
"Fc": 0.9,
|
|
311
320
|
"N": 0.8,
|
|
312
|
-
"name": "my troe"
|
|
321
|
+
"name": "my troe",
|
|
322
|
+
"__irrelevant": "2"
|
|
313
323
|
},
|
|
314
324
|
{
|
|
315
325
|
"type": "BRANCHED_NO_RO2",
|
|
@@ -336,7 +346,8 @@
|
|
|
336
346
|
"Y": 167,
|
|
337
347
|
"a0": 0.15,
|
|
338
348
|
"n": 9,
|
|
339
|
-
"name": "my branched"
|
|
349
|
+
"name": "my branched",
|
|
350
|
+
"__irrelevant": "2"
|
|
340
351
|
},
|
|
341
352
|
{
|
|
342
353
|
"gas phase": "gas",
|
|
@@ -356,13 +367,15 @@
|
|
|
356
367
|
"species name": "C",
|
|
357
368
|
"coefficient": 1
|
|
358
369
|
}
|
|
359
|
-
]
|
|
370
|
+
],
|
|
371
|
+
"__irrelevant": "2"
|
|
360
372
|
},
|
|
361
373
|
{
|
|
362
374
|
"type": "WET_DEPOSITION",
|
|
363
375
|
"aerosol phase": "cloud",
|
|
364
376
|
"name": "rxn cloud",
|
|
365
|
-
"scaling factor": 12.3
|
|
377
|
+
"scaling factor": 12.3,
|
|
378
|
+
"__irrelevant": "2"
|
|
366
379
|
},
|
|
367
380
|
{
|
|
368
381
|
"type": "ARRHENIUS",
|
|
@@ -384,7 +397,8 @@
|
|
|
384
397
|
"C": 102.3,
|
|
385
398
|
"D": 63.4,
|
|
386
399
|
"E": -1.3,
|
|
387
|
-
"name": "my arrhenius"
|
|
400
|
+
"name": "my arrhenius",
|
|
401
|
+
"__irrelevant": "2"
|
|
388
402
|
},
|
|
389
403
|
{
|
|
390
404
|
"type": "ARRHENIUS",
|
|
@@ -428,7 +442,8 @@
|
|
|
428
442
|
}
|
|
429
443
|
],
|
|
430
444
|
"name": "my user defined",
|
|
431
|
-
"scaling factor": 12.3
|
|
445
|
+
"scaling factor": 12.3,
|
|
446
|
+
"__irrelevant": "2"
|
|
432
447
|
}
|
|
433
448
|
]
|
|
434
449
|
}
|
musica/test/examples/v1/{full_configuration.yaml → full_configuration/full_configuration.yaml}
RENAMED
|
@@ -72,6 +72,7 @@ reactions:
|
|
|
72
72
|
aerosol-phase species: H2O2_aq
|
|
73
73
|
aerosol-phase water: H2O_aq
|
|
74
74
|
name: my henry's law
|
|
75
|
+
__irrelevant: "2"
|
|
75
76
|
- type: SIMPOL_PHASE_TRANSFER
|
|
76
77
|
gas phase: gas
|
|
77
78
|
gas-phase species: ethanol
|
|
@@ -83,6 +84,7 @@ reactions:
|
|
|
83
84
|
- 0.00196
|
|
84
85
|
- -0.496
|
|
85
86
|
name: my simpol
|
|
87
|
+
__irrelevant: "2"
|
|
86
88
|
- type: AQUEOUS_EQUILIBRIUM
|
|
87
89
|
aerosol phase: aqueous aerosol
|
|
88
90
|
aerosol-phase water: H2O_aq
|
|
@@ -98,6 +100,7 @@ reactions:
|
|
|
98
100
|
- species name: C
|
|
99
101
|
coefficient: 1
|
|
100
102
|
name: my aqueous eq
|
|
103
|
+
__irrelevant: "2"
|
|
101
104
|
- type: CONDENSED_PHASE_ARRHENIUS
|
|
102
105
|
aerosol phase: aqueous aerosol
|
|
103
106
|
aerosol-phase water: H2O_aq
|
|
@@ -115,6 +118,7 @@ reactions:
|
|
|
115
118
|
- species name: ethanol_aq
|
|
116
119
|
coefficient: 1
|
|
117
120
|
name: my condensed arrhenius
|
|
121
|
+
__irrelevant: "2"
|
|
118
122
|
- type: CONDENSED_PHASE_ARRHENIUS
|
|
119
123
|
aerosol phase: aqueous aerosol
|
|
120
124
|
aerosol-phase water: H2O_aq
|
|
@@ -143,6 +147,7 @@ reactions:
|
|
|
143
147
|
coefficient: 1
|
|
144
148
|
scaling factor: 12.3
|
|
145
149
|
name: condensed photo B
|
|
150
|
+
__irrelevant: "2"
|
|
146
151
|
- type: EMISSION
|
|
147
152
|
gas phase: gas
|
|
148
153
|
products:
|
|
@@ -150,6 +155,7 @@ reactions:
|
|
|
150
155
|
coefficient: 1
|
|
151
156
|
name: my emission
|
|
152
157
|
scaling factor: 12.3
|
|
158
|
+
__irrelevant: "2"
|
|
153
159
|
- type: FIRST_ORDER_LOSS
|
|
154
160
|
gas phase: gas
|
|
155
161
|
reactants:
|
|
@@ -157,6 +163,7 @@ reactions:
|
|
|
157
163
|
coefficient: 1
|
|
158
164
|
name: my first order loss
|
|
159
165
|
scaling factor: 12.3
|
|
166
|
+
__irrelevant: "2"
|
|
160
167
|
- type: PHOTOLYSIS
|
|
161
168
|
gas phase: gas
|
|
162
169
|
reactants:
|
|
@@ -167,6 +174,7 @@ reactions:
|
|
|
167
174
|
coefficient: 1
|
|
168
175
|
name: photo B
|
|
169
176
|
scaling factor: 12.3
|
|
177
|
+
__irrelevant: "2"
|
|
170
178
|
- type: SURFACE
|
|
171
179
|
gas phase: gas
|
|
172
180
|
gas-phase species: A
|
|
@@ -178,6 +186,7 @@ reactions:
|
|
|
178
186
|
coefficient: 1
|
|
179
187
|
aerosol phase: surface reacting phase
|
|
180
188
|
name: my surface
|
|
189
|
+
__irrelevant: "2"
|
|
181
190
|
- type: TROE
|
|
182
191
|
gas phase: gas
|
|
183
192
|
reactants:
|
|
@@ -197,6 +206,7 @@ reactions:
|
|
|
197
206
|
Fc: 0.9
|
|
198
207
|
N: 0.8
|
|
199
208
|
name: my troe
|
|
209
|
+
__irrelevant: "2"
|
|
200
210
|
- type: BRANCHED_NO_RO2
|
|
201
211
|
gas phase: gas
|
|
202
212
|
reactants:
|
|
@@ -213,6 +223,7 @@ reactions:
|
|
|
213
223
|
a0: 0.15
|
|
214
224
|
"n": 9
|
|
215
225
|
name: my branched
|
|
226
|
+
__irrelevant: "2"
|
|
216
227
|
- gas phase: gas
|
|
217
228
|
type: TUNNELING
|
|
218
229
|
name: "my tunneling"
|
|
@@ -225,10 +236,12 @@ reactions:
|
|
|
225
236
|
products:
|
|
226
237
|
- species name: C
|
|
227
238
|
coefficient: 1
|
|
239
|
+
__irrelevant: "2"
|
|
228
240
|
- type: WET_DEPOSITION
|
|
229
241
|
aerosol phase: cloud
|
|
230
242
|
name: rxn cloud
|
|
231
243
|
scaling factor: 12.3
|
|
244
|
+
__irrelevant: "2"
|
|
232
245
|
- type: ARRHENIUS
|
|
233
246
|
gas phase: gas
|
|
234
247
|
reactants:
|
|
@@ -243,6 +256,7 @@ reactions:
|
|
|
243
256
|
D: 63.4
|
|
244
257
|
E: -1.3
|
|
245
258
|
name: my arrhenius
|
|
259
|
+
__irrelevant: "2"
|
|
246
260
|
- type: ARRHENIUS
|
|
247
261
|
gas phase: gas
|
|
248
262
|
reactants:
|
|
@@ -268,4 +282,5 @@ reactions:
|
|
|
268
282
|
- species name: C
|
|
269
283
|
coefficient: 1.3
|
|
270
284
|
name: my user defined
|
|
271
|
-
scaling factor: 12.3
|
|
285
|
+
scaling factor: 12.3
|
|
286
|
+
__irrelevant: "2"
|
musica/test/test_analytical.py
CHANGED
|
@@ -3,13 +3,13 @@ import numpy as np
|
|
|
3
3
|
import musica
|
|
4
4
|
import random
|
|
5
5
|
import musica.mechanism_configuration as mc
|
|
6
|
-
from musica.
|
|
6
|
+
from musica.cuda import is_cuda_available
|
|
7
|
+
from musica.constants import GAS_CONSTANT
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
def TestSingleGridCell(solver, state, time_step, places=5):
|
|
10
11
|
temperature = 272.5
|
|
11
12
|
pressure = 101253.3
|
|
12
|
-
GAS_CONSTANT = 8.31446261815324
|
|
13
13
|
air_density = pressure / (GAS_CONSTANT * temperature)
|
|
14
14
|
|
|
15
15
|
rate_constants = {
|
|
@@ -118,6 +118,7 @@ def TestMultipleGridCell(solver, state, num_grid_cells, time_step, places=5):
|
|
|
118
118
|
rate_constants["USER.reaction 2"].append(
|
|
119
119
|
0.002 + random.uniform(-0.0001, 0.0001))
|
|
120
120
|
|
|
121
|
+
|
|
121
122
|
state.set_conditions(temperatures, pressures) # Air density should be calculated in the state
|
|
122
123
|
state.set_concentrations(concentrations)
|
|
123
124
|
state.set_user_defined_rate_parameters(rate_constants)
|
|
@@ -127,6 +128,7 @@ def TestMultipleGridCell(solver, state, num_grid_cells, time_step, places=5):
|
|
|
127
128
|
initial_temperatures = state.get_conditions()["temperature"]
|
|
128
129
|
initial_pressures = state.get_conditions()["pressure"]
|
|
129
130
|
initial_air_density = state.get_conditions()["air_density"]
|
|
131
|
+
|
|
130
132
|
for i in range(num_grid_cells):
|
|
131
133
|
assert np.isclose(initial_concentrations["A"][i], concentrations["A"][i], atol=1e-13)
|
|
132
134
|
assert np.isclose(initial_concentrations["B"][i], concentrations["B"][i], atol=1e-13)
|
|
@@ -242,7 +244,7 @@ def GetMechanism():
|
|
|
242
244
|
|
|
243
245
|
def test_single_grid_cell_standard_rosenbrock():
|
|
244
246
|
solver = musica.MICM(
|
|
245
|
-
config_path="configs/analytical",
|
|
247
|
+
config_path="configs/v0/analytical",
|
|
246
248
|
solver_type=musica.SolverType.rosenbrock_standard_order)
|
|
247
249
|
state = solver.create_state()
|
|
248
250
|
TestSingleGridCell(solver, state, 200.0, 5)
|
|
@@ -251,16 +253,16 @@ def test_single_grid_cell_standard_rosenbrock():
|
|
|
251
253
|
def test_multiple_grid_cells_standard_rosenbrock():
|
|
252
254
|
for i in range(1, 11):
|
|
253
255
|
solver = musica.MICM(
|
|
254
|
-
config_path="configs/analytical",
|
|
256
|
+
config_path="configs/v0/analytical",
|
|
255
257
|
solver_type=musica.SolverType.rosenbrock_standard_order)
|
|
256
258
|
state = solver.create_state(i)
|
|
257
259
|
TestMultipleGridCell(solver, state, i, 200.0, 5)
|
|
258
260
|
|
|
259
261
|
|
|
260
262
|
def test_cuda_rosenbrock():
|
|
261
|
-
if
|
|
263
|
+
if is_cuda_available():
|
|
262
264
|
solver = musica.MICM(
|
|
263
|
-
config_path="configs/analytical",
|
|
265
|
+
config_path="configs/v0/analytical",
|
|
264
266
|
solver_type=musica.SolverType.cuda_rosenbrock)
|
|
265
267
|
state = solver.create_state()
|
|
266
268
|
TestSingleGridCell(solver, state, 200.0, 5)
|
|
@@ -270,7 +272,7 @@ def test_cuda_rosenbrock():
|
|
|
270
272
|
|
|
271
273
|
def test_single_grid_cell_backward_euler():
|
|
272
274
|
solver = musica.MICM(
|
|
273
|
-
config_path="configs/analytical",
|
|
275
|
+
config_path="configs/v0/analytical",
|
|
274
276
|
solver_type=musica.SolverType.backward_euler_standard_order)
|
|
275
277
|
state = solver.create_state()
|
|
276
278
|
TestSingleGridCell(solver, state, 10.0, places=2)
|
|
@@ -279,7 +281,7 @@ def test_single_grid_cell_backward_euler():
|
|
|
279
281
|
def test_multiple_grid_cells_backward_euler():
|
|
280
282
|
for i in range(1, 11):
|
|
281
283
|
solver = musica.MICM(
|
|
282
|
-
config_path="configs/analytical",
|
|
284
|
+
config_path="configs/v0/analytical",
|
|
283
285
|
solver_type=musica.SolverType.backward_euler_standard_order)
|
|
284
286
|
state = solver.create_state(i)
|
|
285
287
|
TestMultipleGridCell(solver, state, i, 10.0, places=2)
|
|
@@ -287,7 +289,7 @@ def test_multiple_grid_cells_backward_euler():
|
|
|
287
289
|
|
|
288
290
|
def test_single_grid_cell_rosenbrock():
|
|
289
291
|
solver = musica.MICM(
|
|
290
|
-
config_path="configs/analytical",
|
|
292
|
+
config_path="configs/v0/analytical",
|
|
291
293
|
solver_type=musica.SolverType.rosenbrock)
|
|
292
294
|
state = solver.create_state()
|
|
293
295
|
TestSingleGridCell(solver, state, 200.0, 5)
|
|
@@ -296,7 +298,7 @@ def test_single_grid_cell_rosenbrock():
|
|
|
296
298
|
def test_multiple_grid_cells_rosenbrock():
|
|
297
299
|
for i in range(1, 11):
|
|
298
300
|
solver = musica.MICM(
|
|
299
|
-
config_path="configs/analytical",
|
|
301
|
+
config_path="configs/v0/analytical",
|
|
300
302
|
solver_type=musica.SolverType.rosenbrock)
|
|
301
303
|
state = solver.create_state(i)
|
|
302
304
|
TestMultipleGridCell(solver, state, i, 200.0, 5)
|
|
@@ -304,7 +306,7 @@ def test_multiple_grid_cells_rosenbrock():
|
|
|
304
306
|
|
|
305
307
|
def test_single_grid_cell_backward_euler_standard_order():
|
|
306
308
|
solver = musica.MICM(
|
|
307
|
-
config_path="configs/analytical",
|
|
309
|
+
config_path="configs/v0/analytical",
|
|
308
310
|
solver_type=musica.SolverType.backward_euler_standard_order)
|
|
309
311
|
state = solver.create_state()
|
|
310
312
|
TestSingleGridCell(solver, state, 10.0, places=2)
|
|
@@ -313,7 +315,7 @@ def test_single_grid_cell_backward_euler_standard_order():
|
|
|
313
315
|
def test_multiple_grid_cells_backward_euler_standard_order():
|
|
314
316
|
for i in range(1, 11):
|
|
315
317
|
solver = musica.MICM(
|
|
316
|
-
config_path="configs/analytical",
|
|
318
|
+
config_path="configs/v0/analytical",
|
|
317
319
|
solver_type=musica.SolverType.backward_euler_standard_order)
|
|
318
320
|
state = solver.create_state(i)
|
|
319
321
|
TestMultipleGridCell(solver, state, i, 10.0, places=2)
|
musica/test/test_chapman.py
CHANGED
|
@@ -3,9 +3,25 @@ import musica
|
|
|
3
3
|
import musica.mechanism_configuration as mc
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def
|
|
6
|
+
def test_solve_with_config_path_v0():
|
|
7
7
|
solver = musica.MICM(
|
|
8
|
-
config_path="configs/chapman",
|
|
8
|
+
config_path="configs/v0/chapman",
|
|
9
|
+
solver_type=musica.SolverType.rosenbrock_standard_order,
|
|
10
|
+
)
|
|
11
|
+
TestSolve(solver)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_solve_with_config_path_v1_json():
|
|
15
|
+
solver = musica.MICM(
|
|
16
|
+
config_path="configs/v1/chapman/config.json",
|
|
17
|
+
solver_type=musica.SolverType.rosenbrock_standard_order,
|
|
18
|
+
)
|
|
19
|
+
TestSolve(solver)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_solve_with_config_path_v1_yaml():
|
|
23
|
+
solver = musica.MICM(
|
|
24
|
+
config_path="configs/v1/chapman/config.yaml",
|
|
9
25
|
solver_type=musica.SolverType.rosenbrock_standard_order,
|
|
10
26
|
)
|
|
11
27
|
TestSolve(solver)
|