musica 0.12.2__cp310-cp310-win32.whl → 0.13.0__cp310-cp310-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of musica might be problematic. Click here for more details.
- musica/CMakeLists.txt +4 -0
- musica/_musica.cp310-win32.pyd +0 -0
- musica/_version.py +1 -1
- musica/binding_common.cpp +6 -9
- musica/binding_common.hpp +17 -1
- musica/grid.cpp +206 -0
- musica/grid.py +98 -0
- musica/grid_map.cpp +117 -0
- musica/grid_map.py +167 -0
- musica/mechanism_configuration/__init__.py +18 -1
- musica/mechanism_configuration/ancillary.py +6 -0
- musica/mechanism_configuration/arrhenius.py +111 -269
- musica/mechanism_configuration/branched.py +116 -275
- musica/mechanism_configuration/emission.py +63 -52
- musica/mechanism_configuration/first_order_loss.py +73 -157
- musica/mechanism_configuration/mechanism.py +93 -0
- musica/mechanism_configuration/phase.py +44 -33
- musica/mechanism_configuration/phase_species.py +58 -0
- musica/mechanism_configuration/photolysis.py +77 -67
- musica/mechanism_configuration/reaction_component.py +54 -0
- musica/mechanism_configuration/reactions.py +17 -58
- musica/mechanism_configuration/species.py +45 -71
- musica/mechanism_configuration/surface.py +78 -74
- musica/mechanism_configuration/taylor_series.py +136 -0
- musica/mechanism_configuration/ternary_chemical_activation.py +138 -330
- musica/mechanism_configuration/troe.py +138 -330
- musica/mechanism_configuration/tunneling.py +105 -229
- musica/mechanism_configuration/user_defined.py +79 -68
- musica/mechanism_configuration.cpp +54 -162
- musica/musica.cpp +2 -5
- musica/profile.cpp +294 -0
- musica/profile.py +93 -0
- musica/profile_map.cpp +117 -0
- musica/profile_map.py +167 -0
- musica/test/examples/v1/full_configuration/full_configuration.json +91 -233
- musica/test/examples/v1/full_configuration/full_configuration.yaml +191 -290
- musica/test/integration/test_chapman.py +2 -2
- musica/test/integration/test_tuvx.py +72 -15
- musica/test/unit/test_grid.py +137 -0
- musica/test/unit/test_grid_map.py +126 -0
- musica/test/unit/test_parser.py +10 -10
- musica/test/unit/test_profile.py +169 -0
- musica/test/unit/test_profile_map.py +137 -0
- musica/test/unit/test_serializer.py +17 -16
- musica/test/unit/test_state.py +17 -4
- musica/test/unit/test_util_full_mechanism.py +78 -298
- musica/tuvx.cpp +94 -15
- musica/tuvx.py +92 -22
- musica/types.py +13 -5
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/METADATA +14 -14
- musica-0.13.0.dist-info/RECORD +80 -0
- musica/mechanism_configuration/aqueous_equilibrium.py +0 -274
- musica/mechanism_configuration/condensed_phase_arrhenius.py +0 -309
- musica/mechanism_configuration/condensed_phase_photolysis.py +0 -88
- musica/mechanism_configuration/henrys_law.py +0 -44
- musica/mechanism_configuration/mechanism_configuration.py +0 -234
- musica/mechanism_configuration/simpol_phase_transfer.py +0 -217
- musica/mechanism_configuration/wet_deposition.py +0 -52
- musica-0.12.2.dist-info/RECORD +0 -70
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/WHEEL +0 -0
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/entry_points.txt +0 -0
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/licenses/AUTHORS.md +0 -0
- {musica-0.12.2.dist-info → musica-0.13.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -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
|
|
@@ -1,73 +1,32 @@
|
|
|
1
1
|
from typing import Optional, Any, Dict, List, Union
|
|
2
2
|
from .. import backend
|
|
3
|
-
from .species import Species
|
|
3
|
+
from .species import Species
|
|
4
4
|
from .utils import _remove_empty_keys
|
|
5
5
|
|
|
6
6
|
_backend = backend.get_backend()
|
|
7
|
-
|
|
8
|
-
_Reactions = _backend._mechanism_configuration._Reactions
|
|
9
|
-
_ReactionsIterator = _backend._mechanism_configuration._ReactionsIterator
|
|
7
|
+
Reactions = _backend._mechanism_configuration._Reactions
|
|
10
8
|
|
|
9
|
+
original_init = Reactions.__init__
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
A class representing a collection of reactions in a chemical mechanism.
|
|
15
|
-
|
|
16
|
-
Attributes:
|
|
17
|
-
reactions (List[Any]): A list of reactions in the mechanism.
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
def __init__(
|
|
21
|
-
self,
|
|
22
|
-
reactions: Optional[List[Any]] = None,
|
|
23
|
-
):
|
|
24
|
-
"""
|
|
25
|
-
Initializes the Reactions object with the given parameters.
|
|
11
|
+
Reactions.__doc__ = """
|
|
12
|
+
A class representing a collection of reactions in a chemical mechanism.
|
|
26
13
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# Convert Python Arrhenius objects to C++ _Arrhenius objects for the C++ constructor
|
|
31
|
-
if reactions is not None:
|
|
32
|
-
cpp_reactions = []
|
|
33
|
-
for reaction in reactions:
|
|
34
|
-
if hasattr(reaction, '_instance'):
|
|
35
|
-
# This is a Python wrapper around a C++ object, use the internal instance
|
|
36
|
-
cpp_reactions.append(reaction._instance)
|
|
37
|
-
else:
|
|
38
|
-
# This is already a C++ object or other supported type
|
|
39
|
-
cpp_reactions.append(reaction)
|
|
40
|
-
super().__init__(cpp_reactions)
|
|
41
|
-
else:
|
|
42
|
-
super().__init__(reactions)
|
|
14
|
+
Attributes:
|
|
15
|
+
reactions (List[Any]): A list of reactions in the mechanism.
|
|
16
|
+
"""
|
|
43
17
|
|
|
44
18
|
|
|
45
|
-
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
reactions: Optional[List[Any]] = None,
|
|
22
|
+
):
|
|
46
23
|
"""
|
|
47
|
-
|
|
48
|
-
"""
|
|
49
|
-
|
|
24
|
+
Initializes the Reactions object with the given parameters.
|
|
50
25
|
|
|
51
|
-
|
|
26
|
+
Args:
|
|
27
|
+
reactions (List[]): A list of reactions in the mechanism.
|
|
52
28
|
"""
|
|
53
|
-
|
|
54
|
-
"""
|
|
55
|
-
|
|
56
|
-
@staticmethod
|
|
57
|
-
def serialize_reaction_component(rc) -> Union[Dict, str]:
|
|
58
|
-
if isinstance(rc, Species) or isinstance(rc, _Species):
|
|
59
|
-
return rc.name
|
|
29
|
+
original_init(self, reactions)
|
|
60
30
|
|
|
61
|
-
return _remove_empty_keys({
|
|
62
|
-
"species name": rc.species_name,
|
|
63
|
-
"coefficient": rc.coefficient,
|
|
64
|
-
"other_properties": rc.other_properties,
|
|
65
|
-
})
|
|
66
31
|
|
|
67
|
-
|
|
68
|
-
def serialize_list_reaction_components(reaction_component_list) -> List[Union[Dict, str]]:
|
|
69
|
-
ret = []
|
|
70
|
-
for rc in reaction_component_list:
|
|
71
|
-
ret.append(
|
|
72
|
-
ReactionComponentSerializer.serialize_reaction_component(rc))
|
|
73
|
-
return ret
|
|
32
|
+
Reactions.__init__ = __init__
|
|
@@ -1,91 +1,65 @@
|
|
|
1
1
|
from typing import Optional, Any, Dict
|
|
2
2
|
from .. import backend
|
|
3
3
|
from .utils import _add_other_properties, _remove_empty_keys
|
|
4
|
-
from enum import Enum
|
|
5
4
|
|
|
6
5
|
_backend = backend.get_backend()
|
|
7
|
-
|
|
6
|
+
Species = _backend._mechanism_configuration._Species
|
|
7
|
+
original_init = Species.__init__
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
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
|
+
):
|
|
11
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__ = """
|
|
12
52
|
A class representing a species in a chemical mechanism.
|
|
13
53
|
|
|
14
54
|
Attributes:
|
|
15
55
|
name (str): The name of the species.
|
|
16
|
-
HLC_298K_mol_m3_Pa (float): Henry's Law Constant at 298K [mol m-3 Pa-1]
|
|
17
|
-
HLC_exponential_factor_K: Henry's Law Constant exponential factor [K]
|
|
18
|
-
diffusion_coefficient_m2_s (float): Diffusion coefficient [m2 s-1]
|
|
19
|
-
N_star (float): A parameter used to calculate the mass accomodation factor (Ervens et al., 2003)
|
|
20
56
|
molecular_weight_kg_mol (float): Molecular weight [kg mol-1]
|
|
21
|
-
density_kg_m3 (float): Density [kg m-3]
|
|
22
|
-
tracer_type (str): Type of tracer: 'THIRD_BODY' or None [Deprecated, use is_third_body instead]
|
|
23
57
|
constant_concentration_mol_m3 (float): Constant concentration of the species (mol m-3)
|
|
24
58
|
constant_mixing_ratio_mol_mol (float): Constant mixing ratio of the species (mol mol-1)
|
|
25
59
|
is_third_body (bool): Whether the species is a third body.
|
|
26
60
|
other_properties (Dict[str, Any]): A dictionary of other properties of the species.
|
|
27
61
|
"""
|
|
28
62
|
|
|
29
|
-
def __init__(
|
|
30
|
-
self,
|
|
31
|
-
name: Optional[str] = None,
|
|
32
|
-
HLC_298K_mol_m3_Pa: Optional[float] = None,
|
|
33
|
-
HLC_exponential_factor_K: Optional[float] = None,
|
|
34
|
-
diffusion_coefficient_m2_s: Optional[float] = None,
|
|
35
|
-
N_star: Optional[float] = None,
|
|
36
|
-
molecular_weight_kg_mol: Optional[float] = None,
|
|
37
|
-
density_kg_m3: Optional[float] = None,
|
|
38
|
-
tracer_type: Optional[str] = None, # Deprecated use is_third_body instead
|
|
39
|
-
constant_concentration_mol_m3: Optional[float] = None,
|
|
40
|
-
constant_mixing_ratio_mol_mol: Optional[float] = None,
|
|
41
|
-
is_third_body: Optional[bool] = False,
|
|
42
|
-
other_properties: Optional[Dict[str, Any]] = None,
|
|
43
|
-
):
|
|
44
|
-
"""
|
|
45
|
-
Initializes the Species object with the given parameters.
|
|
46
|
-
|
|
47
|
-
Args:
|
|
48
|
-
name (str): The name of the species.
|
|
49
|
-
HLC_298K_mol_m3_Pa (float): Henry's Law Constant at 298K [mol m-3 Pa-1]
|
|
50
|
-
HLC_exponential_factor_K: Henry's Law Constant exponential factor [K]
|
|
51
|
-
diffusion_coefficient_m2_s (float): Diffusion coefficient [m2 s-1]
|
|
52
|
-
N_star (float): A parameter used to calculate the mass accomodation factor (Ervens et al., 2003)
|
|
53
|
-
molecular_weight_kg_mol (float): Molecular weight [kg mol-1]
|
|
54
|
-
density_kg_m3 (float): Density [kg m-3]
|
|
55
|
-
tracer_type (str): Type of tracer: 'THIRD_BODY' or None [Deprecated, use is_third_body instead]
|
|
56
|
-
constant_concentration_mol_m3 (float): Constant concentration of the species (mol m-3)
|
|
57
|
-
constant_mixing_ratio_mol_mol (float): Constant mixing ratio of the species (mol mol-1)
|
|
58
|
-
is_third_body (bool): Whether the species is a third body.
|
|
59
|
-
other_properties (Dict[str, Any]): A dictionary of other properties of the species.
|
|
60
|
-
"""
|
|
61
|
-
super().__init__()
|
|
62
|
-
self.name = name if name is not None else self.name
|
|
63
|
-
self.HLC_298K_mol_m3_Pa = HLC_298K_mol_m3_Pa if HLC_298K_mol_m3_Pa is not None else self.HLC_298K_mol_m3_Pa
|
|
64
|
-
self.HLC_exponential_factor_K = HLC_exponential_factor_K if HLC_exponential_factor_K is not None else self.HLC_exponential_factor_K
|
|
65
|
-
self.diffusion_coefficient_m2_s = diffusion_coefficient_m2_s if diffusion_coefficient_m2_s is not None else self.diffusion_coefficient_m2_s
|
|
66
|
-
self.N_star = N_star if N_star is not None else self.N_star
|
|
67
|
-
self.molecular_weight_kg_mol = molecular_weight_kg_mol if molecular_weight_kg_mol is not None else self.molecular_weight_kg_mol
|
|
68
|
-
self.density_kg_m3 = density_kg_m3 if density_kg_m3 is not None else self.density_kg_m3
|
|
69
|
-
self.tracer_type = tracer_type if tracer_type is not None else self.tracer_type
|
|
70
|
-
self.constant_concentration_mol_m3 = constant_concentration_mol_m3 if constant_concentration_mol_m3 is not None else self.constant_concentration_mol_m3
|
|
71
|
-
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
|
|
72
|
-
self.is_third_body = is_third_body if is_third_body is not None else self.is_third_body
|
|
73
|
-
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
serialize_dict = {
|
|
78
|
-
"name": instance.name,
|
|
79
|
-
"HLC(298K) [mol m-3 Pa-1]": instance.HLC_298K_mol_m3_Pa,
|
|
80
|
-
"HLC exponential factor [K]": instance.HLC_exponential_factor_K,
|
|
81
|
-
"diffusion coefficient [m2 s-1]": instance.diffusion_coefficient_m2_s,
|
|
82
|
-
"N star": instance.N_star,
|
|
83
|
-
"molecular weight [kg mol-1]": instance.molecular_weight_kg_mol,
|
|
84
|
-
"density [kg m-3]": instance.density_kg_m3,
|
|
85
|
-
"tracer type": instance.tracer_type,
|
|
86
|
-
"constant concentration [mol m-3]": instance.constant_concentration_mol_m3,
|
|
87
|
-
"constant mixing ratio [mol mol-1]": instance.constant_mixing_ratio_mol_mol,
|
|
88
|
-
"is third body": instance.is_third_body,
|
|
89
|
-
}
|
|
90
|
-
_add_other_properties(serialize_dict, instance.other_properties)
|
|
91
|
-
return _remove_empty_keys(serialize_dict)
|
|
64
|
+
Species.__init__ = __init__
|
|
65
|
+
Species.serialize = serialize
|
|
@@ -2,93 +2,97 @@ from typing import Optional, Any, Dict, List, Union, Tuple
|
|
|
2
2
|
from .. import backend
|
|
3
3
|
from .phase import Phase
|
|
4
4
|
from .species import Species
|
|
5
|
-
from .
|
|
6
|
-
from .
|
|
5
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
6
|
+
from .reaction_component import ReactionComponent
|
|
7
|
+
from .ancillary import ReactionType
|
|
7
8
|
|
|
8
9
|
_backend = backend.get_backend()
|
|
9
|
-
|
|
10
|
-
_ReactionComponent = _backend._mechanism_configuration._ReactionComponent
|
|
10
|
+
Surface = _backend._mechanism_configuration._Surface
|
|
11
11
|
|
|
12
|
+
original_init = Surface.__init__
|
|
12
13
|
|
|
13
|
-
class Surface(_Surface):
|
|
14
|
-
"""
|
|
15
|
-
A class representing a surface in a chemical mechanism.
|
|
16
14
|
|
|
17
|
-
|
|
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.
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
Args:
|
|
20
36
|
name (str): The name of the surface.
|
|
21
37
|
reaction_probability (float): The probability of a reaction occurring on the surface.
|
|
22
38
|
gas_phase_species (Union[Species, Tuple[float, Species]]): The gas phase species involved in the reaction.
|
|
23
39
|
gas_phase_products (List[Union[Species, Tuple[float, Species]]]): The gas phase products formed in the reaction.
|
|
24
40
|
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
25
|
-
condensed_phase (Phase): The condensed phase in which the reaction occurs.
|
|
26
41
|
other_properties (Dict[str, Any]): A dictionary of other properties of the surface.
|
|
27
42
|
"""
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"""
|
|
43
|
-
Initializes the Surface object with the given parameters.
|
|
44
|
-
|
|
45
|
-
Args:
|
|
46
|
-
name (str): The name of the surface.
|
|
47
|
-
reaction_probability (float): The probability of a reaction occurring on the surface.
|
|
48
|
-
gas_phase_species (Union[Species, Tuple[float, Species]]): The gas phase species involved in the reaction.
|
|
49
|
-
gas_phase_products (List[Union[Species, Tuple[float, Species]]]): The gas phase products formed in the reaction.
|
|
50
|
-
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
51
|
-
condensed_phase (Phase): The condensed phase in which the reaction occurs.
|
|
52
|
-
other_properties (Dict[str, Any]): A dictionary of other properties of the surface.
|
|
53
|
-
"""
|
|
54
|
-
super().__init__()
|
|
55
|
-
self.name = name if name is not None else self.name
|
|
56
|
-
self.reaction_probability = reaction_probability if reaction_probability is not None else self.reaction_probability
|
|
57
|
-
self.gas_phase_species = (
|
|
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
|
+
[
|
|
58
57
|
(
|
|
59
|
-
|
|
60
|
-
if isinstance(
|
|
61
|
-
else
|
|
58
|
+
ReactionComponent(p.name)
|
|
59
|
+
if isinstance(p, Species)
|
|
60
|
+
else ReactionComponent(p[1].name, p[0])
|
|
62
61
|
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
self.gas_phase_products
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
+
"""
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"type": "SURFACE",
|
|
86
|
-
"name": instance.name,
|
|
87
|
-
"reaction probability": instance.reaction_probability,
|
|
88
|
-
"gas-phase species": instance.gas_phase_species.species_name,
|
|
89
|
-
"gas-phase products": ReactionComponentSerializer.serialize_list_reaction_components(instance.gas_phase_products),
|
|
90
|
-
"gas phase": instance.gas_phase,
|
|
91
|
-
"condensed phase": instance.condensed_phase,
|
|
92
|
-
}
|
|
93
|
-
_add_other_properties(serialize_dict, instance.other_properties)
|
|
94
|
-
return serialize_dict
|
|
96
|
+
Surface.__init__ = __init__
|
|
97
|
+
Surface.serialize = serialize
|
|
98
|
+
Surface.type = type
|
|
@@ -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
|