musica 0.11.1.3__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/CMakeLists.txt +35 -40
- musica/__init__.py +51 -3
- musica/_musica.cpython-39-darwin.so +0 -0
- musica/_version.py +1 -1
- musica/binding_common.cpp +16 -0
- musica/binding_common.hpp +7 -0
- musica/constants.py +3 -0
- musica/cpu_binding.cpp +10 -0
- musica/cuda.cpp +12 -0
- musica/cuda.py +10 -0
- musica/gpu_binding.cpp +10 -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/musica.cpp +1 -1
- musica/test/examples/v1/{full_configuration.json → full_configuration/full_configuration.json} +30 -15
- musica/test/examples/v1/{full_configuration.yaml → full_configuration/full_configuration.yaml} +16 -1
- musica/test/test_analytical.py +14 -12
- musica/test/test_chapman.py +18 -2
- musica/test/test_parser.py +4 -640
- musica/test/test_serializer.py +69 -0
- musica/test/test_util_full_mechanism.py +668 -0
- musica/tools/prepare_build_environment_linux.sh +8 -6
- musica/tools/repair_wheel_gpu.sh +25 -16
- musica/types.py +4 -6
- {musica-0.11.1.3.dist-info → musica-0.12.0.dist-info}/METADATA +179 -43
- musica-0.12.0.dist-info/RECORD +57 -0
- {musica-0.11.1.3.dist-info → musica-0.12.0.dist-info}/WHEEL +1 -1
- musica-0.12.0.dist-info/licenses/AUTHORS.md +59 -0
- musica/binding.cpp +0 -19
- musica/lib/libmusica.a +0 -0
- musica/lib/libyaml-cpp.a +0 -0
- musica/mechanism_configuration.py +0 -1291
- musica-0.11.1.3.dist-info/RECORD +0 -30
- {musica-0.11.1.3.dist-info → musica-0.12.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _Photolysis, _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 Photolysis(_Photolysis):
|
|
10
|
+
"""
|
|
11
|
+
A class representing a photolysis 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 Photolysis 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": "PHOTOLYSIS",
|
|
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,61 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union
|
|
2
|
+
from musica import _ReactionType, _Reactions, _ReactionsIterator
|
|
3
|
+
from .species import Species, _Species
|
|
4
|
+
from .utils import _remove_empty_keys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ReactionType(_ReactionType):
|
|
8
|
+
"""
|
|
9
|
+
A enum class representing a reaction type in a chemical mechanism.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Reactions(_Reactions):
|
|
14
|
+
"""
|
|
15
|
+
A class representing a collection of reactions in a chemical mechanism.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
reactions (List[Any]): A list of reactions in the mechanism.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
reactions: Optional[List[Any]] = None,
|
|
24
|
+
):
|
|
25
|
+
"""
|
|
26
|
+
Initializes the Reactions object with the given parameters.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
reactions (List[]): A list of reactions in the mechanism.
|
|
30
|
+
"""
|
|
31
|
+
super().__init__(reactions)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ReactionsIterator(_ReactionsIterator):
|
|
35
|
+
"""
|
|
36
|
+
An iterator for the Reactions class.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class ReactionComponentSerializer():
|
|
41
|
+
"""
|
|
42
|
+
A class for serializing reaction components.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def serialize_reaction_component(rc) -> Union[Dict, str]:
|
|
47
|
+
if isinstance(rc, Species) or isinstance(rc, _Species):
|
|
48
|
+
return rc.name
|
|
49
|
+
|
|
50
|
+
return _remove_empty_keys({
|
|
51
|
+
"species name": rc.species_name,
|
|
52
|
+
"coefficient": rc.coefficient,
|
|
53
|
+
"other_properties": rc.other_properties,
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
@staticmethod
|
|
57
|
+
def serialize_list_reaction_components(reaction_component_list) -> List[Union[Dict, str]]:
|
|
58
|
+
ret = []
|
|
59
|
+
for rc in reaction_component_list:
|
|
60
|
+
ret.append(ReactionComponentSerializer.serialize_reaction_component(rc))
|
|
61
|
+
return ret
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict, List, Union, Tuple
|
|
2
|
+
from musica import _SimpolPhaseTransfer, _ReactionComponent
|
|
3
|
+
from .phase import Phase
|
|
4
|
+
from .species import Species
|
|
5
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SimpolPhaseTransfer(_SimpolPhaseTransfer):
|
|
9
|
+
"""
|
|
10
|
+
A class representing a simplified phase transfer reaction rate constant.
|
|
11
|
+
|
|
12
|
+
Attributes:
|
|
13
|
+
name (str): The name of the simplified phase transfer reaction rate constant.
|
|
14
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
15
|
+
gas_phase_species (Union[Species, Tuple[float, Species]]): The gas phase species involved in the reaction.
|
|
16
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
17
|
+
aerosol_phase_species (Union[Species, Tuple[float, Species]]): The aerosol phase species involved in the reaction.
|
|
18
|
+
B (List[float]): The B parameters [unitless].
|
|
19
|
+
unknown_properties (Dict[str, Any]): A dictionary of other properties of the simplified phase transfer reaction rate constant.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
name: Optional[str] = None,
|
|
25
|
+
gas_phase: Optional[Phase] = None,
|
|
26
|
+
gas_phase_species: Optional[Union[Species, Tuple[float, Species]]] = None,
|
|
27
|
+
aerosol_phase: Optional[Phase] = None,
|
|
28
|
+
aerosol_phase_species: Optional[Union[Species, Tuple[float, Species]]] = None,
|
|
29
|
+
B: Optional[List[float]] = None,
|
|
30
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
31
|
+
):
|
|
32
|
+
"""
|
|
33
|
+
Initializes the SimpolPhaseTransfer object with the given parameters.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
name (str): The name of the simplified phase transfer reaction rate constant.
|
|
37
|
+
gas_phase (Phase): The gas phase in which the reaction occurs.
|
|
38
|
+
gas_phase_species (Union[Species, Tuple[float, Species]]): The gas phase species involved in the reaction.
|
|
39
|
+
aerosol_phase (Phase): The aerosol phase in which the reaction occurs.
|
|
40
|
+
aerosol_phase_species (Union[Species, Tuple[float, Species]]): The aerosol phase species involved in the reaction.
|
|
41
|
+
B (List[float]): The B parameters [unitless].
|
|
42
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the simplified phase transfer reaction rate constant.
|
|
43
|
+
"""
|
|
44
|
+
super().__init__()
|
|
45
|
+
self.name = name if name is not None else self.name
|
|
46
|
+
self.gas_phase = gas_phase.name if gas_phase is not None else self.gas_phase
|
|
47
|
+
self.gas_phase_species = (
|
|
48
|
+
(
|
|
49
|
+
_ReactionComponent(gas_phase_species.name)
|
|
50
|
+
if isinstance(gas_phase_species, Species)
|
|
51
|
+
else _ReactionComponent(gas_phase_species[1].name, gas_phase_species[0])
|
|
52
|
+
)
|
|
53
|
+
if gas_phase_species is not None
|
|
54
|
+
else self.gas_phase_species
|
|
55
|
+
)
|
|
56
|
+
self.aerosol_phase = aerosol_phase.name if aerosol_phase is not None else self.aerosol_phase
|
|
57
|
+
self.aerosol_phase_species = (
|
|
58
|
+
(
|
|
59
|
+
_ReactionComponent(aerosol_phase_species.name)
|
|
60
|
+
if isinstance(aerosol_phase_species, Species)
|
|
61
|
+
else _ReactionComponent(
|
|
62
|
+
aerosol_phase_species[1].name, aerosol_phase_species[0]
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
if aerosol_phase_species is not None
|
|
66
|
+
else self.aerosol_phase_species
|
|
67
|
+
)
|
|
68
|
+
if B is not None:
|
|
69
|
+
if len(B) != 4:
|
|
70
|
+
raise ValueError("B must be a list of 4 elements.")
|
|
71
|
+
self.B = B
|
|
72
|
+
else:
|
|
73
|
+
self.B = [0, 0, 0, 0]
|
|
74
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def serialize(instance) -> Dict:
|
|
78
|
+
serialize_dict = {
|
|
79
|
+
"type": "SIMPOL_PHASE_TRANSFER",
|
|
80
|
+
"name": instance.name,
|
|
81
|
+
"gas phase": instance.gas_phase,
|
|
82
|
+
"gas-phase species": instance.gas_phase_species.species_name,
|
|
83
|
+
"aerosol phase": instance.aerosol_phase,
|
|
84
|
+
"aerosol-phase species": instance.aerosol_phase_species.species_name,
|
|
85
|
+
"B": instance.B,
|
|
86
|
+
}
|
|
87
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
88
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from typing import Optional, Any, Dict
|
|
2
|
+
from musica import _Species
|
|
3
|
+
from .utils import _add_other_properties, _remove_empty_keys
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Species(_Species):
|
|
7
|
+
"""
|
|
8
|
+
A class representing a species in a chemical mechanism.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
name (str): The name of the species.
|
|
12
|
+
HLC_298K_mol_m3_Pa (float): Henry's Law Constant at 298K [mol m-3 Pa-1]
|
|
13
|
+
HLC_exponential_factor_K: Henry's Law Constant exponential factor [K]
|
|
14
|
+
diffusion_coefficient_m2_s (float): Diffusion coefficient [m2 s-1]
|
|
15
|
+
N_star (float): A parameter used to calculate the mass accomodation factor (Ervens et al., 2003)
|
|
16
|
+
molecular_weight_kg_mol (float): Molecular weight [kg mol-1]
|
|
17
|
+
density_kg_m3 (float): Density [kg m-3]
|
|
18
|
+
tracer_type (str): The type of tracer ("AEROSOL", "THIRD_BODY", "CONSTANT").
|
|
19
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the species.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
name: Optional[str] = None,
|
|
25
|
+
HLC_298K_mol_m3_Pa: Optional[float] = None,
|
|
26
|
+
HLC_exponential_factor_K: Optional[float] = None,
|
|
27
|
+
diffusion_coefficient_m2_s: Optional[float] = None,
|
|
28
|
+
N_star: Optional[float] = None,
|
|
29
|
+
molecular_weight_kg_mol: Optional[float] = None,
|
|
30
|
+
density_kg_m3: Optional[float] = None,
|
|
31
|
+
tracer_type: Optional[str] = None,
|
|
32
|
+
other_properties: Optional[Dict[str, Any]] = None,
|
|
33
|
+
):
|
|
34
|
+
"""
|
|
35
|
+
Initializes the Species object with the given parameters.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
name (str): The name of the species.
|
|
39
|
+
HLC_298K_mol_m3_Pa (float): Henry's Law Constant at 298K [mol m-3 Pa-1]
|
|
40
|
+
HLC_exponential_factor_K: Henry's Law Constant exponential factor [K]
|
|
41
|
+
diffusion_coefficient_m2_s (float): Diffusion coefficient [m2 s-1]
|
|
42
|
+
N_star (float): A parameter used to calculate the mass accomodation factor (Ervens et al., 2003)
|
|
43
|
+
molecular_weight_kg_mol (float): Molecular weight [kg mol-1]
|
|
44
|
+
density_kg_m3 (float): Density [kg m-3]
|
|
45
|
+
tracer_type (str): The type of tracer ("AEROSOL", "THIRD_BODY", "CONSTANT").
|
|
46
|
+
other_properties (Dict[str, Any]): A dictionary of other properties of the species.
|
|
47
|
+
"""
|
|
48
|
+
super().__init__()
|
|
49
|
+
self.name = name if name is not None else self.name
|
|
50
|
+
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
|
|
51
|
+
self.HLC_exponential_factor_K = HLC_exponential_factor_K if HLC_exponential_factor_K is not None else self.HLC_exponential_factor_K
|
|
52
|
+
self.diffusion_coefficient_m2_s = diffusion_coefficient_m2_s if diffusion_coefficient_m2_s is not None else self.diffusion_coefficient_m2_s
|
|
53
|
+
self.N_star = N_star if N_star is not None else self.N_star
|
|
54
|
+
self.molecular_weight_kg_mol = molecular_weight_kg_mol if molecular_weight_kg_mol is not None else self.molecular_weight_kg_mol
|
|
55
|
+
self.density_kg_m3 = density_kg_m3 if density_kg_m3 is not None else self.density_kg_m3
|
|
56
|
+
self.tracer_type = tracer_type if tracer_type is not None else self.tracer_type
|
|
57
|
+
self.other_properties = other_properties if other_properties is not None else self.other_properties
|
|
58
|
+
|
|
59
|
+
@staticmethod
|
|
60
|
+
def serialize(instance) -> Dict:
|
|
61
|
+
serialize_dict = {
|
|
62
|
+
"name": instance.name,
|
|
63
|
+
"HLC(298K) [mol m-3 Pa-1]": instance.HLC_298K_mol_m3_Pa,
|
|
64
|
+
"HLC exponential factor [K]": instance.HLC_exponential_factor_K,
|
|
65
|
+
"diffusion coefficient [m2 s-1]": instance.diffusion_coefficient_m2_s,
|
|
66
|
+
"N star": instance.N_star,
|
|
67
|
+
"molecular weight [kg mol-1]": instance.molecular_weight_kg_mol,
|
|
68
|
+
"density [kg m-3]": instance.density_kg_m3,
|
|
69
|
+
"tracer type": instance.tracer_type,
|
|
70
|
+
}
|
|
71
|
+
_add_other_properties(serialize_dict, instance.other_properties)
|
|
72
|
+
return _remove_empty_keys(serialize_dict)
|
|
@@ -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)
|