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
@@ -0,0 +1,93 @@
1
+ # Copyright (C) 2025 University Corporation for Atmospheric Research
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # This file is part of the musica Python package.
5
+ # For more information, see the LICENSE file in the top-level directory of this distribution.
6
+ import os
7
+ import json
8
+ import yaml
9
+ from typing import Optional, Any, Dict, List
10
+ from .. import backend
11
+
12
+ from .species import Species
13
+ from .phase import Phase
14
+ from .reactions import Reactions
15
+ from .ancillary import Version
16
+
17
+ _backend = backend.get_backend()
18
+ Mechanism = _backend._mechanism_configuration._Mechanism
19
+
20
+ original_init = Mechanism.__init__
21
+
22
+
23
+ def export(self, file_path: str) -> None:
24
+ directory, file = os.path.split(file_path)
25
+ if directory:
26
+ os.makedirs(directory, exist_ok=True)
27
+
28
+ dictionary = self.serialize()
29
+
30
+ _, file_ext = os.path.splitext(file)
31
+ file_ext = file_ext.lower()
32
+ if file_ext in ['.yaml', '.yml']:
33
+ with open(file_path, 'w') as file:
34
+ yaml.dump(dictionary, file)
35
+ elif '.json' == file_ext:
36
+ json_str = json.dumps(dictionary, indent=4)
37
+ with open(file_path, 'w') as file:
38
+ file.write(json_str)
39
+ else:
40
+ raise ValueError(
41
+ 'Allowable write formats are .json, .yaml, and .yml')
42
+
43
+
44
+ def __init__(
45
+ self,
46
+ name: Optional[str] = None,
47
+ reactions: Optional[List[Any]] = None,
48
+ species: Optional[List[Species]] = None,
49
+ phases: Optional[List[Phase]] = None,
50
+ version: Optional[Version] = None,
51
+ ):
52
+ """
53
+ Initializes the Mechanism object with the given parameters.
54
+
55
+ Args:
56
+ name (str): The name of the mechanism.
57
+ reactions (List[]): A list of reactions in the mechanism.
58
+ species (List[Species]): A list of species in the mechanism.
59
+ phases (List[Phase]): A list of phases in the mechanism.
60
+ version (Version): The version of the mechanism.
61
+ """
62
+ original_init(self)
63
+ self.name = name
64
+ self.species = species if species is not None else []
65
+ self.phases = phases if phases is not None else []
66
+ self.reactions = Reactions(reactions=reactions if reactions is not None else [])
67
+ self.version = version if version is not None else Version()
68
+
69
+
70
+ def serialize(self) -> Dict:
71
+ return {
72
+ "name": self.name,
73
+ "reactions": [r.serialize() for r in self.reactions],
74
+ "species": [s.serialize() for s in self.species],
75
+ "phases": [p.serialize() for p in self.phases],
76
+ "version": self.version.to_string(),
77
+ }
78
+
79
+
80
+ Mechanism.__doc__ = """
81
+ A class representing a chemical mechanism.
82
+
83
+ Attributes:
84
+ name (str): The name of the mechanism.
85
+ reactions (List[Reaction]): A list of reactions in the mechanism.
86
+ species (List[Species]): A list of species in the mechanism.
87
+ phases (List[Phase]): A list of phases in the mechanism.
88
+ version (Version): The version of the mechanism.
89
+ """
90
+
91
+ Mechanism.__init__ = __init__
92
+ Mechanism.serialize = serialize
93
+ Mechanism.export = export
@@ -0,0 +1,58 @@
1
+ from typing import Optional, Any, Dict, List, Union
2
+ from .. import backend
3
+ from .species import Species
4
+ from .phase_species import PhaseSpecies
5
+ from .utils import _add_other_properties, _remove_empty_keys
6
+
7
+ _backend = backend.get_backend()
8
+ Phase = _backend._mechanism_configuration._Phase
9
+ Phase.__doc__ = """
10
+ A class representing a phase in a chemical mechanism.
11
+
12
+ Attributes:
13
+ name (str): The name of the phase.
14
+ species (List[Species]): A list of species in the phase.
15
+ other_properties (Dict[str, Any]): A dictionary of other properties of the phase.
16
+ """
17
+
18
+ original_init = Phase.__init__
19
+
20
+
21
+ def init(
22
+ self,
23
+ name: Optional[str] = None,
24
+ species: Optional[Union[List[Species], List[PhaseSpecies]]] = None,
25
+ other_properties: Optional[Dict[str, Any]] = None,
26
+ ):
27
+ """
28
+ Initializes the Phase object with the given parameters.
29
+
30
+ Args:
31
+ name (str): The name of the phase.
32
+ species (List[Species]): A list of species in the phase.
33
+ other_properties (Dict[str, Any]): A dictionary of other properties of the phase.
34
+ """
35
+ original_init(self)
36
+ self.name = name if name is not None else self.name
37
+ converted_species = []
38
+ if species is not None:
39
+ for s in species:
40
+ if isinstance(s, PhaseSpecies):
41
+ converted_species.append(s)
42
+ elif isinstance(s, Species):
43
+ converted_species.append(PhaseSpecies(name=s.name))
44
+ self.species = converted_species
45
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
46
+
47
+
48
+ def serialize(instance):
49
+ serialize_dict = {
50
+ "name": instance.name,
51
+ "species": [s.serialize() for s in instance.species],
52
+ }
53
+ _add_other_properties(serialize_dict, instance.other_properties)
54
+ return _remove_empty_keys(serialize_dict)
55
+
56
+
57
+ Phase.__init__ = init
58
+ Phase.serialize = serialize
@@ -0,0 +1,58 @@
1
+ from typing import Optional, Any, Dict
2
+ from .. import backend
3
+ from .utils import _add_other_properties, _remove_empty_keys
4
+
5
+ _backend = backend.get_backend()
6
+ PhaseSpecies = _backend._mechanism_configuration._PhaseSpecies
7
+ original_init = PhaseSpecies.__init__
8
+
9
+
10
+ def __init__(
11
+ self,
12
+ name: Optional[str] = None,
13
+ diffusion_coefficient_m2_s: Optional[float] = None,
14
+ other_properties: Optional[Dict[str, Any]] = None,
15
+ ):
16
+ """
17
+ Initializes the PhaseSpecies object with the given parameters.
18
+
19
+ Args:
20
+ name (str): The name of the species.
21
+ diffusion_coefficient_m2_s (float): Diffusion coefficient [m2 s-1]
22
+ other_properties (Dict[str, Any]): A dictionary of other properties of the species.
23
+ """
24
+ original_init(self)
25
+ self.name = name if name is not None else self.name
26
+ self.diffusion_coefficient_m2_s = diffusion_coefficient_m2_s if diffusion_coefficient_m2_s is not None else self.diffusion_coefficient_m2_s
27
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
28
+
29
+
30
+ def serialize(self) -> Dict:
31
+ serialize_dict = {
32
+ "name": self.name,
33
+ "diffusion coefficient [m2 s-1]": self.diffusion_coefficient_m2_s,
34
+ }
35
+ _add_other_properties(serialize_dict, self.other_properties)
36
+ return _remove_empty_keys(serialize_dict)
37
+
38
+
39
+ def equals(self, other):
40
+ return self.name == other.name and self.diffusion_coefficient_m2_s == other.diffusion_coefficient_m2_s
41
+
42
+
43
+ PhaseSpecies.__doc__ = """
44
+ Represents a chemical species within a specific phase of a mechanism,
45
+ including phase-specific properties such as diffusion coefficients.
46
+
47
+ This class is distinct from a regular Species class in that it models
48
+ properties relevant to the species' behavior in a particular phase
49
+ (e.g., gas, liquid, or solid), such as the diffusion coefficient.
50
+
51
+ Attributes:
52
+ name (str): The name of the species.
53
+ diffusion_coefficient_m2_s (float): Diffusion coefficient in the phase [m2 s-1].
54
+ other_properties (Dict[str, Any]): A dictionary of other phase-specific properties of the species.
55
+ """
56
+ PhaseSpecies.__init__ = __init__
57
+ PhaseSpecies.serialize = serialize
58
+ PhaseSpecies.__eq__ = equals
@@ -0,0 +1,98 @@
1
+ from .utils import _add_other_properties
2
+ from .species import Species
3
+ from .phase import Phase
4
+ from typing import Optional, Any, Dict, List, Union, Tuple
5
+ from .. import backend
6
+ from .reaction_component import ReactionComponent
7
+ from .ancillary import ReactionType
8
+
9
+ _backend = backend.get_backend()
10
+ Photolysis = _backend._mechanism_configuration._Photolysis
11
+
12
+ original_init = Photolysis.__init__
13
+
14
+
15
+ @property
16
+ def type(self):
17
+ return ReactionType.Photolysis
18
+
19
+
20
+ def __init__(
21
+ self,
22
+ name: Optional[str] = None,
23
+ scaling_factor: Optional[float] = None,
24
+ reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
25
+ products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
26
+ gas_phase: Optional[Phase] = None,
27
+ other_properties: Optional[Dict[str, Any]] = None,
28
+ ):
29
+ """
30
+ Initializes the Photolysis object with the given parameters.
31
+
32
+ Args:
33
+ name (str): The name of the photolysis reaction rate constant.
34
+ scaling_factor (float): The scaling factor for the photolysis rate constant.
35
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
36
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
37
+ gas_phase (Phase): The gas phase in which the reaction occurs.
38
+ other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
39
+ """
40
+ original_init(self)
41
+ self.name = name if name is not None else self.name
42
+ self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
43
+ self.reactants = (
44
+ [
45
+ (
46
+ ReactionComponent(r.name)
47
+ if isinstance(r, Species)
48
+ else ReactionComponent(r[1].name, r[0])
49
+ )
50
+ for r in reactants
51
+ ]
52
+ if reactants is not None
53
+ else self.reactants
54
+ )
55
+ self.products = (
56
+ [
57
+ (
58
+ ReactionComponent(p.name)
59
+ if isinstance(p, Species)
60
+ else ReactionComponent(p[1].name, p[0])
61
+ )
62
+ for p in products
63
+ ]
64
+ if products is not None
65
+ else self.products
66
+ )
67
+ self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
68
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
69
+
70
+
71
+ def serialize(self) -> Dict:
72
+ serialize_dict = {
73
+ "type": "PHOTOLYSIS",
74
+ "name": self.name,
75
+ "scaling factor": self.scaling_factor,
76
+ "reactants": [r.serialize() for r in self.reactants],
77
+ "products": [r.serialize() for r in self.products],
78
+ "gas phase": self.gas_phase,
79
+ }
80
+ _add_other_properties(serialize_dict, self.other_properties)
81
+ return serialize_dict
82
+
83
+
84
+ Photolysis.__doc__ = """
85
+ A class representing a photolysis reaction rate constant.
86
+
87
+ Attributes:
88
+ name (str): The name of the photolysis reaction rate constant.
89
+ scaling_factor (float): The scaling factor for the photolysis rate constant.
90
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
91
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
92
+ gas_phase (Phase): The gas phase in which the reaction occurs.
93
+ other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
94
+ """
95
+
96
+ Photolysis.__init__ = __init__
97
+ Photolysis.serialize = serialize
98
+ Photolysis.type = type
@@ -0,0 +1,54 @@
1
+ from typing import Optional, Any, Dict
2
+ from .. import backend
3
+ from .utils import _add_other_properties, _remove_empty_keys
4
+
5
+ _backend = backend.get_backend()
6
+ ReactionComponent = _backend._mechanism_configuration._ReactionComponent
7
+ original_init = ReactionComponent.__init__
8
+
9
+
10
+ def __init__(
11
+ self,
12
+ name: Optional[str] = None,
13
+ coefficient: Optional[float] = 1.0,
14
+ other_properties: Optional[Dict[str, Any]] = None,
15
+ ):
16
+ """
17
+ Initializes the ReactionComponent object with the given parameters.
18
+
19
+ Args:
20
+ name (str): The name of the species.
21
+ coefficient (float): The stichiometric coefficient
22
+ other_properties (Dict[str, Any]): A dictionary of other properties of the species.
23
+ """
24
+ original_init(self)
25
+ self.species_name = name if name is not None else self.species_name
26
+ self.coefficient = coefficient if coefficient is not None else self.coefficient
27
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
28
+
29
+
30
+ def serialize(self) -> Dict:
31
+ serialize_dict = {
32
+ "species name": self.species_name,
33
+ "coefficient": self.coefficient,
34
+ "other_properties": self.other_properties,
35
+ }
36
+ _add_other_properties(serialize_dict, self.other_properties)
37
+ return _remove_empty_keys(serialize_dict)
38
+
39
+
40
+ ReactionComponent.__doc__ = """
41
+ A class representing a reaction component in a chemical reaction.
42
+
43
+ A reaction component typically consists of a chemical species, its stoichiometric coefficient in the reaction,
44
+ and any additional properties relevant to its role in the reaction.
45
+
46
+ Attributes:
47
+ species_name (str): The name of the chemical species involved in the reaction.
48
+ coefficient (float): The stoichiometric coefficient of the species in the reaction.
49
+ other_properties (Dict[str, Any]): A dictionary of other properties relevant to the reaction component.
50
+ """
51
+
52
+
53
+ ReactionComponent.__init__ = __init__
54
+ ReactionComponent.serialize = serialize
@@ -0,0 +1,32 @@
1
+ from typing import Optional, Any, Dict, List, Union
2
+ from .. import backend
3
+ from .species import Species
4
+ from .utils import _remove_empty_keys
5
+
6
+ _backend = backend.get_backend()
7
+ Reactions = _backend._mechanism_configuration._Reactions
8
+
9
+ original_init = Reactions.__init__
10
+
11
+ Reactions.__doc__ = """
12
+ A class representing a collection of reactions in a chemical mechanism.
13
+
14
+ Attributes:
15
+ reactions (List[Any]): A list of reactions in the mechanism.
16
+ """
17
+
18
+
19
+ def __init__(
20
+ self,
21
+ reactions: Optional[List[Any]] = None,
22
+ ):
23
+ """
24
+ Initializes the Reactions object with the given parameters.
25
+
26
+ Args:
27
+ reactions (List[]): A list of reactions in the mechanism.
28
+ """
29
+ original_init(self, reactions)
30
+
31
+
32
+ Reactions.__init__ = __init__
@@ -0,0 +1,65 @@
1
+ from typing import Optional, Any, Dict
2
+ from .. import backend
3
+ from .utils import _add_other_properties, _remove_empty_keys
4
+
5
+ _backend = backend.get_backend()
6
+ Species = _backend._mechanism_configuration._Species
7
+ original_init = Species.__init__
8
+
9
+
10
+ def __init__(
11
+ self,
12
+ name: Optional[str] = None,
13
+ molecular_weight_kg_mol: Optional[float] = None,
14
+ constant_concentration_mol_m3: Optional[float] = None,
15
+ constant_mixing_ratio_mol_mol: Optional[float] = None,
16
+ is_third_body: Optional[bool] = False,
17
+ other_properties: Optional[Dict[str, Any]] = None,
18
+ ):
19
+ """
20
+ Initializes the Species object with the given parameters.
21
+
22
+ Args:
23
+ name (str): The name of the species.
24
+ molecular_weight_kg_mol (float): Molecular weight [kg mol-1]
25
+ constant_concentration_mol_m3 (float): Constant concentration of the species (mol m-3)
26
+ constant_mixing_ratio_mol_mol (float): Constant mixing ratio of the species (mol mol-1)
27
+ is_third_body (bool): Whether the species is a third body.
28
+ other_properties (Dict[str, Any]): A dictionary of other properties of the species.
29
+ """
30
+ original_init(self)
31
+ self.name = name if name is not None else self.name
32
+ self.molecular_weight_kg_mol = molecular_weight_kg_mol if molecular_weight_kg_mol is not None else self.molecular_weight_kg_mol
33
+ self.constant_concentration_mol_m3 = constant_concentration_mol_m3 if constant_concentration_mol_m3 is not None else self.constant_concentration_mol_m3
34
+ self.constant_mixing_ratio_mol_mol = constant_mixing_ratio_mol_mol if constant_mixing_ratio_mol_mol is not None else self.constant_mixing_ratio_mol_mol
35
+ self.is_third_body = is_third_body
36
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
37
+
38
+
39
+ def serialize(self) -> Dict:
40
+ serialize_dict = {
41
+ "name": self.name,
42
+ "molecular weight [kg mol-1]": self.molecular_weight_kg_mol,
43
+ "constant concentration [mol m-3]": self.constant_concentration_mol_m3,
44
+ "constant mixing ratio [mol mol-1]": self.constant_mixing_ratio_mol_mol,
45
+ "is third body": self.is_third_body,
46
+ }
47
+ _add_other_properties(serialize_dict, self.other_properties)
48
+ return _remove_empty_keys(serialize_dict)
49
+
50
+
51
+ Species.__doc__ = """
52
+ A class representing a species in a chemical mechanism.
53
+
54
+ Attributes:
55
+ name (str): The name of the species.
56
+ molecular_weight_kg_mol (float): Molecular weight [kg mol-1]
57
+ constant_concentration_mol_m3 (float): Constant concentration of the species (mol m-3)
58
+ constant_mixing_ratio_mol_mol (float): Constant mixing ratio of the species (mol mol-1)
59
+ is_third_body (bool): Whether the species is a third body.
60
+ other_properties (Dict[str, Any]): A dictionary of other properties of the species.
61
+ """
62
+
63
+
64
+ Species.__init__ = __init__
65
+ Species.serialize = serialize
@@ -0,0 +1,98 @@
1
+ from typing import Optional, Any, Dict, List, Union, Tuple
2
+ from .. import backend
3
+ from .phase import Phase
4
+ from .species import Species
5
+ from .utils import _add_other_properties, _remove_empty_keys
6
+ from .reaction_component import ReactionComponent
7
+ from .ancillary import ReactionType
8
+
9
+ _backend = backend.get_backend()
10
+ Surface = _backend._mechanism_configuration._Surface
11
+
12
+ original_init = Surface.__init__
13
+
14
+
15
+ @property
16
+ def type(self):
17
+ return ReactionType.Surface
18
+
19
+
20
+ def __init__(
21
+ self,
22
+ name: Optional[str] = None,
23
+ reaction_probability: Optional[float] = None,
24
+ gas_phase_species: Optional[Union[Species,
25
+ Tuple[float, Species]]] = None,
26
+ gas_phase_products: Optional[
27
+ List[Union[Species, Tuple[float, Species]]]
28
+ ] = None,
29
+ gas_phase: Optional[Phase] = None,
30
+ other_properties: Optional[Dict[str, Any]] = None,
31
+ ):
32
+ """
33
+ Initializes the Surface object with the given parameters.
34
+
35
+ Args:
36
+ name (str): The name of the surface.
37
+ reaction_probability (float): The probability of a reaction occurring on the surface.
38
+ gas_phase_species (Union[Species, Tuple[float, Species]]): The gas phase species involved in the reaction.
39
+ gas_phase_products (List[Union[Species, Tuple[float, Species]]]): The gas phase products formed in the reaction.
40
+ gas_phase (Phase): The gas phase in which the reaction occurs.
41
+ other_properties (Dict[str, Any]): A dictionary of other properties of the surface.
42
+ """
43
+ original_init(self)
44
+ self.name = name if name is not None else self.name
45
+ self.reaction_probability = reaction_probability if reaction_probability is not None else self.reaction_probability
46
+ self.gas_phase_species = (
47
+ (
48
+ ReactionComponent(gas_phase_species.name)
49
+ if isinstance(gas_phase_species, Species)
50
+ else ReactionComponent(gas_phase_species[1].name, gas_phase_species[0])
51
+ )
52
+ if gas_phase_species is not None
53
+ else self.gas_phase_species
54
+ )
55
+ self.gas_phase_products = (
56
+ [
57
+ (
58
+ ReactionComponent(p.name)
59
+ if isinstance(p, Species)
60
+ else ReactionComponent(p[1].name, p[0])
61
+ )
62
+ for p in gas_phase_products
63
+ ]
64
+ if gas_phase_products is not None
65
+ else self.gas_phase_products
66
+ )
67
+ self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
68
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
69
+
70
+
71
+ def serialize(self) -> Dict:
72
+ serialize_dict = {
73
+ "type": "SURFACE",
74
+ "name": self.name,
75
+ "reaction probability": self.reaction_probability,
76
+ "gas-phase species": self.gas_phase_species.species_name,
77
+ "gas-phase products": [r.serialize() for r in self.gas_phase_products],
78
+ "gas phase": self.gas_phase,
79
+ }
80
+ _add_other_properties(serialize_dict, self.other_properties)
81
+ return _remove_empty_keys(serialize_dict)
82
+
83
+
84
+ Surface.__doc__ = """
85
+ A class representing a surface in a chemical mechanism.
86
+
87
+ Attributes:
88
+ name (str): The name of the surface.
89
+ reaction_probability (float): The probability of a reaction occurring on the surface.
90
+ gas_phase_species (Union[Species, Tuple[float, Species]]): The gas phase species involved in the reaction.
91
+ gas_phase_products (List[Union[Species, Tuple[float, Species]]]): The gas phase products formed in the reaction.
92
+ gas_phase (Phase): The gas phase in which the reaction occurs.
93
+ other_properties (Dict[str, Any]): A dictionary of other properties of the surface.
94
+ """
95
+
96
+ Surface.__init__ = __init__
97
+ Surface.serialize = serialize
98
+ Surface.type = type