musica 0.12.2__cp39-cp39-win_arm64.whl → 0.13.0__cp39-cp39-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of musica might be problematic. Click here for more details.

Files changed (63) hide show
  1. musica/CMakeLists.txt +4 -0
  2. musica/_musica.cp39-win_amd64.pyd +0 -0
  3. musica/_version.py +1 -1
  4. musica/binding_common.cpp +6 -9
  5. musica/binding_common.hpp +17 -1
  6. musica/grid.cpp +206 -0
  7. musica/grid.py +98 -0
  8. musica/grid_map.cpp +117 -0
  9. musica/grid_map.py +167 -0
  10. musica/mechanism_configuration/__init__.py +18 -1
  11. musica/mechanism_configuration/ancillary.py +6 -0
  12. musica/mechanism_configuration/arrhenius.py +111 -269
  13. musica/mechanism_configuration/branched.py +116 -275
  14. musica/mechanism_configuration/emission.py +63 -52
  15. musica/mechanism_configuration/first_order_loss.py +73 -157
  16. musica/mechanism_configuration/mechanism.py +93 -0
  17. musica/mechanism_configuration/phase.py +44 -33
  18. musica/mechanism_configuration/phase_species.py +58 -0
  19. musica/mechanism_configuration/photolysis.py +77 -67
  20. musica/mechanism_configuration/reaction_component.py +54 -0
  21. musica/mechanism_configuration/reactions.py +17 -58
  22. musica/mechanism_configuration/species.py +45 -71
  23. musica/mechanism_configuration/surface.py +78 -74
  24. musica/mechanism_configuration/taylor_series.py +136 -0
  25. musica/mechanism_configuration/ternary_chemical_activation.py +138 -330
  26. musica/mechanism_configuration/troe.py +138 -330
  27. musica/mechanism_configuration/tunneling.py +105 -229
  28. musica/mechanism_configuration/user_defined.py +79 -68
  29. musica/mechanism_configuration.cpp +54 -162
  30. musica/musica.cpp +2 -5
  31. musica/profile.cpp +294 -0
  32. musica/profile.py +93 -0
  33. musica/profile_map.cpp +117 -0
  34. musica/profile_map.py +167 -0
  35. musica/test/examples/v1/full_configuration/full_configuration.json +91 -233
  36. musica/test/examples/v1/full_configuration/full_configuration.yaml +191 -290
  37. musica/test/integration/test_chapman.py +2 -2
  38. musica/test/integration/test_tuvx.py +72 -15
  39. musica/test/unit/test_grid.py +137 -0
  40. musica/test/unit/test_grid_map.py +126 -0
  41. musica/test/unit/test_parser.py +10 -10
  42. musica/test/unit/test_profile.py +169 -0
  43. musica/test/unit/test_profile_map.py +137 -0
  44. musica/test/unit/test_serializer.py +17 -16
  45. musica/test/unit/test_state.py +17 -4
  46. musica/test/unit/test_util_full_mechanism.py +78 -298
  47. musica/tuvx.cpp +94 -15
  48. musica/tuvx.py +92 -22
  49. musica/types.py +13 -5
  50. {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/METADATA +14 -14
  51. musica-0.13.0.dist-info/RECORD +80 -0
  52. musica/mechanism_configuration/aqueous_equilibrium.py +0 -274
  53. musica/mechanism_configuration/condensed_phase_arrhenius.py +0 -309
  54. musica/mechanism_configuration/condensed_phase_photolysis.py +0 -88
  55. musica/mechanism_configuration/henrys_law.py +0 -44
  56. musica/mechanism_configuration/mechanism_configuration.py +0 -234
  57. musica/mechanism_configuration/simpol_phase_transfer.py +0 -217
  58. musica/mechanism_configuration/wet_deposition.py +0 -52
  59. musica-0.12.2.dist-info/RECORD +0 -70
  60. {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/WHEEL +0 -0
  61. {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/entry_points.txt +0 -0
  62. {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/licenses/AUTHORS.md +0 -0
  63. {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,274 +0,0 @@
1
- from .utils import _add_other_properties
2
- from .reactions import ReactionComponentSerializer
3
- from .species import Species
4
- from .phase import Phase
5
- from typing import Optional, Any, Dict, List, Union, Tuple
6
- from .. import backend
7
-
8
- _backend = backend.get_backend()
9
- _AqueousEquilibrium = _backend._mechanism_configuration._AqueousEquilibrium
10
- _ReactionComponent = _backend._mechanism_configuration._ReactionComponent
11
- ReactionType = _backend._mechanism_configuration._ReactionType
12
-
13
-
14
- class AqueousEquilibrium:
15
- """
16
- A class representing an aqueous equilibrium reaction rate constant.
17
-
18
- Attributes:
19
- name (str): The name of the aqueous equilibrium reaction rate constant.
20
- condensed_phase (Phase): The condensed phase in which the reaction occurs.
21
- condensed_phase_water (Species): The water species in the condensed phase.
22
- reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
23
- products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
24
- A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
25
- C (float): Exponential term [K-1].
26
- k_reverse (float): Reverse rate constant [(mol m-3)^(n-1)s-1].
27
- other_properties (Dict[str, Any]): A dictionary of other properties of the aqueous equilibrium reaction rate constant.
28
- """
29
-
30
- def __init__(
31
- self,
32
- name: Optional[str] = None,
33
- condensed_phase: Optional[Phase] = None,
34
- condensed_phase_water: Optional[Species] = None,
35
- reactants: Optional[List[Union[Species,
36
- Tuple[float, Species]]]] = None,
37
- products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
38
- A: Optional[float] = None,
39
- C: Optional[float] = None,
40
- k_reverse: Optional[float] = None,
41
- other_properties: Optional[Dict[str, Any]] = None,
42
- ):
43
- """
44
- Initializes the AqueousEquilibrium object with the given parameters.
45
-
46
- Args:
47
- name (str): The name of the aqueous equilibrium reaction rate constant.
48
- condensed_phase (Phase): The condensed phase in which the reaction occurs.
49
- condensed_phase_water (Species): The water species in the condensed phase.
50
- reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
51
- products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
52
- A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
53
- C (float): Exponential term [K-1].
54
- k_reverse (float): Reverse rate constant [(mol m-3)^(n-1)s-1].
55
- other_properties (Dict[str, Any]): A dictionary of other properties of the aqueous equilibrium reaction rate constant.
56
- """
57
- # Create the internal C++ instance
58
- self._instance = _AqueousEquilibrium()
59
-
60
- # Set all parameters
61
- if name is not None:
62
- self.name = name
63
- if condensed_phase is not None:
64
- self.condensed_phase = condensed_phase
65
- if condensed_phase_water is not None:
66
- self.condensed_phase_water = condensed_phase_water
67
- if reactants is not None:
68
- self.reactants = reactants
69
- if products is not None:
70
- self.products = products
71
- if A is not None:
72
- self.A = A
73
- if C is not None:
74
- self.C = C
75
- if k_reverse is not None:
76
- self.k_reverse = k_reverse
77
- if other_properties is not None:
78
- self.other_properties = other_properties
79
-
80
- # Property delegation to self._instance
81
- @property
82
- def name(self) -> str:
83
- """Get the name of the aqueous equilibrium reaction rate constant."""
84
- return self._instance.name
85
-
86
- @name.setter
87
- def name(self, value: str):
88
- """Set the name of the aqueous equilibrium reaction rate constant."""
89
- self._instance.name = value
90
-
91
- @property
92
- def condensed_phase(self) -> str:
93
- """Get the condensed phase name."""
94
- return self._instance.condensed_phase
95
-
96
- @condensed_phase.setter
97
- def condensed_phase(self, value: Union[Phase, str]):
98
- """Set the condensed phase."""
99
- if isinstance(value, Phase):
100
- self._instance.condensed_phase = value.name
101
- elif isinstance(value, str):
102
- self._instance.condensed_phase = value
103
- else:
104
- raise ValueError(f"Invalid condensed_phase type: {type(value)}")
105
-
106
- @property
107
- def condensed_phase_water(self) -> str:
108
- """Get the condensed phase water species name."""
109
- return self._instance.condensed_phase_water
110
-
111
- @condensed_phase_water.setter
112
- def condensed_phase_water(self, value: Union[Species, str]):
113
- """Set the condensed phase water species."""
114
- if isinstance(value, Species):
115
- self._instance.condensed_phase_water = value.name
116
- elif isinstance(value, str):
117
- self._instance.condensed_phase_water = value
118
- else:
119
- raise ValueError(f"Invalid condensed_phase_water type: {type(value)}")
120
-
121
- @property
122
- def reactants(self) -> List[Union[Species, Tuple[float, Species]]]:
123
- """Get the reactants as Python objects."""
124
- # Convert from C++ _ReactionComponent objects to Python Species objects
125
- result = []
126
- for rc in self._instance.reactants:
127
- if hasattr(rc, 'coefficient') and rc.coefficient != 1.0:
128
- # Create a tuple with coefficient and species
129
- species = Species(name=rc.species_name)
130
- result.append((rc.coefficient, species))
131
- else:
132
- # Just the species
133
- species = Species(name=rc.species_name)
134
- result.append(species)
135
- return result
136
-
137
- @reactants.setter
138
- def reactants(self, value: List[Union[Species, Tuple[float, Species]]]):
139
- """Set the reactants, converting from Python to C++ objects."""
140
- cpp_reactants = []
141
- for r in value:
142
- if isinstance(r, Species):
143
- cpp_reactants.append(_ReactionComponent(r.name))
144
- elif isinstance(r, tuple) and len(r) == 2:
145
- coefficient, species = r
146
- cpp_reactants.append(_ReactionComponent(species.name, coefficient))
147
- else:
148
- raise ValueError(f"Invalid reactant format: {r}")
149
- self._instance.reactants = cpp_reactants
150
-
151
- @property
152
- def products(self) -> List[Union[Species, Tuple[float, Species]]]:
153
- """Get the products as Python objects."""
154
- # Convert from C++ _ReactionComponent objects to Python Species objects
155
- result = []
156
- for rc in self._instance.products:
157
- if hasattr(rc, 'coefficient') and rc.coefficient != 1.0:
158
- # Create a tuple with coefficient and species
159
- species = Species(name=rc.species_name)
160
- result.append((rc.coefficient, species))
161
- else:
162
- # Just the species
163
- species = Species(name=rc.species_name)
164
- result.append(species)
165
- return result
166
-
167
- @products.setter
168
- def products(self, value: List[Union[Species, Tuple[float, Species]]]):
169
- """Set the products, converting from Python to C++ objects."""
170
- cpp_products = []
171
- for p in value:
172
- if isinstance(p, Species):
173
- cpp_products.append(_ReactionComponent(p.name))
174
- elif isinstance(p, tuple) and len(p) == 2:
175
- coefficient, species = p
176
- cpp_products.append(_ReactionComponent(species.name, coefficient))
177
- else:
178
- raise ValueError(f"Invalid product format: {p}")
179
- self._instance.products = cpp_products
180
-
181
- @property
182
- def A(self) -> float:
183
- """Get the pre-exponential factor."""
184
- return self._instance.A
185
-
186
- @A.setter
187
- def A(self, value: float):
188
- """Set the pre-exponential factor."""
189
- self._instance.A = value
190
-
191
- @property
192
- def C(self) -> float:
193
- """Get the exponential term."""
194
- return self._instance.C
195
-
196
- @C.setter
197
- def C(self, value: float):
198
- """Set the exponential term."""
199
- self._instance.C = value
200
-
201
- @property
202
- def k_reverse(self) -> float:
203
- """Get the reverse rate constant."""
204
- return self._instance.k_reverse
205
-
206
- @k_reverse.setter
207
- def k_reverse(self, value: float):
208
- """Set the reverse rate constant."""
209
- self._instance.k_reverse = value
210
-
211
- @property
212
- def other_properties(self) -> Dict[str, Any]:
213
- """Get the other properties."""
214
- return self._instance.other_properties
215
-
216
- @other_properties.setter
217
- def other_properties(self, value: Dict[str, Any]):
218
- """Set the other properties."""
219
- self._instance.other_properties = value
220
-
221
- @property
222
- def type(self):
223
- """Get the reaction type."""
224
- return ReactionType.AqueousEquilibrium
225
-
226
- def _create_serialize_dict(self, instance) -> Dict:
227
- """
228
- Helper method to create the serialization dictionary.
229
-
230
- Args:
231
- instance: The instance to serialize (either self._instance or a _AqueousEquilibrium object).
232
-
233
- Returns:
234
- Dict: Base serialization dictionary.
235
- """
236
- return {
237
- "type": "AQUEOUS_EQUILIBRIUM",
238
- "name": instance.name,
239
- "condensed phase": instance.condensed_phase,
240
- "condensed-phase water": instance.condensed_phase_water,
241
- "reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
242
- "products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
243
- "A": instance.A,
244
- "C": instance.C,
245
- "k_reverse": instance.k_reverse,
246
- }
247
-
248
- def serialize(self) -> Dict:
249
- """
250
- Serialize the AqueousEquilibrium object to a dictionary using only Python-visible data.
251
-
252
- Returns:
253
- Dict: A dictionary representation of the AqueousEquilibrium object.
254
- """
255
- serialize_dict = self._create_serialize_dict(self._instance)
256
- _add_other_properties(serialize_dict, self.other_properties)
257
- return serialize_dict
258
-
259
- @staticmethod
260
- def serialize_static(instance) -> Dict:
261
- """
262
- Static serialize method for compatibility with C++ _AqueousEquilibrium objects.
263
-
264
- Args:
265
- instance: The _AqueousEquilibrium instance to serialize.
266
-
267
- Returns:
268
- Dict: A dictionary representation of the AqueousEquilibrium object.
269
- """
270
- # Create a temporary AqueousEquilibrium object to use the helper method
271
- temp_aqueous_equilibrium = AqueousEquilibrium()
272
- serialize_dict = temp_aqueous_equilibrium._create_serialize_dict(instance)
273
- _add_other_properties(serialize_dict, instance.other_properties)
274
- return serialize_dict
@@ -1,309 +0,0 @@
1
- from ..constants import BOLTZMANN
2
- from .utils import _add_other_properties
3
- from .reactions import ReactionComponentSerializer
4
- from .species import Species
5
- from .phase import Phase
6
- from typing import Optional, Any, Dict, List, Union, Tuple
7
- from .. import backend
8
-
9
- _backend = backend.get_backend()
10
- _CondensedPhaseArrhenius = _backend._mechanism_configuration._CondensedPhaseArrhenius
11
- _ReactionComponent = _backend._mechanism_configuration._ReactionComponent
12
-
13
-
14
- class CondensedPhaseArrhenius:
15
- """
16
- A class representing a condensed phase Arrhenius rate constant.
17
-
18
- Attributes:
19
- name (str): The name of the condensed phase Arrhenius rate constant.
20
- A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
21
- B (float): Temperature exponent [unitless].
22
- C (float): Exponential term [K-1].
23
- Ea (float): Activation energy [J molecule-1].
24
- D (float): Reference Temperature [K].
25
- E (float): Pressure scaling term [Pa-1].
26
- reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
27
- products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
28
- condensed_phase (Phase): The condensed phase in which the reaction occurs.
29
- other_properties (Dict[str, Any]): A dictionary of other properties of the condensed phase Arrhenius rate constant.
30
- """
31
-
32
- def __init__(
33
- self,
34
- name: Optional[str] = None,
35
- A: Optional[float] = None,
36
- B: Optional[float] = None,
37
- C: Optional[float] = None,
38
- Ea: Optional[float] = None,
39
- D: Optional[float] = None,
40
- E: Optional[float] = None,
41
- reactants: Optional[List[Union[Species,
42
- Tuple[float, Species]]]] = None,
43
- products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
44
- condensed_phase: Optional[Phase] = None,
45
- other_properties: Optional[Dict[str, Any]] = None,
46
- ):
47
- """
48
- Initializes the CondensedPhaseArrhenius object with the given parameters.
49
-
50
- Args:
51
- name (str): The name of the condensed phase Arrhenius rate constant.
52
- A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
53
- B (float): Temperature exponent [unitless].
54
- C (float): Exponential term [K-1].
55
- Ea (float): Activation energy [J molecule-1].
56
- D (float): Reference Temperature [K].
57
- E (float): Pressure scaling term [Pa-1].
58
- reactants (List[Union[Species, Tuple[float, Species]]]]: A list of reactants involved in the reaction.
59
- products (List[Union[Species, Tuple[float, Species]]]]: A list of products formed in the reaction.
60
- condensed_phase (Phase): The condensed phase in which the reaction occurs.
61
- other_properties (Dict[str, Any]): A dictionary of other properties of the condensed phase Arrhenius rate constant.
62
- """
63
- # Create the internal C++ instance
64
- self._instance = _CondensedPhaseArrhenius()
65
-
66
- # Store Python objects for reactants, products, phases
67
- self._reactants = reactants if reactants is not None else []
68
- self._products = products if products is not None else []
69
- self._condensed_phase = condensed_phase
70
- self._other_properties = other_properties if other_properties is not None else {}
71
-
72
- # Set basic properties on the C++ instance
73
- if name is not None:
74
- self._instance.name = name
75
- if A is not None:
76
- self._instance.A = A
77
- if B is not None:
78
- self._instance.B = B
79
- if C is not None and Ea is not None:
80
- raise ValueError("Cannot specify both C and Ea.")
81
- if Ea is not None:
82
- self._instance.C = -Ea / BOLTZMANN
83
- elif C is not None:
84
- self._instance.C = C
85
- if D is not None:
86
- self._instance.D = D
87
- if E is not None:
88
- self._instance.E = E
89
-
90
- # Set reactants on the C++ instance
91
- if reactants is not None:
92
- self._instance.reactants = [
93
- (
94
- _ReactionComponent(r.name)
95
- if isinstance(r, Species)
96
- else _ReactionComponent(r[1].name, r[0])
97
- )
98
- for r in reactants
99
- ]
100
-
101
- # Set products on the C++ instance
102
- if products is not None:
103
- self._instance.products = [
104
- (
105
- _ReactionComponent(p.name)
106
- if isinstance(p, Species)
107
- else _ReactionComponent(p[1].name, p[0])
108
- )
109
- for p in products
110
- ]
111
-
112
- # Set phase information on the C++ instance
113
- if condensed_phase is not None:
114
- self._instance.condensed_phase = condensed_phase.name
115
- if other_properties is not None:
116
- self._instance.other_properties = other_properties
117
-
118
- def __getattr__(self, name):
119
- """Delegate unknown attribute access to the internal instance."""
120
- return getattr(self._instance, name)
121
-
122
- @property
123
- def type(self):
124
- """The reaction type."""
125
- return self._instance.type
126
-
127
- @property
128
- def name(self) -> str:
129
- """The name of the condensed phase Arrhenius rate constant."""
130
- return self._instance.name
131
-
132
- @name.setter
133
- def name(self, value: str):
134
- self._instance.name = value
135
-
136
- @property
137
- def A(self) -> float:
138
- """Pre-exponential factor [(mol m-3)^(n-1)s-1]."""
139
- return self._instance.A
140
-
141
- @A.setter
142
- def A(self, value: float):
143
- self._instance.A = value
144
-
145
- @property
146
- def B(self) -> float:
147
- """Temperature exponent [unitless]."""
148
- return self._instance.B
149
-
150
- @B.setter
151
- def B(self, value: float):
152
- self._instance.B = value
153
-
154
- @property
155
- def C(self) -> float:
156
- """Exponential term [K-1]."""
157
- return self._instance.C
158
-
159
- @C.setter
160
- def C(self, value: float):
161
- self._instance.C = value
162
-
163
- @property
164
- def D(self) -> float:
165
- """Reference Temperature [K]."""
166
- return self._instance.D
167
-
168
- @D.setter
169
- def D(self, value: float):
170
- self._instance.D = value
171
-
172
- @property
173
- def E(self) -> float:
174
- """Pressure scaling term [Pa-1]."""
175
- return self._instance.E
176
-
177
- @E.setter
178
- def E(self, value: float):
179
- self._instance.E = value
180
-
181
- @property
182
- def reactants(self) -> List[Union[Species, Tuple[float, Species]]]:
183
- """A list of reactants involved in the reaction."""
184
- return self._reactants
185
-
186
- @reactants.setter
187
- def reactants(self, value: List[Union[Species, Tuple[float, Species]]]):
188
- self._reactants = value
189
- # Update the C++ instance
190
- self._instance.reactants = [
191
- (
192
- _ReactionComponent(r.name)
193
- if isinstance(r, Species)
194
- else _ReactionComponent(r[1].name, r[0])
195
- )
196
- for r in value
197
- ]
198
-
199
- @property
200
- def products(self) -> List[Union[Species, Tuple[float, Species]]]:
201
- """A list of products formed in the reaction."""
202
- return self._products
203
-
204
- @products.setter
205
- def products(self, value: List[Union[Species, Tuple[float, Species]]]):
206
- self._products = value
207
- # Update the C++ instance
208
- self._instance.products = [
209
- (
210
- _ReactionComponent(p.name)
211
- if isinstance(p, Species)
212
- else _ReactionComponent(p[1].name, p[0])
213
- )
214
- for p in value
215
- ]
216
-
217
- @property
218
- def condensed_phase(self) -> Phase:
219
- """The condensed phase in which the reaction occurs."""
220
- return self._condensed_phase
221
-
222
- @condensed_phase.setter
223
- def condensed_phase(self, value: Phase):
224
- self._condensed_phase = value
225
- # Update the C++ instance
226
- self._instance.condensed_phase = value.name if value is not None else ""
227
-
228
- @property
229
- def other_properties(self) -> Dict[str, Any]:
230
- """A dictionary of other properties of the condensed phase Arrhenius rate constant."""
231
- return self._other_properties
232
-
233
- @other_properties.setter
234
- def other_properties(self, value: Dict[str, Any]):
235
- self._other_properties = value
236
- # Update the C++ instance
237
- self._instance.other_properties = value
238
-
239
- def serialize(self) -> Dict:
240
- """
241
- Serialize the CondensedPhaseArrhenius instance to a dictionary.
242
-
243
- Returns:
244
- Dict: A dictionary representation of the condensed phase Arrhenius rate constant.
245
- """
246
- # Convert Python reactants/products to serializable format
247
- def serialize_python_components(components):
248
- result = []
249
- for component in components:
250
- if isinstance(component, Species):
251
- result.append(component.name)
252
- elif isinstance(component, tuple) and len(component) == 2:
253
- # Handle (coefficient, Species) tuples
254
- coefficient, species = component
255
- result.append({
256
- "species name": species.name,
257
- "coefficient": coefficient
258
- })
259
- else:
260
- # Fallback: treat as Species
261
- result.append(component.name if hasattr(component, 'name') else str(component))
262
- return result
263
-
264
- serialize_dict = {
265
- "type": "CONDENSED_PHASE_ARRHENIUS",
266
- "name": self.name,
267
- "A": self.A,
268
- "B": self.B,
269
- "C": self.C,
270
- "D": self.D,
271
- "E": self.E,
272
- "reactants": serialize_python_components(self._reactants),
273
- "products": serialize_python_components(self._products),
274
- "condensed phase": self._condensed_phase.name if self._condensed_phase is not None else "",
275
- }
276
- _add_other_properties(serialize_dict, self._other_properties)
277
- return serialize_dict
278
-
279
- @staticmethod
280
- def serialize_static(instance) -> Dict:
281
- """
282
- Static serialize method for backward compatibility.
283
-
284
- Args:
285
- instance: The CondensedPhaseArrhenius instance to serialize (can be Python wrapper or C++ type).
286
-
287
- Returns:
288
- Dict: A dictionary representation of the condensed phase Arrhenius rate constant.
289
- """
290
- # Check if it's the new composition-based Python wrapper
291
- if hasattr(instance, '_instance'):
292
- # New Python wrapper - use instance method
293
- return instance.serialize()
294
- else:
295
- # Old C++ wrapper type - use direct attribute access
296
- serialize_dict = {
297
- "type": "CONDENSED_PHASE_ARRHENIUS",
298
- "name": instance.name,
299
- "A": instance.A,
300
- "B": instance.B,
301
- "C": instance.C,
302
- "D": instance.D,
303
- "E": instance.E,
304
- "reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
305
- "products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
306
- "condensed phase": instance.condensed_phase,
307
- }
308
- _add_other_properties(serialize_dict, instance.other_properties)
309
- return serialize_dict
@@ -1,88 +0,0 @@
1
- from .utils import _add_other_properties
2
- from .reactions import ReactionComponentSerializer
3
- from .species import Species
4
- from .phase import Phase
5
- from typing import Optional, Any, Dict, List, Union, Tuple
6
- from .. import backend
7
-
8
- _backend = backend.get_backend()
9
- _CondensedPhasePhotolysis = _backend._mechanism_configuration._CondensedPhasePhotolysis
10
- _ReactionComponent = _backend._mechanism_configuration._ReactionComponent
11
-
12
-
13
- class CondensedPhasePhotolysis(_CondensedPhasePhotolysis):
14
- """
15
- A class representing a condensed phase photolysis reaction rate constant.
16
-
17
- Attributes:
18
- name (str): The name of the condensed phase photolysis reaction rate constant.
19
- scaling_factor (float): The scaling factor for the photolysis rate constant.
20
- reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
21
- products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
22
- condensed_phase (Phase): The condensed phase in which the reaction occurs.
23
- other_properties (Dict[str, Any]): A dictionary of other properties of the condensed phase photolysis reaction rate constant.
24
- """
25
-
26
- def __init__(
27
- self,
28
- name: Optional[str] = None,
29
- scaling_factor: Optional[float] = None,
30
- reactants: Optional[List[Union[Species,
31
- Tuple[float, Species]]]] = None,
32
- products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
33
- condensed_phase: Optional[Phase] = None,
34
- other_properties: Optional[Dict[str, Any]] = None,
35
- ):
36
- """
37
- Initializes the CondensedPhasePhotolysis object with the given parameters.
38
-
39
- Args:
40
- name (str): The name of the condensed phase photolysis reaction rate constant.
41
- scaling_factor (float): The scaling factor for the photolysis rate constant.
42
- reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
43
- products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
44
- condensed_phase (Phase): The condensed phase in which the reaction occurs.
45
- other_properties (Dict[str, Any]): A dictionary of other properties of the condensed phase photolysis reaction rate constant.
46
- """
47
- super().__init__()
48
- self.name = name if name is not None else self.name
49
- self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
50
- self.reactants = (
51
- [
52
- (
53
- _ReactionComponent(r.name)
54
- if isinstance(r, Species)
55
- else _ReactionComponent(r[1].name, r[0])
56
- )
57
- for r in reactants
58
- ]
59
- if reactants is not None
60
- else self.reactants
61
- )
62
- self.products = (
63
- [
64
- (
65
- _ReactionComponent(p.name)
66
- if isinstance(p, Species)
67
- else _ReactionComponent(p[1].name, p[0])
68
- )
69
- for p in products
70
- ]
71
- if products is not None
72
- else self.products
73
- )
74
- self.condensed_phase = condensed_phase.name if condensed_phase is not None else self.condensed_phase
75
- self.other_properties = other_properties if other_properties is not None else self.other_properties
76
-
77
- @staticmethod
78
- def serialize(instance) -> Dict:
79
- serialize_dict = {
80
- "type": "CONDENSED_PHASE_PHOTOLYSIS",
81
- "name": instance.name,
82
- "scaling factor": instance.scaling_factor,
83
- "reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
84
- "products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
85
- "condensed phase": instance.condensed_phase,
86
- }
87
- _add_other_properties(serialize_dict, instance.other_properties)
88
- return serialize_dict