musica 0.11.1.4__cp312-cp312-win32.whl → 0.12.0__cp312-cp312-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/_musica.cp312-win32.pyd +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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _Surface, _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 Surface(_Surface):
|
|
10
|
+
"""
|
|
11
|
+
A class representing a surface in a chemical mechanism.
|
|
12
|
+
|
|
13
|
+
(TODO: get details from MusicBox)
|
|
14
|
+
|
|
15
|
+
Attributes:
|
|
16
|
+
name (str): The name of the surface.
|
|
17
|
+
reaction_probability (float): The probability of a reaction occurring on the surface.
|
|
18
|
+
gas_phase_species (Union[Species, Tuple[float, Species]]): The gas phase species involved in the reaction.
|
|
19
|
+
gas_phase_products (List[Union[Species, Tuple[float, Species]]]): The gas phase products formed in the reaction.
|
|
20
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
21
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
22
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the surface.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
name: Optional[str] = None,
|
|
28
|
+
reaction_probability: Optional[float] = None,
|
|
29
|
+
gas_phase_species: Optional[Union[Species, Tuple[float, Species]]] = None,
|
|
30
|
+
gas_phase_products: Optional[
|
|
31
|
+
List[Union[Species, Tuple[float, Species]]]
|
|
32
|
+
] = None,
|
|
33
|
+
gas_phase: Optional[Phase] = None,
|
|
34
|
+
aerosol_phase: Optional[Phase] = None,
|
|
35
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
36
|
+
):
|
|
37
|
+
"""
|
|
38
|
+
Initializes the Surface object with the given parameters.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
name (str): The name of the surface.
|
|
42
|
+
reaction_probability (float): The probability of a reaction occurring on the surface.
|
|
43
|
+
gas_phase_species (Union[Species, Tuple[float, Species]]): The gas phase species involved in the reaction.
|
|
44
|
+
gas_phase_products (List[Union[Species, Tuple[float, Species]]]): The gas phase products formed in the reaction.
|
|
45
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
46
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
47
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the surface.
|
|
48
|
+
"""
|
|
49
|
+
super().__init__()
|
|
50
|
+
self.name = name if name is not None else self.name
|
|
51
|
+
self.reaction_probability = reaction_probability if reaction_probability is not None else self.reaction_probability
|
|
52
|
+
self.gas_phase_species = (
|
|
53
|
+
(
|
|
54
|
+
_ReactionComponent(gas_phase_species.name)
|
|
55
|
+
if isinstance(gas_phase_species, Species)
|
|
56
|
+
else _ReactionComponent(gas_phase_species[1].name, gas_phase_species[0])
|
|
57
|
+
)
|
|
58
|
+
if gas_phase_species is not None
|
|
59
|
+
else self.gas_phase_species
|
|
60
|
+
)
|
|
61
|
+
self.gas_phase_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 gas_phase_products
|
|
69
|
+
]
|
|
70
|
+
if gas_phase_products is not None
|
|
71
|
+
else self.gas_phase_products
|
|
72
|
+
)
|
|
73
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
74
|
+
self.aerosol_phase = aerosol_phase.name if aerosol_phase is not None else self.aerosol_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": "SURFACE",
|
|
81
|
+
"name": instance.name,
|
|
82
|
+
"reaction probability": instance.reaction_probability,
|
|
83
|
+
"gas-phase species": instance.gas_phase_species.species_name,
|
|
84
|
+
"gas-phase products": ReactionComponentSerializer.serialize_list_reaction_components(instance.gas_phase_products),
|
|
85
|
+
"gas phase": instance.gas_phase,
|
|
86
|
+
"aerosol phase": instance.aerosol_phase,
|
|
87
|
+
}
|
|
88
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
89
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _Troe, _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 Troe(_Troe):
|
|
10
|
+
"""
|
|
11
|
+
A class representing a Troe rate constant.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
name (str): The name of the Troe rate constant.
|
|
15
|
+
k0_A (float): Pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1].
|
|
16
|
+
k0_B (float): Temperature exponent for the low-pressure limit [unitless].
|
|
17
|
+
k0_C (float): Exponential term for the low-pressure limit [K-1].
|
|
18
|
+
kinf_A (float): Pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1].
|
|
19
|
+
kinf_B (float): Temperature exponent for the high-pressure limit [unitless].
|
|
20
|
+
kinf_C (float): Exponential term for the high-pressure limit [K-1].
|
|
21
|
+
Fc (float): Troe parameter [unitless].
|
|
22
|
+
N (float): Troe parameter [unitless].
|
|
23
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
24
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
25
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
26
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the Troe rate constant.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
name: Optional[str] = None,
|
|
32
|
+
k0_A: Optional[float] = None,
|
|
33
|
+
k0_B: Optional[float] = None,
|
|
34
|
+
k0_C: Optional[float] = None,
|
|
35
|
+
kinf_A: Optional[float] = None,
|
|
36
|
+
kinf_B: Optional[float] = None,
|
|
37
|
+
kinf_C: Optional[float] = None,
|
|
38
|
+
Fc: Optional[float] = None,
|
|
39
|
+
N: Optional[float] = None,
|
|
40
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
41
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
42
|
+
gas_phase: Optional[Phase] = None,
|
|
43
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
44
|
+
):
|
|
45
|
+
"""
|
|
46
|
+
Initializes the Troe object with the given parameters.
|
|
47
|
+
|
|
48
|
+
k0 = k0_A * exp( k0_C / T ) * ( T / 300.0 )^k0_B
|
|
49
|
+
kinf = kinf_A * exp( kinf_C / T ) * ( T / 300.0 )^kinf_B
|
|
50
|
+
k = k0[M] / ( 1 + k0[M] / kinf ) * Fc^(1 + 1/N*(log10(k0[M]/kinf))^2)^-1
|
|
51
|
+
|
|
52
|
+
where:
|
|
53
|
+
k = rate constant
|
|
54
|
+
k0 = low-pressure limit rate constant
|
|
55
|
+
kinf = high-pressure limit rate constant
|
|
56
|
+
k0_A = pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1]
|
|
57
|
+
k0_B = temperature exponent for the low-pressure limit [unitless]
|
|
58
|
+
k0_C = exponential term for the low-pressure limit [K-1]
|
|
59
|
+
kinf_A = pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1]
|
|
60
|
+
kinf_B = temperature exponent for the high-pressure limit [unitless]
|
|
61
|
+
kinf_C = exponential term for the high-pressure limit [K-1]
|
|
62
|
+
Fc = Troe parameter [unitless]
|
|
63
|
+
N = Troe parameter [unitless]
|
|
64
|
+
T = temperature [K]
|
|
65
|
+
M = concentration of the third body [mol m-3]
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
name (str): The name of the Troe rate constant.
|
|
69
|
+
k0_A (float): Pre-exponential factor for the low-pressure limit [(mol m-3)^(n-1)s-1].
|
|
70
|
+
k0_B (float): Temperature exponent for the low-pressure limit [unitless].
|
|
71
|
+
k0_C (float): Exponential term for the low-pressure limit [K-1].
|
|
72
|
+
kinf_A (float): Pre-exponential factor for the high-pressure limit [(mol m-3)^(n-1)s-1].
|
|
73
|
+
kinf_B (float): Temperature exponent for the high-pressure limit [unitless].
|
|
74
|
+
kinf_C (float): Exponential term for the high-pressure limit [K-1].
|
|
75
|
+
Fc (float): Troe parameter [unitless].
|
|
76
|
+
N (float): Troe parameter [unitless].
|
|
77
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
78
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
79
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
80
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the Troe rate constant.
|
|
81
|
+
"""
|
|
82
|
+
super().__init__()
|
|
83
|
+
self.name = name if name is not None else self.name
|
|
84
|
+
self.k0_A = k0_A if k0_A is not None else self.k0_A
|
|
85
|
+
self.k0_B = k0_B if k0_B is not None else self.k0_B
|
|
86
|
+
self.k0_C = k0_C if k0_C is not None else self.k0_C
|
|
87
|
+
self.kinf_A = kinf_A if kinf_A is not None else self.kinf_A
|
|
88
|
+
self.kinf_B = kinf_B if kinf_B is not None else self.kinf_B
|
|
89
|
+
self.kinf_C = kinf_C if kinf_C is not None else self.kinf_C
|
|
90
|
+
self.Fc = Fc if Fc is not None else self.Fc
|
|
91
|
+
self.N = N if N is not None else self.N
|
|
92
|
+
self.reactants = (
|
|
93
|
+
[
|
|
94
|
+
(
|
|
95
|
+
_ReactionComponent(r.name)
|
|
96
|
+
if isinstance(r, Species)
|
|
97
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
98
|
+
)
|
|
99
|
+
for r in reactants
|
|
100
|
+
]
|
|
101
|
+
if reactants is not None
|
|
102
|
+
else self.reactants
|
|
103
|
+
)
|
|
104
|
+
self.products = (
|
|
105
|
+
[
|
|
106
|
+
(
|
|
107
|
+
_ReactionComponent(p.name)
|
|
108
|
+
if isinstance(p, Species)
|
|
109
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
110
|
+
)
|
|
111
|
+
for p in products
|
|
112
|
+
]
|
|
113
|
+
if products is not None
|
|
114
|
+
else self.products
|
|
115
|
+
)
|
|
116
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
117
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
118
|
+
|
|
119
|
+
@staticmethod
|
|
120
|
+
def serialize(instance) -> Dict:
|
|
121
|
+
serialize_dict = {
|
|
122
|
+
"type": "TROE",
|
|
123
|
+
"name": instance.name,
|
|
124
|
+
"k0_A": instance.k0_A,
|
|
125
|
+
"k0_B": instance.k0_B,
|
|
126
|
+
"k0_C": instance.k0_C,
|
|
127
|
+
"kinf_A": instance.kinf_A,
|
|
128
|
+
"kinf_B": instance.kinf_B,
|
|
129
|
+
"kinf_C": instance.kinf_C,
|
|
130
|
+
"Fc": instance.Fc,
|
|
131
|
+
"N": instance.N,
|
|
132
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
133
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
134
|
+
"gas phase": instance.gas_phase,
|
|
135
|
+
}
|
|
136
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
137
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _Tunneling, _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 Tunneling(_Tunneling):
|
|
10
|
+
"""
|
|
11
|
+
A class representing a quantum tunneling reaction rate constant.
|
|
12
|
+
|
|
13
|
+
k = A * exp( -B / T ) * exp( C / T^3 )
|
|
14
|
+
|
|
15
|
+
where:
|
|
16
|
+
k = rate constant
|
|
17
|
+
A = pre-exponential factor [(mol m-3)^(n-1)s-1]
|
|
18
|
+
B = tunneling parameter [K^-1]
|
|
19
|
+
C = tunneling parameter [K^-3]
|
|
20
|
+
T = temperature [K]
|
|
21
|
+
n = number of reactants
|
|
22
|
+
|
|
23
|
+
Attributes:
|
|
24
|
+
name (str): The name of the tunneling reaction rate constant.
|
|
25
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
|
|
26
|
+
B (float): Tunneling parameter [K^-1].
|
|
27
|
+
C (float): Tunneling parameter [K^-3].
|
|
28
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
29
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
30
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
31
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the tunneling reaction rate constant.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
name: Optional[str] = None,
|
|
37
|
+
A: Optional[float] = None,
|
|
38
|
+
B: Optional[float] = None,
|
|
39
|
+
C: Optional[float] = None,
|
|
40
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
41
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
42
|
+
gas_phase: Optional[Phase] = None,
|
|
43
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
44
|
+
):
|
|
45
|
+
"""
|
|
46
|
+
Initializes the Tunneling object with the given parameters.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
name (str): The name of the tunneling reaction rate constant.
|
|
50
|
+
A (float): Pre-exponential factor [(mol m-3)^(n-1)s-1].
|
|
51
|
+
B (float): Tunneling parameter [K^-1].
|
|
52
|
+
C (float): Tunneling parameter [K^-3].
|
|
53
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
54
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
55
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
56
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the tunneling reaction rate constant.
|
|
57
|
+
"""
|
|
58
|
+
super().__init__()
|
|
59
|
+
self.name = name if name is not None else self.name
|
|
60
|
+
self.A = A if A is not None else self.A
|
|
61
|
+
self.B = B if B is not None else self.B
|
|
62
|
+
self.C = C if C is not None else self.C
|
|
63
|
+
self.reactants = (
|
|
64
|
+
[
|
|
65
|
+
(
|
|
66
|
+
_ReactionComponent(r.name)
|
|
67
|
+
if isinstance(r, Species)
|
|
68
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
69
|
+
)
|
|
70
|
+
for r in reactants
|
|
71
|
+
]
|
|
72
|
+
if reactants is not None
|
|
73
|
+
else self.reactants
|
|
74
|
+
)
|
|
75
|
+
self.products = (
|
|
76
|
+
[
|
|
77
|
+
(
|
|
78
|
+
_ReactionComponent(p.name)
|
|
79
|
+
if isinstance(p, Species)
|
|
80
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
81
|
+
)
|
|
82
|
+
for p in products
|
|
83
|
+
]
|
|
84
|
+
if products is not None
|
|
85
|
+
else self.products
|
|
86
|
+
)
|
|
87
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
88
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
89
|
+
|
|
90
|
+
@staticmethod
|
|
91
|
+
def serialize(instance) -> Dict:
|
|
92
|
+
serialize_dict = {
|
|
93
|
+
"type": "TUNNELING",
|
|
94
|
+
"name": instance.name,
|
|
95
|
+
"A": instance.A,
|
|
96
|
+
"B": instance.B,
|
|
97
|
+
"C": instance.C,
|
|
98
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
99
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
100
|
+
"gas phase": instance.gas_phase,
|
|
101
|
+
}
|
|
102
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
103
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _UserDefined, _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 UserDefined(_UserDefined):
|
|
10
|
+
"""
|
|
11
|
+
A class representing a user-defined reaction rate constant.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
name (str): The name of the photolysis reaction rate constant.
|
|
15
|
+
scaling_factor (float): The scaling factor for the photolysis rate constant.
|
|
16
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
17
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
18
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
19
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
name: Optional[str] = None,
|
|
25
|
+
scaling_factor: Optional[float] = None,
|
|
26
|
+
reactants: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
27
|
+
products: Optional[List[Union[Species, Tuple[float, Species]]]] = None,
|
|
28
|
+
gas_phase: Optional[Phase] = None,
|
|
29
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
30
|
+
):
|
|
31
|
+
"""
|
|
32
|
+
Initializes the UserDefined object with the given parameters.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
name (str): The name of the photolysis reaction rate constant.
|
|
36
|
+
scaling_factor (float): The scaling factor for the photolysis rate constant.
|
|
37
|
+
reactants (List[Union[Species, Tuple[float, Species]]]): A list of reactants involved in the reaction.
|
|
38
|
+
products (List[Union[Species, Tuple[float, Species]]]): A list of products formed in the reaction.
|
|
39
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
40
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the photolysis reaction rate constant.
|
|
41
|
+
"""
|
|
42
|
+
super().__init__()
|
|
43
|
+
self.name = name if name is not None else self.name
|
|
44
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
45
|
+
self.reactants = (
|
|
46
|
+
[
|
|
47
|
+
(
|
|
48
|
+
_ReactionComponent(r.name)
|
|
49
|
+
if isinstance(r, Species)
|
|
50
|
+
else _ReactionComponent(r[1].name, r[0])
|
|
51
|
+
)
|
|
52
|
+
for r in reactants
|
|
53
|
+
]
|
|
54
|
+
if reactants is not None
|
|
55
|
+
else self.reactants
|
|
56
|
+
)
|
|
57
|
+
self.products = (
|
|
58
|
+
[
|
|
59
|
+
(
|
|
60
|
+
_ReactionComponent(p.name)
|
|
61
|
+
if isinstance(p, Species)
|
|
62
|
+
else _ReactionComponent(p[1].name, p[0])
|
|
63
|
+
)
|
|
64
|
+
for p in products
|
|
65
|
+
]
|
|
66
|
+
if products is not None
|
|
67
|
+
else self.products
|
|
68
|
+
)
|
|
69
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
70
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
71
|
+
|
|
72
|
+
@staticmethod
|
|
73
|
+
def serialize(instance) -> Dict:
|
|
74
|
+
serialize_dict = {
|
|
75
|
+
"type": "USER_DEFINED",
|
|
76
|
+
"name": instance.name,
|
|
77
|
+
"scaling factor": instance.scaling_factor,
|
|
78
|
+
"reactants": ReactionComponentSerializer.serialize_list_reaction_components(instance.reactants),
|
|
79
|
+
"products": ReactionComponentSerializer.serialize_list_reaction_components(instance.products),
|
|
80
|
+
"gas phase": instance.gas_phase,
|
|
81
|
+
}
|
|
82
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
83
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -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]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict
|
|
2
|
+
from musica import _WetDeposition
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class WetDeposition(_WetDeposition):
|
|
8
|
+
"""
|
|
9
|
+
A class representing a wet deposition reaction rate constant.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
name (str): The name of the wet deposition reaction rate constant.
|
|
13
|
+
scaling_factor (float): The scaling factor for the wet deposition rate constant.
|
|
14
|
+
aerosol_phase (Phase): The aerosol phase which undergoes wet deposition.
|
|
15
|
+
unknown_properties (Dict[str, Any]): A dictionary of other properties of the wet deposition reaction rate constant.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
name: Optional[str] = None,
|
|
21
|
+
scaling_factor: Optional[float] = None,
|
|
22
|
+
aerosol_phase: Optional[Phase] = None,
|
|
23
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
24
|
+
):
|
|
25
|
+
"""
|
|
26
|
+
Initializes the WetDeposition object with the given parameters.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
name (str): The name of the wet deposition reaction rate constant.
|
|
30
|
+
scaling_factor (float): The scaling factor for the wet deposition rate constant.
|
|
31
|
+
aerosol_phase (Phase): The aerosol phase which undergoes wet deposition.
|
|
32
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the wet deposition reaction rate constant.
|
|
33
|
+
"""
|
|
34
|
+
super().__init__()
|
|
35
|
+
self.name = name if name is not None else self.name
|
|
36
|
+
self.scaling_factor = scaling_factor if scaling_factor is not None else self.scaling_factor
|
|
37
|
+
self.aerosol_phase = aerosol_phase.name if aerosol_phase is not None else self.aerosol_phase
|
|
38
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
39
|
+
|
|
40
|
+
@staticmethod
|
|
41
|
+
def serialize(instance) -> Dict:
|
|
42
|
+
serialize_dict = {
|
|
43
|
+
"type": "WET_DEPOSITION",
|
|
44
|
+
"name": instance.name,
|
|
45
|
+
"scaling factor": instance.scaling_factor,
|
|
46
|
+
"aerosol phase": instance.aerosol_phase,
|
|
47
|
+
}
|
|
48
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
49
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -374,7 +374,6 @@ void bind_mechanism_configuration(py::module_ & mechanism_configuration)
|
|
|
374
374
|
py::class_<AqueousEquilibrium>(mechanism_configuration, "_AqueousEquilibrium")
|
|
375
375
|
.def(py::init<>())
|
|
376
376
|
.def_readwrite("name", &AqueousEquilibrium::name)
|
|
377
|
-
.def_readwrite("gas_phase", &AqueousEquilibrium::gas_phase)
|
|
378
377
|
.def_readwrite("aerosol_phase", &AqueousEquilibrium::aerosol_phase)
|
|
379
378
|
.def_readwrite("aerosol_phase_water", &AqueousEquilibrium::aerosol_phase_water)
|
|
380
379
|
.def_readwrite("reactants", &AqueousEquilibrium::reactants)
|
|
@@ -108,7 +108,8 @@
|
|
|
108
108
|
"aerosol phase": "aqueous aerosol",
|
|
109
109
|
"aerosol-phase species": "H2O2_aq",
|
|
110
110
|
"aerosol-phase water": "H2O_aq",
|
|
111
|
-
"name": "my henry's law"
|
|
111
|
+
"name": "my henry's law",
|
|
112
|
+
"__irrelevant": "2"
|
|
112
113
|
},
|
|
113
114
|
{
|
|
114
115
|
"type": "SIMPOL_PHASE_TRANSFER",
|
|
@@ -122,7 +123,8 @@
|
|
|
122
123
|
1.96E-03,
|
|
123
124
|
-4.96E-01
|
|
124
125
|
],
|
|
125
|
-
"name": "my simpol"
|
|
126
|
+
"name": "my simpol",
|
|
127
|
+
"__irrelevant": "2"
|
|
126
128
|
},
|
|
127
129
|
{
|
|
128
130
|
"type": "AQUEOUS_EQUILIBRIUM",
|
|
@@ -147,7 +149,8 @@
|
|
|
147
149
|
"coefficient": 1
|
|
148
150
|
}
|
|
149
151
|
],
|
|
150
|
-
"name": "my aqueous eq"
|
|
152
|
+
"name": "my aqueous eq",
|
|
153
|
+
"__irrelevant": "2"
|
|
151
154
|
},
|
|
152
155
|
{
|
|
153
156
|
"type": "CONDENSED_PHASE_ARRHENIUS",
|
|
@@ -174,7 +177,8 @@
|
|
|
174
177
|
"coefficient": 1
|
|
175
178
|
}
|
|
176
179
|
],
|
|
177
|
-
"name": "my condensed arrhenius"
|
|
180
|
+
"name": "my condensed arrhenius",
|
|
181
|
+
"__irrelevant": "2"
|
|
178
182
|
},
|
|
179
183
|
{
|
|
180
184
|
"type": "CONDENSED_PHASE_ARRHENIUS",
|
|
@@ -220,7 +224,8 @@
|
|
|
220
224
|
}
|
|
221
225
|
],
|
|
222
226
|
"scaling factor": 12.3,
|
|
223
|
-
"name": "condensed photo B"
|
|
227
|
+
"name": "condensed photo B",
|
|
228
|
+
"__irrelevant": "2"
|
|
224
229
|
},
|
|
225
230
|
{
|
|
226
231
|
"type": "EMISSION",
|
|
@@ -232,7 +237,8 @@
|
|
|
232
237
|
}
|
|
233
238
|
],
|
|
234
239
|
"name": "my emission",
|
|
235
|
-
"scaling factor": 12.3
|
|
240
|
+
"scaling factor": 12.3,
|
|
241
|
+
"__irrelevant": "2"
|
|
236
242
|
},
|
|
237
243
|
{
|
|
238
244
|
"type": "FIRST_ORDER_LOSS",
|
|
@@ -244,7 +250,8 @@
|
|
|
244
250
|
}
|
|
245
251
|
],
|
|
246
252
|
"name": "my first order loss",
|
|
247
|
-
"scaling factor": 12.3
|
|
253
|
+
"scaling factor": 12.3,
|
|
254
|
+
"__irrelevant": "2"
|
|
248
255
|
},
|
|
249
256
|
{
|
|
250
257
|
"type": "PHOTOLYSIS",
|
|
@@ -262,7 +269,8 @@
|
|
|
262
269
|
}
|
|
263
270
|
],
|
|
264
271
|
"name": "photo B",
|
|
265
|
-
"scaling factor": 12.3
|
|
272
|
+
"scaling factor": 12.3,
|
|
273
|
+
"__irrelevant": "2"
|
|
266
274
|
},
|
|
267
275
|
{
|
|
268
276
|
"type": "SURFACE",
|
|
@@ -280,7 +288,8 @@
|
|
|
280
288
|
}
|
|
281
289
|
],
|
|
282
290
|
"aerosol phase": "surface reacting phase",
|
|
283
|
-
"name": "my surface"
|
|
291
|
+
"name": "my surface",
|
|
292
|
+
"__irrelevant": "2"
|
|
284
293
|
},
|
|
285
294
|
{
|
|
286
295
|
"type": "TROE",
|
|
@@ -309,7 +318,8 @@
|
|
|
309
318
|
"kinf_C": 24,
|
|
310
319
|
"Fc": 0.9,
|
|
311
320
|
"N": 0.8,
|
|
312
|
-
"name": "my troe"
|
|
321
|
+
"name": "my troe",
|
|
322
|
+
"__irrelevant": "2"
|
|
313
323
|
},
|
|
314
324
|
{
|
|
315
325
|
"type": "BRANCHED_NO_RO2",
|
|
@@ -336,7 +346,8 @@
|
|
|
336
346
|
"Y": 167,
|
|
337
347
|
"a0": 0.15,
|
|
338
348
|
"n": 9,
|
|
339
|
-
"name": "my branched"
|
|
349
|
+
"name": "my branched",
|
|
350
|
+
"__irrelevant": "2"
|
|
340
351
|
},
|
|
341
352
|
{
|
|
342
353
|
"gas phase": "gas",
|
|
@@ -356,13 +367,15 @@
|
|
|
356
367
|
"species name": "C",
|
|
357
368
|
"coefficient": 1
|
|
358
369
|
}
|
|
359
|
-
]
|
|
370
|
+
],
|
|
371
|
+
"__irrelevant": "2"
|
|
360
372
|
},
|
|
361
373
|
{
|
|
362
374
|
"type": "WET_DEPOSITION",
|
|
363
375
|
"aerosol phase": "cloud",
|
|
364
376
|
"name": "rxn cloud",
|
|
365
|
-
"scaling factor": 12.3
|
|
377
|
+
"scaling factor": 12.3,
|
|
378
|
+
"__irrelevant": "2"
|
|
366
379
|
},
|
|
367
380
|
{
|
|
368
381
|
"type": "ARRHENIUS",
|
|
@@ -384,7 +397,8 @@
|
|
|
384
397
|
"C": 102.3,
|
|
385
398
|
"D": 63.4,
|
|
386
399
|
"E": -1.3,
|
|
387
|
-
"name": "my arrhenius"
|
|
400
|
+
"name": "my arrhenius",
|
|
401
|
+
"__irrelevant": "2"
|
|
388
402
|
},
|
|
389
403
|
{
|
|
390
404
|
"type": "ARRHENIUS",
|
|
@@ -428,7 +442,8 @@
|
|
|
428
442
|
}
|
|
429
443
|
],
|
|
430
444
|
"name": "my user defined",
|
|
431
|
-
"scaling factor": 12.3
|
|
445
|
+
"scaling factor": 12.3,
|
|
446
|
+
"__irrelevant": "2"
|
|
432
447
|
}
|
|
433
448
|
]
|
|
434
449
|
}
|