musica 0.11.1.1__cp312-cp312-win_amd64.whl → 0.14.2__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.
Files changed (129) hide show
  1. musica/__init__.py +23 -3
  2. musica/_musica.cp312-win_amd64.pyd +0 -0
  3. musica/_version.py +1 -1
  4. musica/backend.py +58 -0
  5. musica/carma/__init__.py +20 -0
  6. musica/carma/carma.py +1727 -0
  7. musica/constants.py +3 -0
  8. musica/cuda.py +13 -0
  9. musica/examples/__init__.py +1 -0
  10. musica/examples/carma_aluminum.py +124 -0
  11. musica/examples/carma_sulfate.py +246 -0
  12. musica/examples/examples.py +165 -0
  13. musica/examples/sulfate_box_model.py +439 -0
  14. musica/examples/ts1_latin_hypercube.py +245 -0
  15. musica/main.py +128 -0
  16. musica/mechanism_configuration/__init__.py +18 -0
  17. musica/mechanism_configuration/ancillary.py +6 -0
  18. musica/mechanism_configuration/arrhenius.py +149 -0
  19. musica/mechanism_configuration/branched.py +140 -0
  20. musica/mechanism_configuration/emission.py +82 -0
  21. musica/mechanism_configuration/first_order_loss.py +90 -0
  22. musica/mechanism_configuration/mechanism.py +93 -0
  23. musica/mechanism_configuration/phase.py +58 -0
  24. musica/mechanism_configuration/phase_species.py +58 -0
  25. musica/mechanism_configuration/photolysis.py +98 -0
  26. musica/mechanism_configuration/reaction_component.py +54 -0
  27. musica/mechanism_configuration/reactions.py +32 -0
  28. musica/mechanism_configuration/species.py +65 -0
  29. musica/mechanism_configuration/surface.py +98 -0
  30. musica/mechanism_configuration/taylor_series.py +136 -0
  31. musica/mechanism_configuration/ternary_chemical_activation.py +160 -0
  32. musica/mechanism_configuration/troe.py +160 -0
  33. musica/mechanism_configuration/tunneling.py +126 -0
  34. musica/mechanism_configuration/user_defined.py +99 -0
  35. musica/mechanism_configuration/utils.py +10 -0
  36. musica/micm/__init__.py +10 -0
  37. musica/micm/conditions.py +49 -0
  38. musica/micm/micm.py +135 -0
  39. musica/micm/solver.py +8 -0
  40. musica/micm/solver_result.py +24 -0
  41. musica/micm/state.py +220 -0
  42. musica/micm/utils.py +18 -0
  43. musica/tuvx/__init__.py +11 -0
  44. musica/tuvx/grid.py +98 -0
  45. musica/tuvx/grid_map.py +167 -0
  46. musica/tuvx/profile.py +130 -0
  47. musica/tuvx/profile_map.py +167 -0
  48. musica/tuvx/radiator.py +95 -0
  49. musica/tuvx/radiator_map.py +173 -0
  50. musica/tuvx/tuvx.py +283 -0
  51. musica-0.14.2.dist-info/DELVEWHEEL +2 -0
  52. {musica-0.11.1.1.dist-info → musica-0.14.2.dist-info}/METADATA +146 -63
  53. musica-0.14.2.dist-info/RECORD +104 -0
  54. {musica-0.11.1.1.dist-info → musica-0.14.2.dist-info}/WHEEL +1 -1
  55. musica-0.14.2.dist-info/entry_points.txt +3 -0
  56. musica-0.14.2.dist-info/licenses/AUTHORS.md +59 -0
  57. musica.libs/libaws-c-auth-0a61a643442f1c0912920b37d9fb0be5.dll +0 -0
  58. musica.libs/libaws-c-cal-eaafa5905de6c9ba274eb8737e6087dd.dll +0 -0
  59. musica.libs/libaws-c-common-b4aa4468297ae8e1664f9380a5510317.dll +0 -0
  60. musica.libs/libaws-c-compression-9f997952aeae03067122ca493c9081b5.dll +0 -0
  61. musica.libs/libaws-c-event-stream-fe9cc8e1692f60c2b5694a8959dbd7c3.dll +0 -0
  62. musica.libs/libaws-c-http-4a9d50ba6ad8882f5267ef89e5e4103a.dll +0 -0
  63. musica.libs/libaws-c-io-e454f1c7a44e77f8c957a016888754be.dll +0 -0
  64. musica.libs/libaws-c-mqtt-67c5fc291740f5cbc5e53fb767e93226.dll +0 -0
  65. musica.libs/libaws-c-s3-206db4af6e1a95637b1921ea596603b9.dll +0 -0
  66. musica.libs/libaws-c-sdkutils-5c9c62dafb8b774cd4a3386f95ef428d.dll +0 -0
  67. musica.libs/libaws-checksums-7e50fe01b862214958f4d2ab4215fde5.dll +0 -0
  68. musica.libs/libaws-cpp-sdk-core-7a9ba9c045ee16f5262e955d96865718.dll +0 -0
  69. musica.libs/libaws-cpp-sdk-s3-4eebff3923c6d250fb508da3c990e0ae.dll +0 -0
  70. musica.libs/libaws-crt-cpp-3173f1e6f504a96d88e8dbf9e04b3b14.dll +0 -0
  71. musica.libs/libbrotlicommon-c62c08223e450dfc2fff33c752cc2285.dll +0 -0
  72. musica.libs/libbrotlidec-ccde7c3978eb1d2e052b193f2968d30a.dll +0 -0
  73. musica.libs/libbz2-1-669a4bf9266d5f020e843aa5fd75b93c.dll +0 -0
  74. musica.libs/libcrypto-3-x64-237eeb55505d067eab5e0b886e519387.dll +0 -0
  75. musica.libs/libcurl-4-bdf865458887dc1235b192ec83729214.dll +0 -0
  76. musica.libs/libgcc_s_seh-1-5a3153f12338f79fbbb7bf095fc5cef1.dll +0 -0
  77. musica.libs/libgfortran-5-90848e0eacdecce3a9005faf5aaec7e7.dll +0 -0
  78. musica.libs/libgomp-1-b8afcf09fecd2f6f01e454c9a5f2c690.dll +0 -0
  79. musica.libs/libhdf5-320-eec6c8ba2fdde30d365786ffbff40989.dll +0 -0
  80. musica.libs/libhdf5_hl-320-7e26e1caaad6be4082d728cf08ab2de4.dll +0 -0
  81. musica.libs/libiconv-2-b37d1b4acab5310c4e4f6e2a961d1464.dll +0 -0
  82. musica.libs/libidn2-0-d17600177f3b4cd2521d595b3472d240.dll +0 -0
  83. musica.libs/libintl-8-e4d4ca6b37338fbb0a8c1246afa7258f.dll +0 -0
  84. musica.libs/liblzma-5-bd95aa0fda6e7c8e41b3843d6fc2942c.dll +0 -0
  85. musica.libs/libnetcdf-0623e518145bddd30cc615b6d7f2f9c1.dll +0 -0
  86. musica.libs/libnetcdff-7-982cb7ee026b78f05a79d00e735f91d1.dll +0 -0
  87. musica.libs/libnghttp2-14-6d49ed806389b4892bcf29c6ed6e3984.dll +0 -0
  88. musica.libs/libnghttp3-9-d3c9b57d760f6dae7d6a067a68126b84.dll +0 -0
  89. musica.libs/libngtcp2-16-a43356e6376d41ce4238e2c55581636a.dll +0 -0
  90. musica.libs/libngtcp2_crypto_ossl-0-b37121badf25a552e5654f27bf6ff093.dll +0 -0
  91. musica.libs/libopenblas-a16595c3cae114c5c7304aa8bb3c1272.dll +0 -0
  92. musica.libs/libpsl-5-4368d4c2412410a4a14f3e7f3227e295.dll +0 -0
  93. musica.libs/libquadmath-0-4edeffe0a60c96360445d33a1876dbda.dll +0 -0
  94. musica.libs/libssh2-1-f407a2b50419bd904c7eb2c101ae81ea.dll +0 -0
  95. musica.libs/libssl-3-x64-d2e43d36e6f87f6f1645717cd0871f86.dll +0 -0
  96. musica.libs/libstdc++-6-83061aaccaf8df77a3b584efef12bc7c.dll +0 -0
  97. musica.libs/libsz-2-d12f3d26417507ec8dea9964f9fe36a1.dll +0 -0
  98. musica.libs/libunistring-5-0473d7a71d94f08292beed694c34f7d1.dll +0 -0
  99. musica.libs/libwinpthread-1-9157bac12a85fb717fa3d2bf6712631a.dll +0 -0
  100. musica.libs/libxml2-16-7fe545d280fdef922282226eef91571f.dll +0 -0
  101. musica.libs/libzip-62d3c877b7842bc509fc000316a4731b.dll +0 -0
  102. musica.libs/libzstd-a25427164f8775046eb8ce488d7d0884.dll +0 -0
  103. musica.libs/zlib1-1dc85208162ee57fe97e892bb5160fe9.dll +0 -0
  104. _musica.cp312-win_amd64.pyd +0 -0
  105. lib/musica.lib +0 -0
  106. lib/yaml-cpp.lib +0 -0
  107. musica/CMakeLists.txt +0 -47
  108. musica/binding.cpp +0 -19
  109. musica/mechanism_configuration.cpp +0 -519
  110. musica/mechanism_configuration.py +0 -1291
  111. musica/musica.cpp +0 -214
  112. musica/test/examples/v0/config.json +0 -7
  113. musica/test/examples/v0/config.yaml +0 -3
  114. musica/test/examples/v0/reactions.json +0 -193
  115. musica/test/examples/v0/reactions.yaml +0 -142
  116. musica/test/examples/v0/species.json +0 -40
  117. musica/test/examples/v0/species.yaml +0 -19
  118. musica/test/examples/v1/full_configuration.json +0 -434
  119. musica/test/examples/v1/full_configuration.yaml +0 -271
  120. musica/test/test_analytical.py +0 -323
  121. musica/test/test_chapman.py +0 -123
  122. musica/test/test_parser.py +0 -693
  123. musica/test/tuvx.py +0 -10
  124. musica/tools/prepare_build_environment_linux.sh +0 -41
  125. musica/tools/prepare_build_environment_windows.sh +0 -22
  126. musica/tools/repair_wheel_gpu.sh +0 -25
  127. musica/types.py +0 -362
  128. musica-0.11.1.1.dist-info/RECORD +0 -30
  129. {musica-0.11.1.1.dist-info → musica-0.14.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,693 +0,0 @@
1
- import pytest
2
- from musica.mechanism_configuration import *
3
- from _musica._mechanism_configuration import _ReactionType
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)
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{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
musica/test/tuvx.py DELETED
@@ -1,10 +0,0 @@
1
- import pytest
2
- import musica
3
-
4
-
5
- def test_tuvx_run():
6
- assert 1 != 0
7
-
8
-
9
- if __name__ == '__main__':
10
- pytest.main()