musica 0.11.1.4__cp311-cp311-win_amd64.whl → 0.12.0__cp311-cp311-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/_musica.cp311-win_amd64.pyd +0 -0
- musica/_version.py +1 -1
- musica/constants.py +3 -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/test/examples/v1/full_configuration/full_configuration.json +30 -15
- musica/test/examples/v1/full_configuration/full_configuration.yaml +16 -1
- musica/test/test_analytical.py +1 -1
- musica/test/test_parser.py +3 -639
- musica/test/test_serializer.py +69 -0
- musica/test/test_util_full_mechanism.py +668 -0
- musica/types.py +1 -4
- {musica-0.11.1.4.dist-info → musica-0.12.0.dist-info}/METADATA +61 -46
- musica-0.12.0.dist-info/RECORD +57 -0
- musica-0.12.0.dist-info/licenses/AUTHORS.md +59 -0
- musica/mechanism_configuration.py +0 -1291
- musica-0.11.1.4.dist-info/RECORD +0 -33
- {musica-0.11.1.4.dist-info → musica-0.12.0.dist-info}/WHEEL +0 -0
- {musica-0.11.1.4.dist-info → musica-0.12.0.dist-info}/licenses/LICENSE +0 -0
musica/test/test_parser.py
CHANGED
|
@@ -1,399 +1,6 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from musica.mechanism_configuration import *
|
|
3
|
-
from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def validate_species(species):
|
|
7
|
-
# Define the expected species and their required attributes
|
|
8
|
-
expected_species = {
|
|
9
|
-
"A": {"other_properties": {"__absolute tolerance": "1e-30"}},
|
|
10
|
-
"B": {"tracer_type": "AEROSOL"},
|
|
11
|
-
"C": {"tracer_type": "THIRD_BODY"},
|
|
12
|
-
"M": {},
|
|
13
|
-
"H2O2": {
|
|
14
|
-
"HLC_298K_mol_m3_Pa": 1.011596348,
|
|
15
|
-
"HLC_exponential_factor_K": 6340,
|
|
16
|
-
"diffusion_coefficient_m2_s": 1.46e-05,
|
|
17
|
-
"N_star": 1.74,
|
|
18
|
-
"molecular_weight_kg_mol": 0.0340147,
|
|
19
|
-
"density_kg_m3": 1000.0,
|
|
20
|
-
"other_properties": {"__absolute tolerance": "1e-10"},
|
|
21
|
-
},
|
|
22
|
-
"ethanol": {
|
|
23
|
-
"diffusion_coefficient_m2_s": 0.95e-05,
|
|
24
|
-
"N_star": 2.55,
|
|
25
|
-
"molecular_weight_kg_mol": 0.04607,
|
|
26
|
-
"other_properties": {"__absolute tolerance": "1e-20"},
|
|
27
|
-
},
|
|
28
|
-
"ethanol_aq": {
|
|
29
|
-
"molecular_weight_kg_mol": 0.04607,
|
|
30
|
-
"density_kg_m3": 1000.0,
|
|
31
|
-
"other_properties": {"__absolute tolerance": "1e-20"},
|
|
32
|
-
},
|
|
33
|
-
"H2O2_aq": {
|
|
34
|
-
"molecular_weight_kg_mol": 0.0340147,
|
|
35
|
-
"density_kg_m3": 1000.0,
|
|
36
|
-
"other_properties": {"__absolute tolerance": "1e-10"},
|
|
37
|
-
},
|
|
38
|
-
"H2O_aq": {
|
|
39
|
-
"density_kg_m3": 1000.0,
|
|
40
|
-
"molecular_weight_kg_mol": 0.01801,
|
|
41
|
-
},
|
|
42
|
-
"aerosol stuff": {
|
|
43
|
-
"molecular_weight_kg_mol": 0.5,
|
|
44
|
-
"density_kg_m3": 1000.0,
|
|
45
|
-
"other_properties": {"__absolute tolerance": "1e-20"},
|
|
46
|
-
},
|
|
47
|
-
"more aerosol stuff": {
|
|
48
|
-
"molecular_weight_kg_mol": 0.2,
|
|
49
|
-
"density_kg_m3": 1000.0,
|
|
50
|
-
"other_properties": {"__absolute tolerance": "1e-20"},
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
# Create a dictionary for quick lookup of species by name
|
|
55
|
-
species_dict = {sp.name: sp for sp in species}
|
|
56
|
-
|
|
57
|
-
# Validate each expected species
|
|
58
|
-
for name, attributes in expected_species.items():
|
|
59
|
-
assert name in species_dict, f"Species '{name}' is missing."
|
|
60
|
-
for attr, expected_value in attributes.items():
|
|
61
|
-
assert hasattr(
|
|
62
|
-
species_dict[name], attr
|
|
63
|
-
), f"Attribute '{attr}' is missing for species '{name}'."
|
|
64
|
-
got_value = getattr(species_dict[name], attr)
|
|
65
|
-
# Handle special cases for floating-point representation
|
|
66
|
-
if isinstance(got_value, str) and ".0e" in got_value:
|
|
67
|
-
got_value = got_value.replace(".0e", "e")
|
|
68
|
-
elif isinstance(got_value, dict):
|
|
69
|
-
def replace_in_dict(d):
|
|
70
|
-
for key, value in d.items():
|
|
71
|
-
if isinstance(value, str) and ".0e" in value:
|
|
72
|
-
d[key] = value.replace(".0e", "e")
|
|
73
|
-
elif isinstance(value, dict):
|
|
74
|
-
replace_in_dict(value)
|
|
75
|
-
replace_in_dict(got_value)
|
|
76
|
-
assert got_value == expected_value, (
|
|
77
|
-
f"Attribute '{attr}' for species '{name}' has value "
|
|
78
|
-
f"{got_value}, expected {expected_value}."
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def validate_phases(phases):
|
|
83
|
-
# Define the expected phases and their associated species
|
|
84
|
-
expected_phases = {
|
|
85
|
-
"gas": ["A", "B", "C", "ethanol"],
|
|
86
|
-
"aqueous aerosol": ["H2O2_aq", "H2O_aq", "ethanol_aq", "A", "B", "C"],
|
|
87
|
-
"surface reacting phase": ["aerosol stuff", "more aerosol stuff"],
|
|
88
|
-
"cloud": ["B", "C"],
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
# Create a dictionary for quick lookup of phases by name
|
|
92
|
-
phases_dict = {phase.name: phase for phase in phases}
|
|
93
|
-
|
|
94
|
-
# Validate each expected phase
|
|
95
|
-
for name, expected_species in expected_phases.items():
|
|
96
|
-
assert name in phases_dict, f"Phase '{name}' is missing."
|
|
97
|
-
assert hasattr(
|
|
98
|
-
phases_dict[name], "species"
|
|
99
|
-
), f"Phase '{name}' does not have a 'species' attribute."
|
|
100
|
-
phase_species = getattr(phases_dict[name], "species")
|
|
101
|
-
assert set(phase_species) == set(expected_species), (
|
|
102
|
-
f"Phase '{name}' has species {phase_species}, "
|
|
103
|
-
f"expected {expected_species}."
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def extract_components(components):
|
|
108
|
-
return [
|
|
109
|
-
{"species name": component.species_name, "coefficient": component.coefficient}
|
|
110
|
-
for component in components
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def validate_arrhenius(reactions):
|
|
115
|
-
assert reactions[0].type == ReactionType.Arrhenius
|
|
116
|
-
assert extract_components(reactions[0].reactants) == [
|
|
117
|
-
{"species name": "B", "coefficient": 1}
|
|
118
|
-
]
|
|
119
|
-
assert extract_components(reactions[0].products) == [
|
|
120
|
-
{"species name": "C", "coefficient": 1}
|
|
121
|
-
]
|
|
122
|
-
assert reactions[0].A == 32.1
|
|
123
|
-
assert reactions[0].B == -2.3
|
|
124
|
-
assert reactions[0].C == 102.3
|
|
125
|
-
assert reactions[0].D == 63.4
|
|
126
|
-
assert reactions[0].E == -1.3
|
|
127
|
-
assert reactions[0].name == "my arrhenius"
|
|
128
|
-
assert reactions[0].other_properties == {}
|
|
129
|
-
assert reactions[1].type == ReactionType.Arrhenius
|
|
130
|
-
assert extract_components(reactions[1].reactants) == [
|
|
131
|
-
{"species name": "A", "coefficient": 1}
|
|
132
|
-
]
|
|
133
|
-
assert extract_components(reactions[1].products) == [
|
|
134
|
-
{"species name": "B", "coefficient": 1.2}
|
|
135
|
-
]
|
|
136
|
-
assert reactions[1].A == 29.3
|
|
137
|
-
assert reactions[1].B == -1.5
|
|
138
|
-
assert reactions[1].C == -101.2 / 1.380649e-23
|
|
139
|
-
assert reactions[1].D == 82.6
|
|
140
|
-
assert reactions[1].E == -0.98
|
|
141
|
-
assert reactions[1].name == "my other arrhenius"
|
|
142
|
-
assert reactions[1].other_properties == {}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def validate_henrys_law(reactions):
|
|
146
|
-
assert reactions[0].type == ReactionType.HenrysLaw
|
|
147
|
-
assert reactions[0].gas_phase == "gas"
|
|
148
|
-
assert extract_components([reactions[0].gas_phase_species]) == [
|
|
149
|
-
{"species name": "H2O2", "coefficient": 1}
|
|
150
|
-
]
|
|
151
|
-
assert reactions[0].aerosol_phase == "aqueous aerosol"
|
|
152
|
-
assert extract_components([reactions[0].aerosol_phase_species]) == [
|
|
153
|
-
{"species name": "H2O2_aq", "coefficient": 1}
|
|
154
|
-
]
|
|
155
|
-
assert reactions[0].aerosol_phase_water == "H2O_aq"
|
|
156
|
-
assert reactions[0].name == "my henry's law"
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def validate_simpol_phase_transfer(reactions):
|
|
160
|
-
assert reactions[0].type == ReactionType.SimpolPhaseTransfer
|
|
161
|
-
assert reactions[0].gas_phase == "gas"
|
|
162
|
-
assert extract_components([reactions[0].gas_phase_species]) == [
|
|
163
|
-
{"species name": "ethanol", "coefficient": 1}
|
|
164
|
-
]
|
|
165
|
-
assert reactions[0].aerosol_phase == "aqueous aerosol"
|
|
166
|
-
assert extract_components([reactions[0].aerosol_phase_species]) == [
|
|
167
|
-
{"species name": "ethanol_aq", "coefficient": 1}
|
|
168
|
-
]
|
|
169
|
-
assert reactions[0].B == [-1.97e03, 2.91e00, 1.96e-03, -4.96e-01]
|
|
170
|
-
assert reactions[0].name == "my simpol"
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
def validate_aqueous_equilibrium(reactions):
|
|
174
|
-
assert reactions[0].type == ReactionType.AqueousEquilibrium
|
|
175
|
-
assert reactions[0].aerosol_phase == "aqueous aerosol"
|
|
176
|
-
assert reactions[0].aerosol_phase_water == "H2O_aq"
|
|
177
|
-
assert reactions[0].A == 1.14e-2
|
|
178
|
-
assert reactions[0].C == 2300.0
|
|
179
|
-
assert reactions[0].k_reverse == 0.32
|
|
180
|
-
assert extract_components(reactions[0].reactants) == [
|
|
181
|
-
{"species name": "A", "coefficient": 2}
|
|
182
|
-
]
|
|
183
|
-
assert extract_components(reactions[0].products) == [
|
|
184
|
-
{"species name": "B", "coefficient": 1},
|
|
185
|
-
{"species name": "C", "coefficient": 1},
|
|
186
|
-
]
|
|
187
|
-
assert reactions[0].name == "my aqueous eq"
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
def validate_condensed_phase_arrhenius(reactions):
|
|
191
|
-
for reaction in reactions:
|
|
192
|
-
assert reaction.type == ReactionType.CondensedPhaseArrhenius
|
|
193
|
-
assert reaction.aerosol_phase == "aqueous aerosol"
|
|
194
|
-
assert reaction.aerosol_phase_water == "H2O_aq"
|
|
195
|
-
assert reaction.A == 123.45
|
|
196
|
-
assert reaction.B == 1.3
|
|
197
|
-
assert reaction.D == 300.0
|
|
198
|
-
assert reaction.E == 0.6e-5
|
|
199
|
-
assert extract_components(reaction.reactants) == [
|
|
200
|
-
{"species name": "H2O2_aq", "coefficient": 1},
|
|
201
|
-
{"species name": "H2O_aq", "coefficient": 1},
|
|
202
|
-
]
|
|
203
|
-
assert extract_components(reaction.products) == [
|
|
204
|
-
{"species name": "ethanol_aq", "coefficient": 1}
|
|
205
|
-
]
|
|
206
|
-
assert reactions[0].name == "my condensed arrhenius"
|
|
207
|
-
assert reactions[0].C == -123.45 / 1.380649e-23
|
|
208
|
-
assert reactions[1].name == "my other condensed arrhenius"
|
|
209
|
-
assert reactions[1].C == 123.45
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
def validate_condensed_phase_photolysis(reactions):
|
|
213
|
-
assert reactions[0].type == ReactionType.CondensedPhasePhotolysis
|
|
214
|
-
assert reactions[0].aerosol_phase == "aqueous aerosol"
|
|
215
|
-
assert reactions[0].aerosol_phase_water == "H2O_aq"
|
|
216
|
-
assert extract_components(reactions[0].reactants) == [
|
|
217
|
-
{"species name": "H2O2_aq", "coefficient": 1}
|
|
218
|
-
]
|
|
219
|
-
assert extract_components(reactions[0].products) == [
|
|
220
|
-
{"species name": "ethanol_aq", "coefficient": 1}
|
|
221
|
-
]
|
|
222
|
-
assert reactions[0].scaling_factor == 12.3
|
|
223
|
-
assert reactions[0].name == "condensed photo B"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
def validate_emission(reactions):
|
|
227
|
-
assert reactions[0].type == ReactionType.Emission
|
|
228
|
-
assert reactions[0].gas_phase == "gas"
|
|
229
|
-
assert extract_components(reactions[0].products) == [
|
|
230
|
-
{"species name": "B", "coefficient": 1}
|
|
231
|
-
]
|
|
232
|
-
assert reactions[0].scaling_factor == 12.3
|
|
233
|
-
assert reactions[0].name == "my emission"
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
def validate_first_order_loss(reactions):
|
|
237
|
-
assert reactions[0].type == ReactionType.FirstOrderLoss
|
|
238
|
-
assert reactions[0].gas_phase == "gas"
|
|
239
|
-
assert extract_components(reactions[0].reactants) == [
|
|
240
|
-
{"species name": "C", "coefficient": 1}
|
|
241
|
-
]
|
|
242
|
-
assert reactions[0].scaling_factor == 12.3
|
|
243
|
-
assert reactions[0].name == "my first order loss"
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
def validate_photolysis(reactions):
|
|
247
|
-
assert reactions[0].type == ReactionType.Photolysis
|
|
248
|
-
assert reactions[0].gas_phase == "gas"
|
|
249
|
-
assert extract_components(reactions[0].reactants) == [
|
|
250
|
-
{"species name": "B", "coefficient": 1}
|
|
251
|
-
]
|
|
252
|
-
assert extract_components(reactions[0].products) == [
|
|
253
|
-
{"species name": "C", "coefficient": 1}
|
|
254
|
-
]
|
|
255
|
-
assert reactions[0].scaling_factor == 12.3
|
|
256
|
-
assert reactions[0].name == "photo B"
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
def validate_surface(reactions):
|
|
260
|
-
assert reactions[0].type == ReactionType.Surface
|
|
261
|
-
assert reactions[0].gas_phase == "gas"
|
|
262
|
-
assert extract_components([reactions[0].gas_phase_species]) == [
|
|
263
|
-
{"species name": "A", "coefficient": 1}
|
|
264
|
-
]
|
|
265
|
-
assert reactions[0].reaction_probability == 2.0e-2
|
|
266
|
-
assert extract_components(reactions[0].gas_phase_products) == [
|
|
267
|
-
{"species name": "B", "coefficient": 1},
|
|
268
|
-
{"species name": "C", "coefficient": 1},
|
|
269
|
-
]
|
|
270
|
-
assert reactions[0].aerosol_phase == "surface reacting phase"
|
|
271
|
-
assert reactions[0].name == "my surface"
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
def validate_troe(reactions):
|
|
275
|
-
assert reactions[0].type == ReactionType.Troe
|
|
276
|
-
assert reactions[0].gas_phase == "gas"
|
|
277
|
-
assert extract_components(reactions[0].reactants) == [
|
|
278
|
-
{"species name": "B", "coefficient": 1},
|
|
279
|
-
{"species name": "M", "coefficient": 1},
|
|
280
|
-
]
|
|
281
|
-
assert extract_components(reactions[0].products) == [
|
|
282
|
-
{"species name": "C", "coefficient": 1}
|
|
283
|
-
]
|
|
284
|
-
assert reactions[0].k0_A == 1.2e-12
|
|
285
|
-
assert reactions[0].k0_B == 167
|
|
286
|
-
assert reactions[0].k0_C == 3
|
|
287
|
-
assert reactions[0].kinf_A == 136
|
|
288
|
-
assert reactions[0].kinf_B == 5
|
|
289
|
-
assert reactions[0].kinf_C == 24
|
|
290
|
-
assert reactions[0].Fc == 0.9
|
|
291
|
-
assert reactions[0].N == 0.8
|
|
292
|
-
assert reactions[0].name == "my troe"
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
def validate_branched_no_ro2(reactions):
|
|
296
|
-
assert reactions[0].type == ReactionType.Branched
|
|
297
|
-
assert reactions[0].gas_phase == "gas"
|
|
298
|
-
assert extract_components(reactions[0].reactants) == [
|
|
299
|
-
{"species name": "A", "coefficient": 1}
|
|
300
|
-
]
|
|
301
|
-
assert extract_components(reactions[0].alkoxy_products) == [
|
|
302
|
-
{"species name": "B", "coefficient": 1}
|
|
303
|
-
]
|
|
304
|
-
assert extract_components(reactions[0].nitrate_products) == [
|
|
305
|
-
{"species name": "C", "coefficient": 1}
|
|
306
|
-
]
|
|
307
|
-
assert reactions[0].X == 1.2e-4
|
|
308
|
-
assert reactions[0].Y == 167
|
|
309
|
-
assert reactions[0].a0 == 0.15
|
|
310
|
-
assert reactions[0].n == 9
|
|
311
|
-
assert reactions[0].name == "my branched"
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
def validate_tunneling(reactions):
|
|
315
|
-
assert reactions[0].type == ReactionType.Tunneling
|
|
316
|
-
assert reactions[0].gas_phase == "gas"
|
|
317
|
-
assert extract_components(reactions[0].reactants) == [
|
|
318
|
-
{"species name": "B", "coefficient": 1}
|
|
319
|
-
]
|
|
320
|
-
assert extract_components(reactions[0].products) == [
|
|
321
|
-
{"species name": "C", "coefficient": 1}
|
|
322
|
-
]
|
|
323
|
-
assert reactions[0].A == 123.45
|
|
324
|
-
assert reactions[0].B == 1200.0
|
|
325
|
-
assert reactions[0].C == 1.0e8
|
|
326
|
-
assert reactions[0].name == "my tunneling"
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
def validate_wet_deposition(reactions):
|
|
330
|
-
assert reactions[0].type == ReactionType.WetDeposition
|
|
331
|
-
assert reactions[0].name == "rxn cloud"
|
|
332
|
-
assert reactions[0].aerosol_phase == "cloud"
|
|
333
|
-
assert reactions[0].scaling_factor == 12.3
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
def validate_user_defined(reactions):
|
|
337
|
-
assert reactions[0].type == ReactionType.UserDefined
|
|
338
|
-
assert reactions[0].gas_phase == "gas"
|
|
339
|
-
assert extract_components(reactions[0].reactants) == [
|
|
340
|
-
{"species name": "A", "coefficient": 1},
|
|
341
|
-
{"species name": "B", "coefficient": 1},
|
|
342
|
-
]
|
|
343
|
-
assert extract_components(reactions[0].products) == [
|
|
344
|
-
{"species name": "C", "coefficient": 1.3}
|
|
345
|
-
]
|
|
346
|
-
assert reactions[0].scaling_factor == 12.3
|
|
347
|
-
assert reactions[0].name == "my user defined"
|
|
348
|
-
assert reactions[0].other_properties == {}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
def validate_full_v1_mechanism(mechanism):
|
|
352
|
-
assert mechanism is not None
|
|
353
|
-
assert mechanism.name == "Full Configuration"
|
|
354
|
-
assert len(mechanism.species) == 11
|
|
355
|
-
validate_species(mechanism.species)
|
|
356
|
-
assert len(mechanism.phases) == 4
|
|
357
|
-
validate_phases(mechanism.phases)
|
|
358
|
-
assert len(mechanism.reactions.aqueous_equilibrium) == 1
|
|
359
|
-
validate_aqueous_equilibrium(mechanism.reactions.aqueous_equilibrium)
|
|
360
|
-
assert len(mechanism.reactions.arrhenius) == 2
|
|
361
|
-
validate_arrhenius(mechanism.reactions.arrhenius)
|
|
362
|
-
assert len(mechanism.reactions.branched) == 1
|
|
363
|
-
validate_branched_no_ro2(mechanism.reactions.branched)
|
|
364
|
-
assert len(mechanism.reactions.condensed_phase_arrhenius) == 2
|
|
365
|
-
validate_condensed_phase_arrhenius(mechanism.reactions.condensed_phase_arrhenius)
|
|
366
|
-
assert len(mechanism.reactions.condensed_phase_photolysis) == 1
|
|
367
|
-
validate_condensed_phase_photolysis(
|
|
368
|
-
mechanism.reactions.condensed_phase_photolysis
|
|
369
|
-
)
|
|
370
|
-
assert len(mechanism.reactions.emission) == 1
|
|
371
|
-
validate_emission(mechanism.reactions.emission)
|
|
372
|
-
assert len(mechanism.reactions.first_order_loss) == 1
|
|
373
|
-
validate_first_order_loss(mechanism.reactions.first_order_loss)
|
|
374
|
-
assert len(mechanism.reactions.henrys_law) == 1
|
|
375
|
-
validate_henrys_law(mechanism.reactions.henrys_law)
|
|
376
|
-
assert len(mechanism.reactions.photolysis) == 1
|
|
377
|
-
validate_photolysis(mechanism.reactions.photolysis)
|
|
378
|
-
assert len(mechanism.reactions.simpol_phase_transfer) == 1
|
|
379
|
-
validate_simpol_phase_transfer(mechanism.reactions.simpol_phase_transfer)
|
|
380
|
-
assert len(mechanism.reactions.surface) == 1
|
|
381
|
-
validate_surface(mechanism.reactions.surface)
|
|
382
|
-
assert len(mechanism.reactions.troe) == 1
|
|
383
|
-
validate_troe(mechanism.reactions.troe)
|
|
384
|
-
assert len(mechanism.reactions.tunneling) == 1
|
|
385
|
-
validate_tunneling(mechanism.reactions.tunneling)
|
|
386
|
-
assert len(mechanism.reactions.wet_deposition) == 1
|
|
387
|
-
validate_wet_deposition(mechanism.reactions.wet_deposition)
|
|
388
|
-
assert len(mechanism.reactions.user_defined) == 1
|
|
389
|
-
validate_user_defined(mechanism.reactions.user_defined)
|
|
390
|
-
assert mechanism.version.major == 1
|
|
391
|
-
assert mechanism.version.minor == 0
|
|
392
|
-
assert mechanism.version.patch == 0
|
|
393
|
-
assert len(mechanism.reactions) == 17
|
|
394
|
-
for reaction in mechanism.reactions:
|
|
395
|
-
assert reaction is not None
|
|
396
|
-
assert isinstance(reaction.type, _ReactionType)
|
|
3
|
+
from test_util_full_mechanism import get_fully_defined_mechanism, validate_full_v1_mechanism
|
|
397
4
|
|
|
398
5
|
|
|
399
6
|
def test_parsed_full_v1_configuration():
|
|
@@ -415,251 +22,8 @@ def test_parser_reports_bad_files():
|
|
|
415
22
|
|
|
416
23
|
|
|
417
24
|
def test_hard_coded_full_v1_configuration():
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
A = Species(name="A", other_properties={"__absolute tolerance": "1.0e-30"})
|
|
421
|
-
B = Species(name="B", tracer_type="AEROSOL")
|
|
422
|
-
C = Species(name="C", tracer_type="THIRD_BODY")
|
|
423
|
-
M = Species(name="M")
|
|
424
|
-
H2O2 = Species(
|
|
425
|
-
name="H2O2",
|
|
426
|
-
HLC_298K_mol_m3_Pa=1.011596348,
|
|
427
|
-
HLC_exponential_factor_K=6340,
|
|
428
|
-
diffusion_coefficient_m2_s=1.46e-05,
|
|
429
|
-
N_star=1.74,
|
|
430
|
-
molecular_weight_kg_mol=0.0340147,
|
|
431
|
-
density_kg_m3=1000.0,
|
|
432
|
-
other_properties={"__absolute tolerance": "1.0e-10"},
|
|
433
|
-
)
|
|
434
|
-
ethanol = Species(
|
|
435
|
-
name="ethanol",
|
|
436
|
-
diffusion_coefficient_m2_s=0.95e-05,
|
|
437
|
-
N_star=2.55,
|
|
438
|
-
molecular_weight_kg_mol=0.04607,
|
|
439
|
-
other_properties={"__absolute tolerance": "1.0e-20"},
|
|
440
|
-
)
|
|
441
|
-
ethanol_aq = Species(
|
|
442
|
-
name="ethanol_aq",
|
|
443
|
-
molecular_weight_kg_mol=0.04607,
|
|
444
|
-
density_kg_m3=1000.0,
|
|
445
|
-
other_properties={"__absolute tolerance": "1.0e-20"},
|
|
446
|
-
)
|
|
447
|
-
H2O2_aq = Species(
|
|
448
|
-
name="H2O2_aq",
|
|
449
|
-
molecular_weight_kg_mol=0.0340147,
|
|
450
|
-
density_kg_m3=1000.0,
|
|
451
|
-
other_properties={"__absolute tolerance": "1.0e-10"},
|
|
452
|
-
)
|
|
453
|
-
H2O_aq = Species(
|
|
454
|
-
name="H2O_aq",
|
|
455
|
-
density_kg_m3=1000.0,
|
|
456
|
-
molecular_weight_kg_mol=0.01801,
|
|
457
|
-
)
|
|
458
|
-
aerosol_stuff = Species(
|
|
459
|
-
name="aerosol stuff",
|
|
460
|
-
molecular_weight_kg_mol=0.5,
|
|
461
|
-
density_kg_m3=1000.0,
|
|
462
|
-
other_properties={"__absolute tolerance": "1.0e-20"},
|
|
463
|
-
)
|
|
464
|
-
more_aerosol_stuff = Species(
|
|
465
|
-
name="more aerosol stuff",
|
|
466
|
-
molecular_weight_kg_mol=0.2,
|
|
467
|
-
density_kg_m3=1000.0,
|
|
468
|
-
other_properties={"__absolute tolerance": "1.0e-20"},
|
|
469
|
-
)
|
|
470
|
-
|
|
471
|
-
# Chemical phases
|
|
472
|
-
gas = Phase(name="gas", species=[A, B, C, ethanol])
|
|
473
|
-
aqueous_aerosol = Phase(
|
|
474
|
-
name="aqueous aerosol",
|
|
475
|
-
species=[H2O2_aq, H2O_aq, ethanol_aq, A, B, C]
|
|
476
|
-
)
|
|
477
|
-
surface_reacting_phase = Phase(
|
|
478
|
-
name="surface reacting phase",
|
|
479
|
-
species=[aerosol_stuff, more_aerosol_stuff]
|
|
480
|
-
)
|
|
481
|
-
cloud = Phase(name="cloud", species=[B, C])
|
|
482
|
-
|
|
483
|
-
# Reactions
|
|
484
|
-
my_arrhenius = Arrhenius(
|
|
485
|
-
name="my arrhenius",
|
|
486
|
-
A=32.1, B=-2.3, C=102.3, D=63.4, E=-1.3,
|
|
487
|
-
gas_phase=gas,
|
|
488
|
-
reactants=[B],
|
|
489
|
-
products=[C]
|
|
490
|
-
)
|
|
491
|
-
|
|
492
|
-
my_other_arrhenius = Arrhenius(
|
|
493
|
-
name="my other arrhenius",
|
|
494
|
-
A=29.3, B=-1.5, Ea=101.2, D=82.6, E=-0.98,
|
|
495
|
-
gas_phase=gas,
|
|
496
|
-
reactants=[A],
|
|
497
|
-
products=[(1.2, B)]
|
|
498
|
-
)
|
|
499
|
-
|
|
500
|
-
my_condensed_arrhenius = CondensedPhaseArrhenius(
|
|
501
|
-
name="my condensed arrhenius",
|
|
502
|
-
aerosol_phase=aqueous_aerosol,
|
|
503
|
-
aerosol_phase_water=H2O_aq,
|
|
504
|
-
A=123.45,
|
|
505
|
-
B=1.3,
|
|
506
|
-
Ea=123.45,
|
|
507
|
-
D=300.0,
|
|
508
|
-
E=0.6e-5,
|
|
509
|
-
reactants=[H2O2_aq, H2O_aq],
|
|
510
|
-
products=[ethanol_aq]
|
|
511
|
-
)
|
|
512
|
-
|
|
513
|
-
my_other_condensed_arrhenius = CondensedPhaseArrhenius(
|
|
514
|
-
name="my other condensed arrhenius",
|
|
515
|
-
aerosol_phase=aqueous_aerosol,
|
|
516
|
-
aerosol_phase_water=H2O_aq,
|
|
517
|
-
A=123.45,
|
|
518
|
-
B=1.3,
|
|
519
|
-
C=123.45,
|
|
520
|
-
D=300.0,
|
|
521
|
-
E=0.6e-5,
|
|
522
|
-
reactants=[H2O2_aq, H2O_aq],
|
|
523
|
-
products=[ethanol_aq]
|
|
524
|
-
)
|
|
525
|
-
|
|
526
|
-
my_troe = Troe(
|
|
527
|
-
name="my troe",
|
|
528
|
-
gas_phase=gas,
|
|
529
|
-
k0_A=1.2e-12,
|
|
530
|
-
k0_B=167,
|
|
531
|
-
k0_C=3,
|
|
532
|
-
kinf_A=136,
|
|
533
|
-
kinf_B=5,
|
|
534
|
-
kinf_C=24,
|
|
535
|
-
Fc=0.9,
|
|
536
|
-
N=0.8,
|
|
537
|
-
reactants=[B, M],
|
|
538
|
-
products=[C]
|
|
539
|
-
)
|
|
540
|
-
|
|
541
|
-
my_branched = Branched(
|
|
542
|
-
name="my branched",
|
|
543
|
-
gas_phase=gas,
|
|
544
|
-
reactants=[A],
|
|
545
|
-
alkoxy_products=[B],
|
|
546
|
-
nitrate_products=[C],
|
|
547
|
-
X=1.2e-4,
|
|
548
|
-
Y=167,
|
|
549
|
-
a0=0.15,
|
|
550
|
-
n=9,
|
|
551
|
-
)
|
|
552
|
-
|
|
553
|
-
my_tunneling = Tunneling(
|
|
554
|
-
name="my tunneling",
|
|
555
|
-
gas_phase=gas,
|
|
556
|
-
reactants=[B],
|
|
557
|
-
products=[C],
|
|
558
|
-
A=123.45,
|
|
559
|
-
B=1200.0,
|
|
560
|
-
C=1.0e8,
|
|
561
|
-
)
|
|
562
|
-
|
|
563
|
-
my_surface = Surface(
|
|
564
|
-
name="my surface",
|
|
565
|
-
gas_phase=gas,
|
|
566
|
-
gas_phase_species=A,
|
|
567
|
-
reaction_probability=2.0e-2,
|
|
568
|
-
gas_phase_products=[B, C],
|
|
569
|
-
aerosol_phase=surface_reacting_phase,
|
|
570
|
-
)
|
|
571
|
-
|
|
572
|
-
photo_B = Photolysis(
|
|
573
|
-
name="photo B",
|
|
574
|
-
gas_phase=gas,
|
|
575
|
-
reactants=[B],
|
|
576
|
-
products=[C],
|
|
577
|
-
scaling_factor=12.3,
|
|
578
|
-
)
|
|
579
|
-
|
|
580
|
-
condensed_photo_B = CondensedPhasePhotolysis(
|
|
581
|
-
name="condensed photo B",
|
|
582
|
-
aerosol_phase=aqueous_aerosol,
|
|
583
|
-
aerosol_phase_water=H2O_aq,
|
|
584
|
-
reactants=[H2O2_aq],
|
|
585
|
-
products=[ethanol_aq],
|
|
586
|
-
scaling_factor=12.3,
|
|
587
|
-
)
|
|
588
|
-
|
|
589
|
-
my_emission = Emission(
|
|
590
|
-
name="my emission",
|
|
591
|
-
gas_phase=gas,
|
|
592
|
-
products=[B],
|
|
593
|
-
scaling_factor=12.3,
|
|
594
|
-
)
|
|
595
|
-
|
|
596
|
-
my_first_order_loss = FirstOrderLoss(
|
|
597
|
-
name="my first order loss",
|
|
598
|
-
gas_phase=gas,
|
|
599
|
-
reactants=[C],
|
|
600
|
-
scaling_factor=12.3,
|
|
601
|
-
)
|
|
602
|
-
|
|
603
|
-
my_aqueous_equilibrium = AqueousEquilibrium(
|
|
604
|
-
name="my aqueous eq",
|
|
605
|
-
gas_phase=gas,
|
|
606
|
-
aerosol_phase=aqueous_aerosol,
|
|
607
|
-
aerosol_phase_water=H2O_aq,
|
|
608
|
-
A=1.14e-2,
|
|
609
|
-
C=2300.0,
|
|
610
|
-
k_reverse=0.32,
|
|
611
|
-
reactants=[(2, A)],
|
|
612
|
-
products=[B, C],
|
|
613
|
-
)
|
|
614
|
-
|
|
615
|
-
my_wet_deposition = WetDeposition(
|
|
616
|
-
name="rxn cloud",
|
|
617
|
-
aerosol_phase=cloud,
|
|
618
|
-
scaling_factor=12.3,
|
|
619
|
-
)
|
|
620
|
-
|
|
621
|
-
my_henrys_law = HenrysLaw(
|
|
622
|
-
name="my henry's law",
|
|
623
|
-
gas_phase=gas,
|
|
624
|
-
gas_phase_species=H2O2,
|
|
625
|
-
aerosol_phase=aqueous_aerosol,
|
|
626
|
-
aerosol_phase_species=H2O2_aq,
|
|
627
|
-
aerosol_phase_water=H2O_aq,
|
|
628
|
-
)
|
|
629
|
-
|
|
630
|
-
my_simpol_phase_transfer = SimpolPhaseTransfer(
|
|
631
|
-
name="my simpol",
|
|
632
|
-
gas_phase=gas,
|
|
633
|
-
gas_phase_species=ethanol,
|
|
634
|
-
aerosol_phase=aqueous_aerosol,
|
|
635
|
-
aerosol_phase_species=ethanol_aq,
|
|
636
|
-
B=[-1.97e03, 2.91e00, 1.96e-03, -4.96e-01],
|
|
637
|
-
)
|
|
638
|
-
|
|
639
|
-
user_defined = UserDefined(
|
|
640
|
-
name="my user defined",
|
|
641
|
-
gas_phase=gas,
|
|
642
|
-
reactants=[A, B],
|
|
643
|
-
products=[(1.3, C)],
|
|
644
|
-
scaling_factor=12.3,
|
|
645
|
-
)
|
|
646
|
-
|
|
647
|
-
# Mechanism
|
|
648
|
-
mechanism = Mechanism(
|
|
649
|
-
name="Full Configuration",
|
|
650
|
-
species=[A, B, C, M, H2O2, ethanol, ethanol_aq, H2O2_aq, H2O_aq,
|
|
651
|
-
aerosol_stuff, more_aerosol_stuff],
|
|
652
|
-
phases=[gas, aqueous_aerosol, surface_reacting_phase, cloud],
|
|
653
|
-
reactions=[my_arrhenius, my_other_arrhenius, my_condensed_arrhenius,
|
|
654
|
-
my_other_condensed_arrhenius, my_troe, my_branched,
|
|
655
|
-
my_tunneling, my_surface, photo_B, condensed_photo_B,
|
|
656
|
-
my_emission, my_first_order_loss, my_aqueous_equilibrium,
|
|
657
|
-
my_wet_deposition, my_henrys_law, my_simpol_phase_transfer,
|
|
658
|
-
user_defined],
|
|
659
|
-
version=Version(1, 0, 0),
|
|
660
|
-
)
|
|
661
|
-
|
|
662
|
-
validate_full_v1_mechanism(mechanism)
|
|
25
|
+
MECHANISM_FULLY_DEFINED = get_fully_defined_mechanism()
|
|
26
|
+
validate_full_v1_mechanism(MECHANISM_FULLY_DEFINED)
|
|
663
27
|
|
|
664
28
|
|
|
665
29
|
def test_hard_coded_default_constructed_types():
|