musica 0.11.1.4__cp39-cp39-macosx_11_0_arm64.whl → 0.12.0__cp39-cp39-macosx_11_0_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.
- musica/_musica.cpython-39-darwin.so +0 -0
- musica/_version.py +1 -1
- musica/constants.py +3 -0
- musica/mechanism_configuration/__init__.py +1 -0
- musica/mechanism_configuration/aqueous_equilibrium.py +101 -0
- musica/mechanism_configuration/arrhenius.py +121 -0
- musica/mechanism_configuration/branched.py +116 -0
- musica/mechanism_configuration/condensed_phase_arrhenius.py +116 -0
- musica/mechanism_configuration/condensed_phase_photolysis.py +91 -0
- musica/mechanism_configuration/emission.py +67 -0
- musica/mechanism_configuration/first_order_loss.py +67 -0
- musica/mechanism_configuration/henrys_law.py +85 -0
- musica/mechanism_configuration/mechanism_configuration.py +161 -0
- musica/mechanism_configuration/phase.py +43 -0
- musica/mechanism_configuration/photolysis.py +83 -0
- musica/mechanism_configuration/reactions.py +61 -0
- musica/mechanism_configuration/simpol_phase_transfer.py +88 -0
- musica/mechanism_configuration/species.py +72 -0
- musica/mechanism_configuration/surface.py +89 -0
- musica/mechanism_configuration/troe.py +137 -0
- musica/mechanism_configuration/tunneling.py +103 -0
- musica/mechanism_configuration/user_defined.py +83 -0
- musica/mechanism_configuration/utils.py +10 -0
- musica/mechanism_configuration/wet_deposition.py +49 -0
- musica/mechanism_configuration.cpp +0 -1
- musica/test/examples/v1/full_configuration/full_configuration.json +30 -15
- musica/test/examples/v1/full_configuration/full_configuration.yaml +16 -1
- musica/test/test_analytical.py +1 -1
- musica/test/test_parser.py +3 -639
- musica/test/test_serializer.py +69 -0
- musica/test/test_util_full_mechanism.py +668 -0
- musica/types.py +1 -4
- {musica-0.11.1.4.dist-info → musica-0.12.0.dist-info}/METADATA +61 -46
- musica-0.12.0.dist-info/RECORD +57 -0
- musica-0.12.0.dist-info/licenses/AUTHORS.md +59 -0
- musica/mechanism_configuration.py +0 -1291
- musica-0.11.1.4.dist-info/RECORD +0 -33
- {musica-0.11.1.4.dist-info → musica-0.12.0.dist-info}/WHEEL +0 -0
- {musica-0.11.1.4.dist-info → musica-0.12.0.dist-info}/licenses/LICENSE +0 -0
|
Binary file
|
musica/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
version = "0.
|
|
1
|
+
version = "0.12.0"
|
musica/constants.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .mechanism_configuration import *
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _AqueousEquilibrium, _ReactionComponent
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .species import Species
|
|
5
|
+
from .reactions import ReactionComponentSerializer
|
|
6
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AqueousEquilibrium(_AqueousEquilibrium):
|
|
10
|
+
"""
|
|
11
|
+
A class representing an aqueous equilibrium reaction rate constant.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
name (str): The name of the aqueous equilibrium reaction rate constant.
|
|
15
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
16
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
17
|
+
aerosol_phase_water (Species): The water species in the aerosol phase.
|
|
18
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
19
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
20
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
|
|
21
|
+
C (float): Exponential term [K-1].
|
|
22
|
+
k_reverse (float): Reverse rate constant [(mol m-3)^(n-1)s-1].
|
|
23
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the aqueous equilibrium reaction rate constant.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
name: Optional[str] = None,
|
|
29
|
+
aerosol_phase: Optional[Phase] = None,
|
|
30
|
+
aerosol_phase_water: Optional[Species] = None,
|
|
31
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
32
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
33
|
+
A: Optional[float] = None,
|
|
34
|
+
C: Optional[float] = None,
|
|
35
|
+
k_reverse: Optional[float] = None,
|
|
36
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
Initializes the AqueousEquilibrium object with the given parameters.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
name (str): The name of the aqueous equilibrium reaction rate constant.
|
|
43
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
44
|
+
aerosol_phase_water (Species): The water species in the aerosol phase.
|
|
45
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
46
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
47
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
|
|
48
|
+
C (float): Exponential term [K-1].
|
|
49
|
+
k_reverse (float): Reverse rate constant [(mol m-3)^(n-1)s-1].
|
|
50
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the aqueous equilibrium reaction rate constant.
|
|
51
|
+
"""
|
|
52
|
+
super().__init__()
|
|
53
|
+
self.name = name if name is not None else self.name
|
|
54
|
+
self.aerosol_phase = aerosol_phase.name if aerosol_phase is not None else self.aerosol_phase
|
|
55
|
+
self.aerosol_phase_water = (
|
|
56
|
+
aerosol_phase_water.name if aerosol_phase_water is not None else self.aerosol_phase_water
|
|
57
|
+
)
|
|
58
|
+
self.reactants = (
|
|
59
|
+
[
|
|
60
|
+
(
|
|
61
|
+
_ReactionComponent(r.name)
|
|
62
|
+
if isinstance(r, Species)
|
|
63
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
64
|
+
)
|
|
65
|
+
for r in reactants
|
|
66
|
+
]
|
|
67
|
+
if reactants is not None
|
|
68
|
+
else self.reactants
|
|
69
|
+
)
|
|
70
|
+
self.products = (
|
|
71
|
+
[
|
|
72
|
+
(
|
|
73
|
+
_ReactionComponent(p.name)
|
|
74
|
+
if isinstance(p, Species)
|
|
75
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
76
|
+
)
|
|
77
|
+
for p in products
|
|
78
|
+
]
|
|
79
|
+
if products is not None
|
|
80
|
+
else self.products
|
|
81
|
+
)
|
|
82
|
+
self.A = A if A is not None else self.A
|
|
83
|
+
self.C = C if C is not None else self.C
|
|
84
|
+
self.k_reverse = k_reverse if k_reverse is not None else self.k_reverse
|
|
85
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
86
|
+
|
|
87
|
+
@staticmethod
|
|
88
|
+
def serialize(instance) -> Dict:
|
|
89
|
+
serialize_dict = {
|
|
90
|
+
"type": "AQUEOUS_EQUILIBRIUM",
|
|
91
|
+
"name": instance.name,
|
|
92
|
+
"aerosol phase": instance.aerosol_phase,
|
|
93
|
+
"aerosol-phase water": instance.aerosol_phase_water,
|
|
94
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
95
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
96
|
+
"A": instance.A,
|
|
97
|
+
"C": instance.C,
|
|
98
|
+
"k_reverse": instance.k_reverse,
|
|
99
|
+
}
|
|
100
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
101
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _Arrhenius, _ReactionComponent
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .species import Species
|
|
5
|
+
from .reactions import ReactionComponentSerializer
|
|
6
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
7
|
+
from musica.constants import BOLTZMANN
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Arrhenius(_Arrhenius):
|
|
11
|
+
"""
|
|
12
|
+
A class representing an Arrhenius rate constant.
|
|
13
|
+
|
|
14
|
+
k = A * exp( C / T ) * ( T / D )^B * exp( 1 - E * P )
|
|
15
|
+
|
|
16
|
+
where:
|
|
17
|
+
k = rate constant
|
|
18
|
+
A = pre-exponential factor [(mol m-3)^(n-1)s-1]
|
|
19
|
+
B = temperature exponent [unitless]
|
|
20
|
+
C = exponential term [K-1]
|
|
21
|
+
D = reference temperature [K]
|
|
22
|
+
E = pressure scaling term [Pa-1]
|
|
23
|
+
T = temperature [K]
|
|
24
|
+
P = pressure [Pa]
|
|
25
|
+
n = number of reactants
|
|
26
|
+
|
|
27
|
+
Attributes:
|
|
28
|
+
name (str): The name of the Arrhenius rate constant.
|
|
29
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1] where n is the number of reactants.
|
|
30
|
+
B (float): Temperature exponent [unitless].
|
|
31
|
+
C (float): Exponential term [K-1].
|
|
32
|
+
D (float): Reference Temperature [K].
|
|
33
|
+
E (float): Pressure scaling term [Pa-1].
|
|
34
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
35
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
36
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
37
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the Arrhenius rate constant.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(
|
|
41
|
+
self,
|
|
42
|
+
name: Optional[str] = None,
|
|
43
|
+
A: Optional[float] = None,
|
|
44
|
+
B: Optional[float] = None,
|
|
45
|
+
C: Optional[float] = None,
|
|
46
|
+
Ea: Optional[float] = None,
|
|
47
|
+
D: Optional[float] = None,
|
|
48
|
+
E: Optional[float] = None,
|
|
49
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
50
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
51
|
+
gas_phase: Optional[Phase] = None,
|
|
52
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
53
|
+
):
|
|
54
|
+
"""
|
|
55
|
+
Initializes the Arrhenius object with the given parameters.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
name (str): The name of the Arrhenius rate constant.
|
|
59
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1] where n is the number of reactants.
|
|
60
|
+
B (float): Temperature exponent [unitless].
|
|
61
|
+
C (float): Exponential term [K-1].
|
|
62
|
+
Ea (float): Activation energy [J molecule-1].
|
|
63
|
+
D (float): Reference Temperature [K].
|
|
64
|
+
E (float): Pressure scaling term [Pa-1].
|
|
65
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
66
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
67
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
68
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the Arrhenius rate constant.
|
|
69
|
+
"""
|
|
70
|
+
super().__init__()
|
|
71
|
+
self.name = name if name is not None else self.name
|
|
72
|
+
self.A = A if A is not None else self.A
|
|
73
|
+
self.B = B if B is not None else self.B
|
|
74
|
+
if C is not None and Ea is not None:
|
|
75
|
+
raise ValueError("Cannot specify both C and Ea.")
|
|
76
|
+
self.C = -Ea / BOLTZMANN if Ea is not None else C if C is not None else self.C
|
|
77
|
+
self.D = D if D is not None else self.D
|
|
78
|
+
self.E = E if E is not None else self.E
|
|
79
|
+
self.reactants = (
|
|
80
|
+
[
|
|
81
|
+
(
|
|
82
|
+
_ReactionComponent(r.name)
|
|
83
|
+
if isinstance(r, Species)
|
|
84
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
85
|
+
)
|
|
86
|
+
for r in reactants
|
|
87
|
+
]
|
|
88
|
+
if reactants is not None
|
|
89
|
+
else self.reactants
|
|
90
|
+
)
|
|
91
|
+
self.products = (
|
|
92
|
+
[
|
|
93
|
+
(
|
|
94
|
+
_ReactionComponent(p.name)
|
|
95
|
+
if isinstance(p, Species)
|
|
96
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
97
|
+
)
|
|
98
|
+
for p in products
|
|
99
|
+
]
|
|
100
|
+
if products is not None
|
|
101
|
+
else self.products
|
|
102
|
+
)
|
|
103
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
104
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def serialize(instance) -> Dict:
|
|
108
|
+
serialize_dict = {
|
|
109
|
+
"type": "ARRHENIUS",
|
|
110
|
+
"name": instance.name,
|
|
111
|
+
"A": instance.A,
|
|
112
|
+
"B": instance.B,
|
|
113
|
+
"C": instance.C,
|
|
114
|
+
"D": instance.D,
|
|
115
|
+
"E": instance.E,
|
|
116
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
117
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
118
|
+
"gas phase": instance.gas_phase,
|
|
119
|
+
}
|
|
120
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
121
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _Branched, _ReactionComponent
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .species import Species
|
|
5
|
+
from .reactions import ReactionComponentSerializer
|
|
6
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Branched(_Branched):
|
|
10
|
+
"""
|
|
11
|
+
A class representing a branched reaction rate constant.
|
|
12
|
+
|
|
13
|
+
(TODO: get details from MusicBox)
|
|
14
|
+
|
|
15
|
+
Attributes:
|
|
16
|
+
name (str): The name of the branched reaction rate constant.
|
|
17
|
+
X (float): Pre-exponential branching factor [(mol m-3)^-(n-1)s-1].
|
|
18
|
+
Y (float): Exponential branching factor [K-1].
|
|
19
|
+
a0 (float): Z parameter [unitless].
|
|
20
|
+
n (float): A parameter [unitless].
|
|
21
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
22
|
+
nitrate_products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the nitrate branch.
|
|
23
|
+
alkoxy_products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the alkoxy branch.
|
|
24
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
25
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the branched reaction rate constant.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
name: Optional[str] = None,
|
|
31
|
+
X: Optional[float] = None,
|
|
32
|
+
Y: Optional[float] = None,
|
|
33
|
+
a0: Optional[float] = None,
|
|
34
|
+
n: Optional[float] = None,
|
|
35
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
36
|
+
nitrate_products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
37
|
+
alkoxy_products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
38
|
+
gas_phase: Optional[Phase] = None,
|
|
39
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
40
|
+
):
|
|
41
|
+
"""
|
|
42
|
+
Initializes the Branched object with the given parameters.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
name (str): The name of the branched reaction rate constant.
|
|
46
|
+
X (float): Pre-exponential branching factor [(mol m-3)^-(n-1)s-1].
|
|
47
|
+
Y (float): Exponential branching factor [K-1].
|
|
48
|
+
a0 (float): Z parameter [unitless].
|
|
49
|
+
n (float): A parameter [unitless].
|
|
50
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
51
|
+
nitrate_products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the nitrate branch.
|
|
52
|
+
alkoxy_products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the alkoxy branch.
|
|
53
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
54
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the branched reaction rate constant.
|
|
55
|
+
"""
|
|
56
|
+
super().__init__()
|
|
57
|
+
self.name = name if name is not None else self.name
|
|
58
|
+
self.X = X if X is not None else self.X
|
|
59
|
+
self.Y = Y if Y is not None else self.Y
|
|
60
|
+
self.a0 = a0 if a0 is not None else self.a0
|
|
61
|
+
self.n = n if n is not None else self.n
|
|
62
|
+
self.reactants = (
|
|
63
|
+
[
|
|
64
|
+
(
|
|
65
|
+
_ReactionComponent(r.name)
|
|
66
|
+
if isinstance(r, Species)
|
|
67
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
68
|
+
)
|
|
69
|
+
for r in reactants
|
|
70
|
+
]
|
|
71
|
+
if reactants is not None
|
|
72
|
+
else self.reactants
|
|
73
|
+
)
|
|
74
|
+
self.nitrate_products = (
|
|
75
|
+
[
|
|
76
|
+
(
|
|
77
|
+
_ReactionComponent(p.name)
|
|
78
|
+
if isinstance(p, Species)
|
|
79
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
80
|
+
)
|
|
81
|
+
for p in nitrate_products
|
|
82
|
+
]
|
|
83
|
+
if nitrate_products is not None
|
|
84
|
+
else self.nitrate_products
|
|
85
|
+
)
|
|
86
|
+
self.alkoxy_products = (
|
|
87
|
+
[
|
|
88
|
+
(
|
|
89
|
+
_ReactionComponent(p.name)
|
|
90
|
+
if isinstance(p, Species)
|
|
91
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
92
|
+
)
|
|
93
|
+
for p in alkoxy_products
|
|
94
|
+
]
|
|
95
|
+
if alkoxy_products is not None
|
|
96
|
+
else self.alkoxy_products
|
|
97
|
+
)
|
|
98
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
99
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
100
|
+
|
|
101
|
+
@staticmethod
|
|
102
|
+
def serialize(instance) -> Dict:
|
|
103
|
+
serialize_dict = {
|
|
104
|
+
"type": "BRANCHED_NO_RO2",
|
|
105
|
+
"name": instance.name,
|
|
106
|
+
"X": instance.X,
|
|
107
|
+
"Y": instance.Y,
|
|
108
|
+
"a0": instance.a0,
|
|
109
|
+
"n": instance.n,
|
|
110
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
111
|
+
"nitrate products": ReactionComponentSerializer.serialize_list_reaction_components(instance.nitrate_products),
|
|
112
|
+
"alkoxy products": ReactionComponentSerializer.serialize_list_reaction_components(instance.alkoxy_products),
|
|
113
|
+
"gas phase": instance.gas_phase,
|
|
114
|
+
}
|
|
115
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
116
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _CondensedPhaseArrhenius, _ReactionComponent
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .species import Species
|
|
5
|
+
from .reactions import ReactionComponentSerializer
|
|
6
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
7
|
+
from musica.constants import BOLTZMANN
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CondensedPhaseArrhenius(_CondensedPhaseArrhenius):
|
|
11
|
+
"""
|
|
12
|
+
A class representing a condensed phase Arrhenius rate constant.
|
|
13
|
+
|
|
14
|
+
Attributes:
|
|
15
|
+
name (str): The name of the condensed phase Arrhenius rate constant.
|
|
16
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
|
|
17
|
+
B (float): Temperature exponent [unitless].
|
|
18
|
+
C (float): Exponential term [K-1].
|
|
19
|
+
Ea (float): Activation energy [J molecule-1].
|
|
20
|
+
D (float): Reference Temperature [K].
|
|
21
|
+
E (float): Pressure scaling term [Pa-1].
|
|
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
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
25
|
+
aerosol_phase_water (Species): The water species in the aerosol phase.
|
|
26
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the condensed phase Arrhenius rate constant.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
name: Optional[str] = None,
|
|
32
|
+
A: Optional[float] = None,
|
|
33
|
+
B: Optional[float] = None,
|
|
34
|
+
C: Optional[float] = None,
|
|
35
|
+
Ea: Optional[float] = None,
|
|
36
|
+
D: Optional[float] = None,
|
|
37
|
+
E: Optional[float] = None,
|
|
38
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
39
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
40
|
+
aerosol_phase: Optional[Phase] = None,
|
|
41
|
+
aerosol_phase_water: Optional[Species] = None,
|
|
42
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
43
|
+
):
|
|
44
|
+
"""
|
|
45
|
+
Initializes the CondensedPhaseArrhenius object with the given parameters.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
name (str): The name of the condensed phase Arrhenius rate constant.
|
|
49
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
|
|
50
|
+
B (float): Temperature exponent [unitless].
|
|
51
|
+
C (float): Exponential term [K-1].
|
|
52
|
+
Ea (float): Activation energy [J molecule-1].
|
|
53
|
+
D (float): Reference Temperature [K].
|
|
54
|
+
E (float): Pressure scaling term [Pa-1].
|
|
55
|
+
reactants (List[Union[Species, Tuple[float, Species]]]]: A list of reactants involved in the reaction.
|
|
56
|
+
products (List[Union[Species, Tuple[float, Species]]]]: A list of products formed in the reaction.
|
|
57
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
58
|
+
aerosol_phase_water (Species): The water species in the aerosol phase.
|
|
59
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the condensed phase Arrhenius rate constant.
|
|
60
|
+
"""
|
|
61
|
+
super().__init__()
|
|
62
|
+
self.name = name if name is not None else self.name
|
|
63
|
+
self.A = A if A is not None else self.A
|
|
64
|
+
self.B = B if B is not None else self.B
|
|
65
|
+
if C is not None and Ea is not None:
|
|
66
|
+
raise ValueError("Cannot specify both C and Ea.")
|
|
67
|
+
self.C = -Ea / BOLTZMANN if Ea is not None else C if C is not None else self.C
|
|
68
|
+
self.D = D if D is not None else self.D
|
|
69
|
+
self.E = E if E is not None else self.E
|
|
70
|
+
self.reactants = (
|
|
71
|
+
[
|
|
72
|
+
(
|
|
73
|
+
_ReactionComponent(r.name)
|
|
74
|
+
if isinstance(r, Species)
|
|
75
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
76
|
+
)
|
|
77
|
+
for r in reactants
|
|
78
|
+
]
|
|
79
|
+
if reactants is not None
|
|
80
|
+
else self.reactants
|
|
81
|
+
)
|
|
82
|
+
self.products = (
|
|
83
|
+
[
|
|
84
|
+
(
|
|
85
|
+
_ReactionComponent(p.name)
|
|
86
|
+
if isinstance(p, Species)
|
|
87
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
88
|
+
)
|
|
89
|
+
for p in products
|
|
90
|
+
]
|
|
91
|
+
if products is not None
|
|
92
|
+
else self.products
|
|
93
|
+
)
|
|
94
|
+
self.aerosol_phase = aerosol_phase.name if aerosol_phase is not None else self.aerosol_phase
|
|
95
|
+
self.aerosol_phase_water = (
|
|
96
|
+
aerosol_phase_water.name if aerosol_phase_water is not None else self.aerosol_phase_water
|
|
97
|
+
)
|
|
98
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
99
|
+
|
|
100
|
+
@staticmethod
|
|
101
|
+
def serialize(instance) -> Dict:
|
|
102
|
+
serialize_dict = {
|
|
103
|
+
"type": "CONDENSED_PHASE_ARRHENIUS",
|
|
104
|
+
"name": instance.name,
|
|
105
|
+
"A": instance.A,
|
|
106
|
+
"B": instance.B,
|
|
107
|
+
"C": instance.C,
|
|
108
|
+
"D": instance.D,
|
|
109
|
+
"E": instance.E,
|
|
110
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
111
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
112
|
+
"aerosol phase": instance.aerosol_phase,
|
|
113
|
+
"aerosol-phase water": instance.aerosol_phase_water,
|
|
114
|
+
}
|
|
115
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
116
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _CondensedPhasePhotolysis, _ReactionComponent
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .species import Species
|
|
5
|
+
from .reactions import ReactionComponentSerializer
|
|
6
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CondensedPhasePhotolysis(_CondensedPhasePhotolysis):
|
|
11
|
+
"""
|
|
12
|
+
A class representing a condensed phase photolysis reaction rate constant.
|
|
13
|
+
|
|
14
|
+
Attributes:
|
|
15
|
+
name (str): The name of the condensed phase photolysis reaction rate constant.
|
|
16
|
+
scaling_factor (float): The scaling factor for the photolysis rate constant.
|
|
17
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
18
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
19
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
20
|
+
aerosol_phase_water (float): The water species in the aerosol phase [unitless].
|
|
21
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the condensed phase photolysis reaction rate constant.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
name: Optional[str] = None,
|
|
27
|
+
scaling_factor: Optional[float] = None,
|
|
28
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
29
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
30
|
+
aerosol_phase: Optional[Phase] = None,
|
|
31
|
+
aerosol_phase_water: Optional[Species] = None,
|
|
32
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
33
|
+
):
|
|
34
|
+
"""
|
|
35
|
+
Initializes the CondensedPhasePhotolysis object with the given parameters.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
name (str): The name of the condensed phase photolysis reaction rate constant.
|
|
39
|
+
scaling_factor (float): The scaling factor for the photolysis rate constant.
|
|
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
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
43
|
+
aerosol_phase_water (Species): The water species in the aerosol phase [unitless].
|
|
44
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the condensed phase photolysis reaction rate constant.
|
|
45
|
+
"""
|
|
46
|
+
super().__init__()
|
|
47
|
+
self.name = name if name is not None else self.name
|
|
48
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
49
|
+
self.reactants = (
|
|
50
|
+
[
|
|
51
|
+
(
|
|
52
|
+
_ReactionComponent(r.name)
|
|
53
|
+
if isinstance(r, Species)
|
|
54
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
55
|
+
)
|
|
56
|
+
for r in reactants
|
|
57
|
+
]
|
|
58
|
+
if reactants is not None
|
|
59
|
+
else self.reactants
|
|
60
|
+
)
|
|
61
|
+
self.products = (
|
|
62
|
+
[
|
|
63
|
+
(
|
|
64
|
+
_ReactionComponent(p.name)
|
|
65
|
+
if isinstance(p, Species)
|
|
66
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
67
|
+
)
|
|
68
|
+
for p in products
|
|
69
|
+
]
|
|
70
|
+
if products is not None
|
|
71
|
+
else self.products
|
|
72
|
+
)
|
|
73
|
+
self.aerosol_phase = aerosol_phase.name if aerosol_phase is not None else self.aerosol_phase
|
|
74
|
+
self.aerosol_phase_water = (
|
|
75
|
+
aerosol_phase_water.name if aerosol_phase_water is not None else self.aerosol_phase_water
|
|
76
|
+
)
|
|
77
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
78
|
+
|
|
79
|
+
@staticmethod
|
|
80
|
+
def serialize(instance) -> Dict:
|
|
81
|
+
serialize_dict = {
|
|
82
|
+
"type": "CONDENSED_PHASE_PHOTOLYSIS",
|
|
83
|
+
"name": instance.name,
|
|
84
|
+
"scaling factor": instance.scaling_factor,
|
|
85
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
86
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
87
|
+
"aerosol phase": instance.aerosol_phase,
|
|
88
|
+
"aerosol-phase water": instance.aerosol_phase_water,
|
|
89
|
+
}
|
|
90
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
91
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _Emission, _ReactionComponent
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .species import Species
|
|
5
|
+
from .reactions import ReactionComponentSerializer
|
|
6
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Emission(_Emission):
|
|
10
|
+
"""
|
|
11
|
+
A class representing an emission reaction rate constant.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
name (str): The name of the emission reaction rate constant.
|
|
15
|
+
scaling_factor (float): The scaling factor for the emission rate constant.
|
|
16
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
17
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
18
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the emission reaction rate constant.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
name: Optional[str] = None,
|
|
24
|
+
scaling_factor: Optional[float] = None,
|
|
25
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
26
|
+
gas_phase: Optional[Phase] = None,
|
|
27
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
28
|
+
):
|
|
29
|
+
"""
|
|
30
|
+
Initializes the Emission object with the given parameters.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
name (str): The name of the emission reaction rate constant.
|
|
34
|
+
scaling_factor (float): The scaling factor for the emission rate constant.
|
|
35
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
36
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
37
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the emission reaction rate constant.
|
|
38
|
+
"""
|
|
39
|
+
super().__init__()
|
|
40
|
+
self.name = name if name is not None else self.name
|
|
41
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
42
|
+
self.products = (
|
|
43
|
+
[
|
|
44
|
+
(
|
|
45
|
+
_ReactionComponent(p.name)
|
|
46
|
+
if isinstance(p, Species)
|
|
47
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
48
|
+
)
|
|
49
|
+
for p in products
|
|
50
|
+
]
|
|
51
|
+
if products is not None
|
|
52
|
+
else self.products
|
|
53
|
+
)
|
|
54
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
55
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def serialize(instance) -> Dict:
|
|
59
|
+
serialize_dict = {
|
|
60
|
+
"type": "EMISSION",
|
|
61
|
+
"name": instance.name,
|
|
62
|
+
"scaling factor": instance.scaling_factor,
|
|
63
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
64
|
+
"gas phase": instance.gas_phase,
|
|
65
|
+
}
|
|
66
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
67
|
+
return _remove_empty_keys(serialize_dict)
|