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