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,136 @@
1
+ from typing import Optional, Any, Dict, List, Union, Tuple
2
+ from .. import backend
3
+ from .utils import _add_other_properties, _remove_empty_keys
4
+ from .phase import Phase
5
+ from .species import Species
6
+ from .reaction_component import ReactionComponent
7
+ from .ancillary import ReactionType
8
+
9
+ _backend = backend.get_backend()
10
+ TaylorSeries = _backend._mechanism_configuration._TaylorSeries
11
+
12
+ original_init = TaylorSeries.__init__
13
+
14
+
15
+ @property
16
+ def type(self):
17
+ return ReactionType.TaylorSeries
18
+
19
+
20
+ def __init__(
21
+ self,
22
+ name: Optional[str] = None,
23
+ gas_phase: Optional[Phase] = None,
24
+ A: Optional[float] = None,
25
+ B: Optional[float] = None,
26
+ C: Optional[float] = None,
27
+ D: Optional[float] = None,
28
+ E: Optional[float] = None,
29
+ taylor_coefficients: Optional[List[float]] = None,
30
+ reactants: Optional[List[Union[Species,
31
+ Tuple[float, Species]]]] = None,
32
+ products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
33
+ other_properties: Optional[Dict[str, Any]] = None,
34
+ ):
35
+ """
36
+ Initializes the TaylorSeries object with the given parameters.
37
+
38
+ Args:
39
+ name (Optional[str]): The name of the TaylorSeries object.
40
+ gas_phase (Optional[Phase]): The gas phase associated with the reaction.
41
+ A (Optional[float]): The A coefficient for the Taylor series.
42
+ B (Optional[float]): The B coefficient for the Taylor series.
43
+ C (Optional[float]): The C coefficient for the Taylor series.
44
+ D (Optional[float]): The D coefficient for the Taylor series.
45
+ E (Optional[float]): The E coefficient for the Taylor series.
46
+ taylor_coefficients (Optional[List[float]]): List of Taylor series coefficients.
47
+ reactants (Optional[List[Union[Species, Tuple[float, Species]]]]): List of reactants, either as Species or (stoichiometry, Species) tuples.
48
+ products (Optional[List[Union[Species, Tuple[float, Species]]]]): List of products, either as Species or (stoichiometry, Species) tuples.
49
+ other_properties (Optional[Dict[str, Any]]): Additional properties for the reaction.
50
+ """
51
+ original_init(self)
52
+ self.name = name if name is not None else self.name
53
+ self.A = A if A is not None else self.A
54
+ self.B = B if B is not None else self.B
55
+ self.C = C if C is not None else self.C
56
+ self.D = D if D is not None else self.D
57
+ self.E = E if E is not None else self.E
58
+ self.taylor_coefficients = taylor_coefficients if taylor_coefficients is not None else self.taylor_coefficients
59
+ self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
60
+ self.reactants = (
61
+ [
62
+ (
63
+ ReactionComponent(r.name)
64
+ if isinstance(r, Species)
65
+ else ReactionComponent(r[1].name, r[0])
66
+ )
67
+ for r in reactants
68
+ ]
69
+ if reactants is not None
70
+ else self.reactants
71
+ )
72
+ self.products = (
73
+ [
74
+ (
75
+ ReactionComponent(p.name)
76
+ if isinstance(p, Species)
77
+ else ReactionComponent(p[1].name, p[0])
78
+ )
79
+ for p in products
80
+ ]
81
+ if products is not None
82
+ else self.products
83
+ )
84
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
85
+
86
+
87
+ def serialize(self) -> Dict:
88
+ serialize_dict = {
89
+ "type": "TAYLOR_SERIES",
90
+ "name": self.name,
91
+ "A": self.A,
92
+ "B": self.B,
93
+ "C": self.C,
94
+ "D": self.D,
95
+ "E": self.E,
96
+ "taylor coefficients": list(self.taylor_coefficients),
97
+ "reactants": [r.serialize() for r in self.reactants],
98
+ "products": [r.serialize() for r in self.products],
99
+ "gas phase": self.gas_phase,
100
+ }
101
+ _add_other_properties(serialize_dict, self.other_properties)
102
+ return _remove_empty_keys(serialize_dict)
103
+
104
+
105
+ TaylorSeries.__doc__ = """
106
+ A class representing a Taylor series rate constant.
107
+
108
+ The rate constant k is represented as a Taylor series expansion in temperature (and optionally other variables):
109
+
110
+ k = a0 + a1*T + a2*T^2 + a3*T^3 + ... + an*T^n
111
+
112
+ where:
113
+ k = rate constant
114
+ T = temperature [K]
115
+ a0, a1, ..., an = Taylor series coefficients
116
+
117
+ Optionally, additional parameters (A, B, C, D, E) may be provided for compatibility or extended forms.
118
+
119
+ Attributes:
120
+ name (str): The name of the Taylor series rate constant.
121
+ taylor_coefficients (List[float]): Coefficients [a0, a1, ..., an] for the Taylor series expansion.
122
+ A (float, optional): Optional parameter for extended forms.
123
+ B (float, optional): Optional parameter for extended forms.
124
+ C (float, optional): Optional parameter for extended forms.
125
+ D (float, optional): Optional parameter for extended forms.
126
+ E (float, optional): Optional parameter for extended forms.
127
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
128
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
129
+ gas_phase (Phase): The gas phase in which the reaction occurs.
130
+ other_properties (Dict[str, Any]): A dictionary of other properties of the Taylor series rate constant.
131
+ """
132
+
133
+
134
+ TaylorSeries.__init__ = __init__
135
+ TaylorSeries.serialize = serialize
136
+ TaylorSeries.type = type
@@ -0,0 +1,160 @@
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
+ TernaryChemicalActivation = _backend._mechanism_configuration._TernaryChemicalActivation
11
+
12
+ original_init = TernaryChemicalActivation.__init__
13
+
14
+
15
+ @property
16
+ def type(self):
17
+ return ReactionType.TernaryChemicalActivation
18
+
19
+
20
+ def __init__(
21
+ self,
22
+ name: Optional[str] = None,
23
+ k0_A: Optional[float] = None,
24
+ k0_B: Optional[float] = None,
25
+ k0_C: Optional[float] = None,
26
+ kinf_A: Optional[float] = None,
27
+ kinf_B: Optional[float] = None,
28
+ kinf_C: Optional[float] = None,
29
+ Fc: Optional[float] = None,
30
+ N: Optional[float] = None,
31
+ reactants: Optional[List[Union[Species,
32
+ Tuple[float, Species]]]] = None,
33
+ products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
34
+ gas_phase: Optional[Phase] = None,
35
+ other_properties: Optional[Dict[str, Any]] = None,
36
+ ):
37
+ """
38
+ Initializes the Ternary Chemical Activation object with the given parameters.
39
+
40
+ k0 = k0_A * exp( k0_C / T ) * ( T / 300.0 )^k0_B
41
+ kinf = kinf_A * exp( kinf_C / T ) * ( T / 300.0 )^kinf_B
42
+ k = k0[M] / ( 1 + k0[M] / kinf ) * Fc^(1 + 1/N*(log10(k0[M]/kinf))^2)^-1
43
+
44
+ where:
45
+ k = rate constant
46
+ k0 = low-pressure limit rate constant
47
+ kinf = high-pressure limit rate constant
48
+ k0_A = pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1]
49
+ k0_B = temperature exponent for the low-pressure limit [unitless]
50
+ k0_C = exponential term for the low-pressure limit [K-1]
51
+ kinf_A = pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1]
52
+ kinf_B = temperature exponent for the high-pressure limit [unitless]
53
+ kinf_C = exponential term for the high-pressure limit [K-1]
54
+ Fc = Ternary Chemical Activation parameter [unitless]
55
+ N = Ternary Chemical Activation parameter [unitless]
56
+ T = temperature [K]
57
+ M = concentration of the third body [mol m-3]
58
+
59
+ Args:
60
+ name (str): The name of the Ternary Chemical Activation rate constant.
61
+ k0_A (float): Pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1].
62
+ k0_B (float): Temperature exponent for the low-pressure limit [unitless].
63
+ k0_C (float): Exponential term for the low-pressure limit [K-1].
64
+ kinf_A (float): Pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1].
65
+ kinf_B (float): Temperature exponent for the high-pressure limit [unitless].
66
+ kinf_C (float): Exponential term for the high-pressure limit [K-1].
67
+ Fc (float): Ternary Chemical Activation parameter [unitless].
68
+ N (float): Ternary Chemical Activation parameter [unitless].
69
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
70
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
71
+ gas_phase (Phase): The gas phase in which the reaction occurs.
72
+ other_properties (Dict[str, Any]): A dictionary of other properties of the Ternary Chemical Activation rate constant.
73
+ """
74
+ original_init(self)
75
+
76
+ self.name = name if name is not None else self.name
77
+ self.k0_A = k0_A if k0_A is not None else self.k0_A
78
+ self.k0_B = k0_B if k0_B is not None else self.k0_B
79
+ self.k0_C = k0_C if k0_C is not None else self.k0_C
80
+ self.kinf_A = kinf_A if kinf_A is not None else self.kinf_A
81
+ self.kinf_B = kinf_B if kinf_B is not None else self.kinf_B
82
+ self.kinf_C = kinf_C if kinf_C is not None else self.kinf_C
83
+ self.Fc = Fc if Fc is not None else self.Fc
84
+ self.N = N if N is not None else self.N
85
+ self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
86
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
87
+ self.reactants = (
88
+ [
89
+ (
90
+ ReactionComponent(r.name)
91
+ if isinstance(r, Species)
92
+ else ReactionComponent(r[1].name, r[0])
93
+ )
94
+ for r in reactants
95
+ ]
96
+ if reactants is not None
97
+ else self.reactants
98
+ )
99
+ self.products = (
100
+ [
101
+ (
102
+ ReactionComponent(p.name)
103
+ if isinstance(p, Species)
104
+ else ReactionComponent(p[1].name, p[0])
105
+ )
106
+ for p in products
107
+ ]
108
+ if products is not None
109
+ else self.products
110
+ )
111
+
112
+
113
+ def serialize(self) -> Dict:
114
+ """
115
+ Serialize the Ternary Chemical Activation object to a dictionary using only Python-visible data.
116
+
117
+ Returns:
118
+ Dict: A dictionary representation of the Ternary Chemical Activation object.
119
+ """
120
+ serialize_dict = {
121
+ "type": "TERNARY_CHEMICAL_ACTIVATION",
122
+ "name": self.name,
123
+ "k0_A": self.k0_A,
124
+ "k0_B": self.k0_B,
125
+ "k0_C": self.k0_C,
126
+ "kinf_A": self.kinf_A,
127
+ "kinf_B": self.kinf_B,
128
+ "kinf_C": self.kinf_C,
129
+ "Fc": self.Fc,
130
+ "N": self.N,
131
+ "reactants": [r.serialize() for r in self.reactants],
132
+ "products": [r.serialize() for r in self.products],
133
+ "gas phase": self.gas_phase,
134
+ }
135
+ _add_other_properties(serialize_dict, self.other_properties)
136
+ return _remove_empty_keys(serialize_dict)
137
+
138
+
139
+ TernaryChemicalActivation.__doc__ = """
140
+ A class representing a Ternary Chemical Activation rate constant.
141
+
142
+ Attributes:
143
+ name (str): The name of the Ternary Chemical Activation rate constant.
144
+ k0_A (float): Pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1].
145
+ k0_B (float): Temperature exponent for the low-pressure limit [unitless].
146
+ k0_C (float): Exponential term for the low-pressure limit [K-1].
147
+ kinf_A (float): Pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1].
148
+ kinf_B (float): Temperature exponent for the high-pressure limit [unitless].
149
+ kinf_C (float): Exponential term for the high-pressure limit [K-1].
150
+ Fc (float): Ternary Chemical Activation parameter [unitless].
151
+ N (float): Ternary Chemical Activation parameter [unitless].
152
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
153
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
154
+ gas_phase (Phase): The gas phase in which the reaction occurs.
155
+ other_properties (Dict[str, Any]): A dictionary of other properties of the Ternary Chemical Activation rate constant.
156
+ """
157
+
158
+ TernaryChemicalActivation.__init__ = __init__
159
+ TernaryChemicalActivation.serialize = serialize
160
+ TernaryChemicalActivation.type = type
@@ -0,0 +1,160 @@
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
+ Troe = _backend._mechanism_configuration._Troe
11
+
12
+ original_init = Troe.__init__
13
+
14
+
15
+ @property
16
+ def type(self):
17
+ return ReactionType.Troe
18
+
19
+
20
+ def __init__(
21
+ self,
22
+ name: Optional[str] = None,
23
+ k0_A: Optional[float] = None,
24
+ k0_B: Optional[float] = None,
25
+ k0_C: Optional[float] = None,
26
+ kinf_A: Optional[float] = None,
27
+ kinf_B: Optional[float] = None,
28
+ kinf_C: Optional[float] = None,
29
+ Fc: Optional[float] = None,
30
+ N: Optional[float] = None,
31
+ reactants: Optional[List[Union[Species,
32
+ Tuple[float, Species]]]] = None,
33
+ products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
34
+ gas_phase: Optional[Phase] = None,
35
+ other_properties: Optional[Dict[str, Any]] = None,
36
+ ):
37
+ """
38
+ Initializes the Troe object with the given parameters.
39
+
40
+ k0 = k0_A * exp( k0_C / T ) * ( T / 300.0 )^k0_B
41
+ kinf = kinf_A * exp( kinf_C / T ) * ( T / 300.0 )^kinf_B
42
+ k = k0[M] / ( 1 + k0[M] / kinf ) * Fc^(1 + 1/N*(log10(k0[M]/kinf))^2)^-1
43
+
44
+ where:
45
+ k = rate constant
46
+ k0 = low-pressure limit rate constant
47
+ kinf = high-pressure limit rate constant
48
+ k0_A = pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1]
49
+ k0_B = temperature exponent for the low-pressure limit [unitless]
50
+ k0_C = exponential term for the low-pressure limit [K-1]
51
+ kinf_A = pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1]
52
+ kinf_B = temperature exponent for the high-pressure limit [unitless]
53
+ kinf_C = exponential term for the high-pressure limit [K-1]
54
+ Fc = Troe parameter [unitless]
55
+ N = Troe parameter [unitless]
56
+ T = temperature [K]
57
+ M = concentration of the third body [mol m-3]
58
+
59
+ Args:
60
+ name (str): The name of the Troe rate constant.
61
+ k0_A (float): Pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1].
62
+ k0_B (float): Temperature exponent for the low-pressure limit [unitless].
63
+ k0_C (float): Exponential term for the low-pressure limit [K-1].
64
+ kinf_A (float): Pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1].
65
+ kinf_B (float): Temperature exponent for the high-pressure limit [unitless].
66
+ kinf_C (float): Exponential term for the high-pressure limit [K-1].
67
+ Fc (float): Troe parameter [unitless].
68
+ N (float): Troe parameter [unitless].
69
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
70
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
71
+ gas_phase (Phase): The gas phase in which the reaction occurs.
72
+ other_properties (Dict[str, Any]): A dictionary of other properties of the Troe rate constant.
73
+ """
74
+ original_init(self)
75
+
76
+ self.name = name if name is not None else self.name
77
+ self.k0_A = k0_A if k0_A is not None else self.k0_A
78
+ self.k0_B = k0_B if k0_B is not None else self.k0_B
79
+ self.k0_C = k0_C if k0_C is not None else self.k0_C
80
+ self.kinf_A = kinf_A if kinf_A is not None else self.kinf_A
81
+ self.kinf_B = kinf_B if kinf_B is not None else self.kinf_B
82
+ self.kinf_C = kinf_C if kinf_C is not None else self.kinf_C
83
+ self.Fc = Fc if Fc is not None else self.Fc
84
+ self.N = N if N is not None else self.N
85
+ self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
86
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
87
+ self.reactants = (
88
+ [
89
+ (
90
+ ReactionComponent(r.name)
91
+ if isinstance(r, Species)
92
+ else ReactionComponent(r[1].name, r[0])
93
+ )
94
+ for r in reactants
95
+ ]
96
+ if reactants is not None
97
+ else self.reactants
98
+ )
99
+ self.products = (
100
+ [
101
+ (
102
+ ReactionComponent(p.name)
103
+ if isinstance(p, Species)
104
+ else ReactionComponent(p[1].name, p[0])
105
+ )
106
+ for p in products
107
+ ]
108
+ if products is not None
109
+ else self.products
110
+ )
111
+
112
+
113
+ def serialize(self) -> Dict:
114
+ """
115
+ Serialize the Troe object to a dictionary using only Python-visible data.
116
+
117
+ Returns:
118
+ Dict: A dictionary representation of the Troe object.
119
+ """
120
+ serialize_dict = {
121
+ "type": "TROE",
122
+ "name": self.name,
123
+ "k0_A": self.k0_A,
124
+ "k0_B": self.k0_B,
125
+ "k0_C": self.k0_C,
126
+ "kinf_A": self.kinf_A,
127
+ "kinf_B": self.kinf_B,
128
+ "kinf_C": self.kinf_C,
129
+ "Fc": self.Fc,
130
+ "N": self.N,
131
+ "reactants": [r.serialize() for r in self.reactants],
132
+ "products": [r.serialize() for r in self.products],
133
+ "gas phase": self.gas_phase,
134
+ }
135
+ _add_other_properties(serialize_dict, self.other_properties)
136
+ return _remove_empty_keys(serialize_dict)
137
+
138
+
139
+ Troe.__doc__ = """
140
+ A class representing a Troe rate constant.
141
+
142
+ Attributes:
143
+ name (str): The name of the Troe rate constant.
144
+ k0_A (float): Pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1].
145
+ k0_B (float): Temperature exponent for the low-pressure limit [unitless].
146
+ k0_C (float): Exponential term for the low-pressure limit [K-1].
147
+ kinf_A (float): Pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1].
148
+ kinf_B (float): Temperature exponent for the high-pressure limit [unitless].
149
+ kinf_C (float): Exponential term for the high-pressure limit [K-1].
150
+ Fc (float): Troe parameter [unitless].
151
+ N (float): Troe parameter [unitless].
152
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
153
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
154
+ gas_phase (Phase): The gas phase in which the reaction occurs.
155
+ other_properties (Dict[str, Any]): A dictionary of other properties of the Troe rate constant.
156
+ """
157
+
158
+ Troe.__init__ = __init__
159
+ Troe.serialize = serialize
160
+ Troe.type = type
@@ -0,0 +1,126 @@
1
+ from .utils import _add_other_properties, _remove_empty_keys
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
+ Tunneling = _backend._mechanism_configuration._Tunneling
11
+
12
+ original_init = Tunneling.__init__
13
+
14
+
15
+ @property
16
+ def type(self):
17
+ return ReactionType.Tunneling
18
+
19
+
20
+ def __init__(
21
+ self,
22
+ name: Optional[str] = None,
23
+ A: Optional[float] = None,
24
+ B: Optional[float] = None,
25
+ C: Optional[float] = None,
26
+ reactants: Optional[List[Union[Species,
27
+ Tuple[float, Species]]]] = None,
28
+ products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
29
+ gas_phase: Optional[Phase] = None,
30
+ other_properties: Optional[Dict[str, Any]] = None,
31
+ ):
32
+ """
33
+ Initializes the Tunneling object with the given parameters.
34
+
35
+ Args:
36
+ name (str): The name of the tunneling reaction rate constant.
37
+ A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
38
+ B (float): Tunneling parameter [K^-1].
39
+ C (float): Tunneling parameter [K^-3].
40
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
41
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
42
+ gas_phase (Phase): The gas phase in which the reaction occurs.
43
+ other_properties (Dict[str, Any]): A dictionary of other properties of the tunneling reaction rate constant.
44
+ """
45
+ original_init(self)
46
+
47
+ self.name = name if name is not None else self.name
48
+ self.A = A if A is not None else self.A
49
+ self.B = B if B is not None else self.B
50
+ self.C = C if C is not None else self.C
51
+ self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
52
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
53
+ self.reactants = (
54
+ [
55
+ (
56
+ ReactionComponent(r.name)
57
+ if isinstance(r, Species)
58
+ else ReactionComponent(r[1].name, r[0])
59
+ )
60
+ for r in reactants
61
+ ]
62
+ if reactants is not None
63
+ else self.reactants
64
+ )
65
+ self.products = (
66
+ [
67
+ (
68
+ ReactionComponent(p.name)
69
+ if isinstance(p, Species)
70
+ else ReactionComponent(p[1].name, p[0])
71
+ )
72
+ for p in products
73
+ ]
74
+ if products is not None
75
+ else self.products
76
+ )
77
+
78
+
79
+ def serialize(self) -> Dict:
80
+ """
81
+ Serialize the Tunneling object to a dictionary using only Python-visible data.
82
+
83
+ Returns:
84
+ Dict: A dictionary representation of the Tunneling object.
85
+ """
86
+ serialize_dict = {
87
+ "type": "TUNNELING",
88
+ "name": self.name,
89
+ "A": self.A,
90
+ "B": self.B,
91
+ "C": self.C,
92
+ "reactants": [r.serialize() for r in self.reactants],
93
+ "products": [r.serialize() for r in self.products],
94
+ "gas phase": self.gas_phase,
95
+ }
96
+ _add_other_properties(serialize_dict, self.other_properties)
97
+ return _remove_empty_keys(serialize_dict)
98
+
99
+
100
+ Tunneling.__doc__ = """
101
+ A class representing a quantum tunneling reaction rate constant.
102
+
103
+ k = A * exp( -B / T ) * exp( C / T^3 )
104
+
105
+ where:
106
+ k = rate constant
107
+ A = pre-exponential factor [(mol m-3)^(n-1)s-1]
108
+ B = tunneling parameter [K^-1]
109
+ C = tunneling parameter [K^-3]
110
+ T = temperature [K]
111
+ n = number of reactants
112
+
113
+ Attributes:
114
+ name (str): The name of the tunneling reaction rate constant.
115
+ A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
116
+ B (float): Tunneling parameter [K^-1].
117
+ C (float): Tunneling parameter [K^-3].
118
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
119
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
120
+ gas_phase (Phase): The gas phase in which the reaction occurs.
121
+ other_properties (Dict[str, Any]): A dictionary of other properties of the tunneling reaction rate constant.
122
+ """
123
+
124
+ Tunneling.__init__ = __init__
125
+ Tunneling.serialize = serialize
126
+ Tunneling.type = type
@@ -0,0 +1,99 @@
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
+ UserDefined = _backend._mechanism_configuration._UserDefined
11
+
12
+ original_init = UserDefined.__init__
13
+
14
+
15
+ @property
16
+ def type(self):
17
+ return ReactionType.UserDefined
18
+
19
+
20
+ def __init__(
21
+ self,
22
+ name: Optional[str] = None,
23
+ scaling_factor: Optional[float] = None,
24
+ reactants: Optional[List[Union[Species,
25
+ Tuple[float, Species]]]] = None,
26
+ products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
27
+ gas_phase: Optional[Phase] = None,
28
+ other_properties: Optional[Dict[str, Any]] = None,
29
+ ):
30
+ """
31
+ Initializes the UserDefined object with the given parameters.
32
+
33
+ Args:
34
+ name (str): The name of the photolysis reaction rate constant.
35
+ scaling_factor (float): The scaling factor for the photolysis rate constant.
36
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
37
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
38
+ gas_phase (Phase): The gas phase in which the reaction occurs.
39
+ other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
40
+ """
41
+ original_init(self)
42
+ self.name = name if name is not None else self.name
43
+ self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
44
+ self.reactants = (
45
+ [
46
+ (
47
+ ReactionComponent(r.name)
48
+ if isinstance(r, Species)
49
+ else ReactionComponent(r[1].name, r[0])
50
+ )
51
+ for r in reactants
52
+ ]
53
+ if reactants is not None
54
+ else self.reactants
55
+ )
56
+ self.products = (
57
+ [
58
+ (
59
+ ReactionComponent(p.name)
60
+ if isinstance(p, Species)
61
+ else ReactionComponent(p[1].name, p[0])
62
+ )
63
+ for p in products
64
+ ]
65
+ if products is not None
66
+ else self.products
67
+ )
68
+ self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
69
+ self.other_properties = other_properties if other_properties is not None else self.other_properties
70
+
71
+
72
+ def serialize(self) -> Dict:
73
+ serialize_dict = {
74
+ "type": "USER_DEFINED",
75
+ "name": self.name,
76
+ "scaling factor": self.scaling_factor,
77
+ "reactants": [r.serialize() for r in self.reactants],
78
+ "products": [r.serialize() for r in self.products],
79
+ "gas phase": self.gas_phase,
80
+ }
81
+ _add_other_properties(serialize_dict, self.other_properties)
82
+ return _remove_empty_keys(serialize_dict)
83
+
84
+
85
+ UserDefined.__doc__ = """
86
+ A class representing a user-defined reaction rate constant.
87
+
88
+ Attributes:
89
+ name (str): The name of the photolysis reaction rate constant.
90
+ scaling_factor (float): The scaling factor for the photolysis rate constant.
91
+ reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
92
+ products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
93
+ gas_phase (Phase): The gas phase in which the reaction occurs.
94
+ other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
95
+ """
96
+
97
+ UserDefined.__init__ = __init__
98
+ UserDefined.serialize = serialize
99
+ UserDefined.type = type
@@ -0,0 +1,10 @@
1
+ from typing import Dict
2
+
3
+
4
+ def _remove_empty_keys(dictionary: Dict) -> Dict:
5
+ return {k: v for k, v in dictionary.items() if v is not None and v != "" and v != [] and v != {}}
6
+
7
+
8
+ def _add_other_properties(serialize_dict: Dict, other_properties: Dict) -> None:
9
+ for key in other_properties:
10
+ serialize_dict[key] = other_properties[key]