musica 0.11.1.1__cp312-cp312-win_amd64.whl → 0.14.2__cp312-cp312-win_amd64.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.
Files changed (129) hide show
  1. musica/__init__.py +23 -3
  2. musica/_musica.cp312-win_amd64.pyd +0 -0
  3. musica/_version.py +1 -1
  4. musica/backend.py +58 -0
  5. musica/carma/__init__.py +20 -0
  6. musica/carma/carma.py +1727 -0
  7. musica/constants.py +3 -0
  8. musica/cuda.py +13 -0
  9. musica/examples/__init__.py +1 -0
  10. musica/examples/carma_aluminum.py +124 -0
  11. musica/examples/carma_sulfate.py +246 -0
  12. musica/examples/examples.py +165 -0
  13. musica/examples/sulfate_box_model.py +439 -0
  14. musica/examples/ts1_latin_hypercube.py +245 -0
  15. musica/main.py +128 -0
  16. musica/mechanism_configuration/__init__.py +18 -0
  17. musica/mechanism_configuration/ancillary.py +6 -0
  18. musica/mechanism_configuration/arrhenius.py +149 -0
  19. musica/mechanism_configuration/branched.py +140 -0
  20. musica/mechanism_configuration/emission.py +82 -0
  21. musica/mechanism_configuration/first_order_loss.py +90 -0
  22. musica/mechanism_configuration/mechanism.py +93 -0
  23. musica/mechanism_configuration/phase.py +58 -0
  24. musica/mechanism_configuration/phase_species.py +58 -0
  25. musica/mechanism_configuration/photolysis.py +98 -0
  26. musica/mechanism_configuration/reaction_component.py +54 -0
  27. musica/mechanism_configuration/reactions.py +32 -0
  28. musica/mechanism_configuration/species.py +65 -0
  29. musica/mechanism_configuration/surface.py +98 -0
  30. musica/mechanism_configuration/taylor_series.py +136 -0
  31. musica/mechanism_configuration/ternary_chemical_activation.py +160 -0
  32. musica/mechanism_configuration/troe.py +160 -0
  33. musica/mechanism_configuration/tunneling.py +126 -0
  34. musica/mechanism_configuration/user_defined.py +99 -0
  35. musica/mechanism_configuration/utils.py +10 -0
  36. musica/micm/__init__.py +10 -0
  37. musica/micm/conditions.py +49 -0
  38. musica/micm/micm.py +135 -0
  39. musica/micm/solver.py +8 -0
  40. musica/micm/solver_result.py +24 -0
  41. musica/micm/state.py +220 -0
  42. musica/micm/utils.py +18 -0
  43. musica/tuvx/__init__.py +11 -0
  44. musica/tuvx/grid.py +98 -0
  45. musica/tuvx/grid_map.py +167 -0
  46. musica/tuvx/profile.py +130 -0
  47. musica/tuvx/profile_map.py +167 -0
  48. musica/tuvx/radiator.py +95 -0
  49. musica/tuvx/radiator_map.py +173 -0
  50. musica/tuvx/tuvx.py +283 -0
  51. musica-0.14.2.dist-info/DELVEWHEEL +2 -0
  52. {musica-0.11.1.1.dist-info → musica-0.14.2.dist-info}/METADATA +146 -63
  53. musica-0.14.2.dist-info/RECORD +104 -0
  54. {musica-0.11.1.1.dist-info → musica-0.14.2.dist-info}/WHEEL +1 -1
  55. musica-0.14.2.dist-info/entry_points.txt +3 -0
  56. musica-0.14.2.dist-info/licenses/AUTHORS.md +59 -0
  57. musica.libs/libaws-c-auth-0a61a643442f1c0912920b37d9fb0be5.dll +0 -0
  58. musica.libs/libaws-c-cal-eaafa5905de6c9ba274eb8737e6087dd.dll +0 -0
  59. musica.libs/libaws-c-common-b4aa4468297ae8e1664f9380a5510317.dll +0 -0
  60. musica.libs/libaws-c-compression-9f997952aeae03067122ca493c9081b5.dll +0 -0
  61. musica.libs/libaws-c-event-stream-fe9cc8e1692f60c2b5694a8959dbd7c3.dll +0 -0
  62. musica.libs/libaws-c-http-4a9d50ba6ad8882f5267ef89e5e4103a.dll +0 -0
  63. musica.libs/libaws-c-io-e454f1c7a44e77f8c957a016888754be.dll +0 -0
  64. musica.libs/libaws-c-mqtt-67c5fc291740f5cbc5e53fb767e93226.dll +0 -0
  65. musica.libs/libaws-c-s3-206db4af6e1a95637b1921ea596603b9.dll +0 -0
  66. musica.libs/libaws-c-sdkutils-5c9c62dafb8b774cd4a3386f95ef428d.dll +0 -0
  67. musica.libs/libaws-checksums-7e50fe01b862214958f4d2ab4215fde5.dll +0 -0
  68. musica.libs/libaws-cpp-sdk-core-7a9ba9c045ee16f5262e955d96865718.dll +0 -0
  69. musica.libs/libaws-cpp-sdk-s3-4eebff3923c6d250fb508da3c990e0ae.dll +0 -0
  70. musica.libs/libaws-crt-cpp-3173f1e6f504a96d88e8dbf9e04b3b14.dll +0 -0
  71. musica.libs/libbrotlicommon-c62c08223e450dfc2fff33c752cc2285.dll +0 -0
  72. musica.libs/libbrotlidec-ccde7c3978eb1d2e052b193f2968d30a.dll +0 -0
  73. musica.libs/libbz2-1-669a4bf9266d5f020e843aa5fd75b93c.dll +0 -0
  74. musica.libs/libcrypto-3-x64-237eeb55505d067eab5e0b886e519387.dll +0 -0
  75. musica.libs/libcurl-4-bdf865458887dc1235b192ec83729214.dll +0 -0
  76. musica.libs/libgcc_s_seh-1-5a3153f12338f79fbbb7bf095fc5cef1.dll +0 -0
  77. musica.libs/libgfortran-5-90848e0eacdecce3a9005faf5aaec7e7.dll +0 -0
  78. musica.libs/libgomp-1-b8afcf09fecd2f6f01e454c9a5f2c690.dll +0 -0
  79. musica.libs/libhdf5-320-eec6c8ba2fdde30d365786ffbff40989.dll +0 -0
  80. musica.libs/libhdf5_hl-320-7e26e1caaad6be4082d728cf08ab2de4.dll +0 -0
  81. musica.libs/libiconv-2-b37d1b4acab5310c4e4f6e2a961d1464.dll +0 -0
  82. musica.libs/libidn2-0-d17600177f3b4cd2521d595b3472d240.dll +0 -0
  83. musica.libs/libintl-8-e4d4ca6b37338fbb0a8c1246afa7258f.dll +0 -0
  84. musica.libs/liblzma-5-bd95aa0fda6e7c8e41b3843d6fc2942c.dll +0 -0
  85. musica.libs/libnetcdf-0623e518145bddd30cc615b6d7f2f9c1.dll +0 -0
  86. musica.libs/libnetcdff-7-982cb7ee026b78f05a79d00e735f91d1.dll +0 -0
  87. musica.libs/libnghttp2-14-6d49ed806389b4892bcf29c6ed6e3984.dll +0 -0
  88. musica.libs/libnghttp3-9-d3c9b57d760f6dae7d6a067a68126b84.dll +0 -0
  89. musica.libs/libngtcp2-16-a43356e6376d41ce4238e2c55581636a.dll +0 -0
  90. musica.libs/libngtcp2_crypto_ossl-0-b37121badf25a552e5654f27bf6ff093.dll +0 -0
  91. musica.libs/libopenblas-a16595c3cae114c5c7304aa8bb3c1272.dll +0 -0
  92. musica.libs/libpsl-5-4368d4c2412410a4a14f3e7f3227e295.dll +0 -0
  93. musica.libs/libquadmath-0-4edeffe0a60c96360445d33a1876dbda.dll +0 -0
  94. musica.libs/libssh2-1-f407a2b50419bd904c7eb2c101ae81ea.dll +0 -0
  95. musica.libs/libssl-3-x64-d2e43d36e6f87f6f1645717cd0871f86.dll +0 -0
  96. musica.libs/libstdc++-6-83061aaccaf8df77a3b584efef12bc7c.dll +0 -0
  97. musica.libs/libsz-2-d12f3d26417507ec8dea9964f9fe36a1.dll +0 -0
  98. musica.libs/libunistring-5-0473d7a71d94f08292beed694c34f7d1.dll +0 -0
  99. musica.libs/libwinpthread-1-9157bac12a85fb717fa3d2bf6712631a.dll +0 -0
  100. musica.libs/libxml2-16-7fe545d280fdef922282226eef91571f.dll +0 -0
  101. musica.libs/libzip-62d3c877b7842bc509fc000316a4731b.dll +0 -0
  102. musica.libs/libzstd-a25427164f8775046eb8ce488d7d0884.dll +0 -0
  103. musica.libs/zlib1-1dc85208162ee57fe97e892bb5160fe9.dll +0 -0
  104. _musica.cp312-win_amd64.pyd +0 -0
  105. lib/musica.lib +0 -0
  106. lib/yaml-cpp.lib +0 -0
  107. musica/CMakeLists.txt +0 -47
  108. musica/binding.cpp +0 -19
  109. musica/mechanism_configuration.cpp +0 -519
  110. musica/mechanism_configuration.py +0 -1291
  111. musica/musica.cpp +0 -214
  112. musica/test/examples/v0/config.json +0 -7
  113. musica/test/examples/v0/config.yaml +0 -3
  114. musica/test/examples/v0/reactions.json +0 -193
  115. musica/test/examples/v0/reactions.yaml +0 -142
  116. musica/test/examples/v0/species.json +0 -40
  117. musica/test/examples/v0/species.yaml +0 -19
  118. musica/test/examples/v1/full_configuration.json +0 -434
  119. musica/test/examples/v1/full_configuration.yaml +0 -271
  120. musica/test/test_analytical.py +0 -323
  121. musica/test/test_chapman.py +0 -123
  122. musica/test/test_parser.py +0 -693
  123. musica/test/tuvx.py +0 -10
  124. musica/tools/prepare_build_environment_linux.sh +0 -41
  125. musica/tools/prepare_build_environment_windows.sh +0 -22
  126. musica/tools/repair_wheel_gpu.sh +0 -25
  127. musica/types.py +0 -362
  128. musica-0.11.1.1.dist-info/RECORD +0 -30
  129. {musica-0.11.1.1.dist-info → musica-0.14.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,41 +0,0 @@
1
- #! /bin/bash
2
-
3
- set -e
4
- set -x
5
-
6
- # Update the mirror list to use vault.centos.org
7
- sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
8
- sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
9
- sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
10
-
11
- sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
12
- sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
13
-
14
- yum install -y zip tree
15
-
16
- # Use CIBW_ARCHS or CIBW_ARCH if set, else fallback to uname -m
17
- if [ -n "$CIBW_ARCHS" ]; then
18
- target_arch="$CIBW_ARCHS"
19
- elif [ -n "$CIBW_ARCH" ]; then
20
- target_arch="$CIBW_ARCH"
21
- else
22
- target_arch="$(uname -m)"
23
- fi
24
-
25
- echo "Detected target_arch: $target_arch"
26
-
27
- if [ "$target_arch" = "x86_64" ]; then
28
- # Install CUDA 12.2 for x86_64:
29
- yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo
30
- # error mirrorlist.centos.org doesn't exists anymore.
31
- sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
32
- sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
33
- sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
34
- yum install --setopt=obsoletes=0 -y \
35
- cuda-nvcc-12-2-12.2.140-1 \
36
- cuda-cudart-devel-12-2-12.2.140-1 \
37
- libcurand-devel-12-2-10.3.3.141-1 \
38
- libcublas-devel-12-2-12.2.5.6-1 \
39
- libnccl-devel-2.19.3-1+cuda12.2
40
- ln -s cuda-12.2 /usr/local/cuda
41
- fi
@@ -1,22 +0,0 @@
1
- #! /bin/bash
2
-
3
- set -e
4
- set -x
5
-
6
- CUDA_ROOT="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8"
7
- # curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_537.13_windows.exe
8
- curl --netrc-optional -L -nv -o cuda.exe https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_572.61_windows.exe
9
- ./cuda.exe -s nvcc_12.8 cudart_12.8 cublas_dev_12.8 curand_dev_12.8
10
- rm cuda.exe
11
-
12
- export CUDA_PATH="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8"
13
- export PATH="$CUDA_PATH/bin:$PATH"
14
-
15
- ls "c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8/extras/visual_studio_integration/MSBuildExtensions"
16
- ls "c/Program Files (x86)/Microsoft Visual Studio/"
17
-
18
- # choco install cuda
19
-
20
- ls "$CUDA_PATH"
21
- ls "$CUDA_PATH/bin"
22
- which nvcc.exe
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
-
4
- auditwheel repair --exclude libcublas --exclude libcublasLt --exclude libcudart -w "$2" "$1"
5
-
6
- for whl in "$2"/*.whl; do
7
- tmpdir=$(mktemp -d)
8
- unzip -q "$whl" -d "$tmpdir"
9
- tree "$tmpdir"
10
- echo "Before patchelf:"
11
- readelf -d "$tmpdir"/_musica*.so
12
- patchelf --remove-rpath "$tmpdir"/_musica*.so
13
- patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../../nvidia/cublas/lib:\$ORIGIN/../../nvidia/cuda_runtime/lib" --force-rpath "$tmpdir"/_musica*.so
14
- # Remove bundled CUDA libraries
15
- rm -f "$tmpdir"/musica.libs/libcudart-*.so*
16
- rm -f "$tmpdir"/musica.libs/libcublas-*.so*
17
- rm -f "$tmpdir"/musica.libs/libcublasLt-*.so*
18
- echo "After patchelf:"
19
- readelf -d "$tmpdir"/_musica*.so
20
- # Repack the wheel with correct structure
21
- (cd "$tmpdir" && zip -qr "${whl%.whl}.patched.whl" .)
22
- rm -rf "$tmpdir"
23
- # Replace the original wheel with the patched one
24
- mv "${whl%.whl}.patched.whl" "$whl"
25
- done
musica/types.py DELETED
@@ -1,362 +0,0 @@
1
- # Copyright (C) 2023-2025 University Corporation for Atmospheric Research
2
- # SPDX-License-Identifier: Apache-2.0
3
- #
4
- # This file is part of the musica Python package.
5
- # For more information, see the LICENSE file in the top-level directory of this distribution.
6
- from typing import Optional, Any, Dict, List, Union, Tuple
7
- from os import PathLike
8
- import math
9
- from _musica._core import (
10
- _Conditions,
11
- _SolverType,
12
- _Solver,
13
- _State,
14
- _create_solver,
15
- _create_solver_from_mechanism,
16
- _create_state,
17
- _micm_solve,
18
- _vector_size,
19
- _species_ordering,
20
- _user_defined_rate_parameters_ordering,
21
- )
22
- import musica.mechanism_configuration as mc
23
-
24
- AVOGADRO = 6.02214076e23 # mol^-1
25
- BOLTZMANN = 1.380649e-23 # J K^-1
26
- GAS_CONSTANT = AVOGADRO * BOLTZMANN # J K^-1 mol^-1
27
-
28
- FilePath = Union[str, "PathLike[str]"]
29
-
30
-
31
- def _get_vector_matrix_indices(row_index: int, column_index: int, vector_size: int) -> Tuple[int, int]:
32
- """
33
- Get the row and column indices for a matrix given the row and column indices for a vector.
34
-
35
- Parameters
36
- ----------
37
- row_index : int
38
- Row index of the vector.
39
- column_index : int
40
- Column index of the vector.
41
- vector_size : int
42
- Size of the vector.
43
-
44
- Returns
45
- -------
46
- tuple[int, int]
47
- Index for which state matrix to use and the index in that matrix'x underlying data vector.
48
- """
49
- return (row_index // vector_size, column_index * (vector_size - 1) + row_index % vector_size)
50
-
51
-
52
- class Conditions(_Conditions):
53
- """
54
- Conditions class for the MICM solver. If air density is not provided,
55
- it will be calculated from the Ideal Gas Law using the provided temperature and pressure.
56
-
57
- Parameters
58
- ----------
59
- temperature : float
60
- Temperature in Kelvin.
61
- pressure : float
62
- Pressure in Pascals.
63
- air_density : float
64
- Air density in mol m-3
65
- """
66
-
67
- def __init__(
68
- self,
69
- temperature: Optional[Union[float, int]] = None,
70
- pressure: Optional[Union[float, int]] = None,
71
- air_density: Optional[Union[float, int]] = None,
72
- ):
73
- super().__init__()
74
- if temperature is not None:
75
- self.temperature = temperature
76
- if pressure is not None:
77
- self.pressure = pressure
78
- if air_density is not None:
79
- self.air_density = air_density
80
- elif temperature is not None and pressure is not None:
81
- self.air_density = 1.0 / (GAS_CONSTANT * temperature / pressure)
82
-
83
-
84
- class SolverType(_SolverType):
85
- """
86
- Enum class for the type of solver to use.
87
- """
88
-
89
-
90
- class State():
91
- """
92
- State class for the MICM solver. It contains the initial conditions and species concentrations.
93
- """
94
-
95
- def __init__(self, solver: _Solver, number_of_grid_cells: int, vector_size: int = 0):
96
- if number_of_grid_cells < 1:
97
- raise ValueError("number_of_grid_cells must be greater than 0.")
98
- super().__init__()
99
- self.__states = [
100
- _create_state(solver, min(vector_size, number_of_grid_cells - i * vector_size))
101
- for i in range(math.ceil(number_of_grid_cells / vector_size))
102
- ] if vector_size > 0 else [_create_state(solver, number_of_grid_cells)]
103
- self.__species_ordering = _species_ordering(self.__states[0])
104
- self.__user_defined_rate_parameters_ordering = _user_defined_rate_parameters_ordering(self.__states[0])
105
- self.__number_of_grid_cells = number_of_grid_cells
106
- self.__vector_size = vector_size
107
-
108
- def get_internal_states(self) -> List[_State]:
109
- """
110
- Get the internal states of the MICM solver.
111
-
112
- Returns
113
- -------
114
- List[_State]
115
- List of internal states.
116
- """
117
- return self.__states
118
-
119
- def set_concentrations(self, concentrations: Dict[str, Union[Union[float, int], List[Union[float, int]]]]):
120
- """
121
- Set the concentrations of the species in the state. Any species not in the
122
- dictionary will be set to zero. The concentrations can be a single value when solving
123
- for a single grid cell, or a list of values when solving for multiple grid cells.
124
-
125
- Parameters
126
- ----------
127
- concentrations : Dict[str, Union[Union[float, int], List[Union[float, int]]]]
128
- Dictionary of species names and their concentrations.
129
- """
130
- for name, value in concentrations.items():
131
- if name not in self.__species_ordering:
132
- raise ValueError(f"Species {name} not found in the mechanism.")
133
- i_species = self.__species_ordering[name]
134
- if isinstance(value, float) or isinstance(value, int):
135
- value = [value]
136
- if len(value) != self.__number_of_grid_cells:
137
- raise ValueError(f"Concentration list for {name} must have length {self.__number_of_grid_cells}.")
138
- # Counter 'k' is used to map grid cell indices across multiple state segments.
139
- k = 0
140
- for state in self.__states:
141
- cell_stride, species_stride = state.concentration_strides()
142
- for i_cell in range(state.number_of_grid_cells()):
143
- state.concentrations[i_species * species_stride + i_cell * cell_stride] = value[k]
144
- k += 1
145
-
146
- def set_user_defined_rate_parameters(
147
- self, user_defined_rate_parameters: Dict[str, Union[Union[float, int], List[Union[float, int]]]]):
148
- """
149
- Set the user-defined rate parameters in the state. Any parameter not in the
150
- dictionary will be set to zero. The parameters can be a single value when solving
151
- for a single grid cell, or a list of values when solving for multiple grid cells.
152
-
153
- Parameters
154
- ----------
155
- user_defined_rate_parameters : Dict[str, Union[Union[float, int], List[Union[float, int]]]]
156
- Dictionary of user-defined rate parameter names and their values.
157
- """
158
- for name, value in user_defined_rate_parameters.items():
159
- if name not in self.__user_defined_rate_parameters_ordering:
160
- raise ValueError(f"User-defined rate parameter {name} not found in the mechanism.")
161
- i_param = self.__user_defined_rate_parameters_ordering[name]
162
- if isinstance(value, float) or isinstance(value, int):
163
- value = [value]
164
- if len(value) != self.__number_of_grid_cells:
165
- raise ValueError(
166
- f"User-defined rate parameter list for {name} must have length {self.__number_of_grid_cells}.")
167
- # Initialize `k` to index the grid cells when assigning user-defined rate parameters.
168
- k = 0
169
- for state in self.__states:
170
- cell_stride, param_stride = state.user_defined_rate_parameter_strides()
171
- for i_cell in range(state.number_of_grid_cells()):
172
- state.user_defined_rate_parameters[i_param * param_stride + i_cell * cell_stride] = value[k]
173
- k += 1
174
-
175
- def set_conditions(self,
176
- temperatures: Union[Union[float, int], List[Union[float, int]]],
177
- pressures: Union[Union[float, int], List[Union[float, int]]],
178
- air_densities: Optional[Union[Union[float, int], List[Union[float, int]]]] = None):
179
- """
180
- Set the conditions for the state. The individual conditions can be a single value
181
- when solving for a single grid cell, or a list of values when solving for multiple grid cells.
182
- If air density is not provided, it will be calculated from the Ideal Gas Law using the provided
183
- temperature and pressure.
184
-
185
- Parameters
186
- ----------
187
- temperatures : Union[float, List[float]]
188
- Temperature in Kelvin.
189
- pressures : Union[float, List[float]]
190
- Pressure in Pascals.
191
- air_densities : Optional[Union[float, List[float]]]
192
- Air density in mol m-3. If not provided, it will be calculated from the Ideal Gas Law.
193
- """
194
- if isinstance(temperatures, float) or isinstance(temperatures, int):
195
- if self.__number_of_grid_cells > 1:
196
- raise ValueError(f"temperatures must be a list of length {self.__number_of_grid_cells}.")
197
- temperatures = [temperatures]
198
- if isinstance(pressures, float) or isinstance(pressures, int):
199
- if self.__number_of_grid_cells > 1:
200
- raise ValueError(f"pressures must be a list of length {self.__number_of_grid_cells}.")
201
- pressures = [pressures]
202
- if air_densities is not None and (isinstance(air_densities, float) or isinstance(air_densities, int)):
203
- if self.__number_of_grid_cells > 1:
204
- raise ValueError(f"air_densities must be a list of length {self.__number_of_grid_cells}.")
205
- air_densities = [air_densities]
206
- if len(temperatures) != self.__number_of_grid_cells:
207
- raise ValueError(f"temperatures must be a list of length {self.__number_of_grid_cells}.")
208
- if len(pressures) != self.__number_of_grid_cells:
209
- raise ValueError(f"pressures must be a list of length {self.__number_of_grid_cells}.")
210
- if air_densities is not None and len(air_densities) != self.__number_of_grid_cells:
211
- raise ValueError(f"air_densities must be a list of length {self.__number_of_grid_cells}.")
212
- k = 0
213
- for state in self.__states:
214
- for condition in state.conditions:
215
- condition.temperature = temperatures[k]
216
- condition.pressure = pressures[k]
217
- condition.air_density = air_densities[k] if air_densities is not None else pressures[k] / (
218
- GAS_CONSTANT * temperatures[k])
219
- k += 1
220
-
221
- def get_concentrations(self) -> Dict[str, List[float]]:
222
- """
223
- Get the concentrations of the species in the state.
224
-
225
- Returns
226
- -------
227
- Dict[str, List[float]]
228
- Dictionary of species names and their concentrations.
229
- """
230
- concentrations = {}
231
- for species, i_species in self.__species_ordering.items():
232
- concentrations[species] = []
233
- for state in self.__states:
234
- cell_stride, species_stride = state.concentration_strides()
235
- for i_cell in range(state.number_of_grid_cells()):
236
- concentrations[species].append(
237
- state.concentrations[i_species * species_stride + i_cell * cell_stride])
238
- return concentrations
239
-
240
- def get_user_defined_rate_parameters(self) -> Dict[str, List[float]]:
241
- """
242
- Get the user-defined rate parameters in the state.
243
-
244
- Returns
245
- -------
246
- Dict[str, List[float]]
247
- Dictionary of user-defined rate parameter names and their values.
248
- """
249
- user_defined_rate_parameters = {}
250
- for param, i_param in self.__user_defined_rate_parameters_ordering.items():
251
- user_defined_rate_parameters[param] = []
252
- for state in self.__states:
253
- cell_stride, param_stride = state.user_defined_rate_parameter_strides()
254
- for i_cell in range(state.number_of_grid_cells()):
255
- user_defined_rate_parameters[param].append(
256
- state.user_defined_rate_parameters[i_param * param_stride + i_cell * cell_stride])
257
- return user_defined_rate_parameters
258
-
259
- def get_conditions(self) -> Dict[str, List[float]]:
260
- """
261
- Get the conditions for the state.
262
-
263
- Returns
264
- -------
265
- Dict[str, List[float]]
266
- Dictionary of conditions names and their values.
267
- """
268
- conditions = {}
269
- conditions["temperature"] = []
270
- conditions["pressure"] = []
271
- conditions["air_density"] = []
272
- for state in self.__states:
273
- for i_cell in range(state.number_of_grid_cells()):
274
- conditions["temperature"].append(state.conditions[i_cell].temperature)
275
- conditions["pressure"].append(state.conditions[i_cell].pressure)
276
- conditions["air_density"].append(state.conditions[i_cell].air_density)
277
- return conditions
278
-
279
-
280
- class MICM():
281
- """
282
- The MICM class is a wrapper around the C++ MICM solver. It provides methods to create a solver,
283
- create a state, and solve the system of equations.
284
-
285
- Parameters
286
- ----------
287
- config_path : FilePath
288
- Path to the configuration file.
289
- mechanism : mechanism_configuration.Mechanism
290
- Mechanism object which specifies the chemical mechanism to use.
291
- solver_type : SolverType
292
- Type of solver to use.
293
- number_of_grid_cells : int
294
- Number of grid cells to use. The default is 1.
295
- """
296
-
297
- def __init__(
298
- self,
299
- config_path: FilePath = None,
300
- mechanism: mc.Mechanism = None,
301
- solver_type: _SolverType = None,
302
- ):
303
- self.__solver_type = solver_type
304
- self.__vector_size = _vector_size(solver_type)
305
- if config_path is None and mechanism is None:
306
- raise ValueError("Either config_path or mechanism must be provided.")
307
- if config_path is not None and mechanism is not None:
308
- raise ValueError("Only one of config_path or mechanism must be provided.")
309
- if config_path is not None:
310
- self.__solver = _create_solver(config_path, solver_type)
311
- elif mechanism is not None:
312
- self.__solver = _create_solver_from_mechanism(mechanism, solver_type)
313
-
314
- def solver_type(self) -> SolverType:
315
- """
316
- Get the type of solver used.
317
-
318
- Returns
319
- -------
320
- SolverType
321
- The type of solver used.
322
- """
323
- return self.__solver_type
324
-
325
- def create_state(self, number_of_grid_cells: int = 1) -> State:
326
- """
327
- Create a new state object.
328
-
329
- Returns
330
- -------
331
- State
332
- A new state object.
333
- """
334
- return State(self.__solver, number_of_grid_cells, self.__vector_size)
335
-
336
- def solve(
337
- self,
338
- state: State,
339
- time_step: float,
340
- ):
341
- """
342
- Solve the system of equations for the given state and time step.
343
-
344
- Parameters
345
- ----------
346
- state : State
347
- State object containing the initial conditions.
348
- time_step : float
349
- Time step in seconds.
350
-
351
- Returns
352
- -------
353
- State
354
- Updated state object after solving the system of equations.
355
- """
356
- if not isinstance(state, State):
357
- raise TypeError("state must be an instance of State.")
358
- if not isinstance(time_step, (int, float)):
359
- raise TypeError("time_step must be an int or float.")
360
- states = state.get_internal_states()
361
- for _, _state in enumerate(states):
362
- _micm_solve(self.__solver, _state, time_step)
@@ -1,30 +0,0 @@
1
- _musica.cp312-win_amd64.pyd,sha256=OPpnY6Nm9doCljoEzLkIky5BoTmP36QWidFxKQvqIa4,1531904
2
- lib/musica.lib,sha256=btfX7dN39dlkLEQ9cXbtx-pH7Hh8pBm1cudEMrdXUNI,5507286
3
- lib/yaml-cpp.lib,sha256=lT-GEY3q3MQqRyd9IDHtZwKefm2GuwtmHkzQmBqdiD8,2764186
4
- musica/__init__.py,sha256=ZtW55jXUkE_2GFco1Q1GyGrpyNoVej6gfbpEWHzfpM0,85
5
- musica/_version.py,sha256=UKJdIRQbpP27qmDKiN3zXQk32a8c-cH4Lf8v0oFMPi4,22
6
- musica/binding.cpp,sha256=rpc7Fn_GmR2Femli_gEvtgtiprRnForekUlMDoBo7PQ,674
7
- musica/CMakeLists.txt,sha256=j5m-7lf8E1YwpiEeUml5GL27hS4sfpgn2h2LzoQDiO8,1174
8
- musica/mechanism_configuration.cpp,sha256=JXGAO3j1EEKYdswjrtX8J3KcI_YlfS9WGRmlMxctaDw,27619
9
- musica/mechanism_configuration.py,sha256=_0kS0fvGS-CbQ_YfJOeSM416u7WLPwq7GzDcPgGGBWA,59302
10
- musica/musica.cpp,sha256=z4nucF98Nd-V6U_OLp_5RsW4WGE8qMn3GWLvCuY_nJE,8612
11
- musica/test/examples/v0/config.json,sha256=JDQdrDNRmRXGYlytX1uiSDV1lkYIAneLwlodHKFw-os,85
12
- musica/test/examples/v0/config.yaml,sha256=r31QbiFE2YDudGxLGpTKnpyveTnlfXeLgJ2qSrQddDY,47
13
- musica/test/examples/v0/reactions.json,sha256=SmRUE5XOAv0h3HOWg4Fb1swBiZvZ-1hsIrmMCJqEVIk,4380
14
- musica/test/examples/v0/reactions.yaml,sha256=5QeEkhjeAL_rXxNYCLOuqDUudTmgwLW3NERDupKpj6s,2408
15
- musica/test/examples/v0/species.json,sha256=klFuYb2vAtWdHfHJVYuIuPe_6LHRTuB0Aw29YhwfCFc,604
16
- musica/test/examples/v0/species.yaml,sha256=ECT9DDa2GMwhSRaRLxjOiCATTKkTRTPwugRsUjHSytY,302
17
- musica/test/examples/v1/full_configuration.json,sha256=1-kr2bZJvfuENfy6FMfc5ZEOtgs_NhzHYeGrEGLqLMw,9240
18
- musica/test/examples/v1/full_configuration.yaml,sha256=9NSd8BUJnJ6CPjX9ZngqbFDEqUf1qG5ixbnQDO2m79k,5505
19
- musica/test/test_analytical.py,sha256=lY5XuEMEg7IEfTvEIeSRhShMNdX39q00H8RjqGnZB30,14098
20
- musica/test/test_chapman.py,sha256=_OHLNBWT5qcU8s3mQAisV16qOdyRq7gdaU4nFZtxTnY,3193
21
- musica/test/test_parser.py,sha256=s8b55MntiDmUeW3GP_-JHucEhxi5RMSzPWQULM73rpg,24985
22
- musica/test/tuvx.py,sha256=L8X7rJ09HiRlrhLK6fjircI8tGHnFCZJzVow8He5YOE,126
23
- musica/tools/prepare_build_environment_linux.sh,sha256=Xrd95nPnznqTAc24TVeehXP-7uMkJE1FysKKZsPYgPs,1507
24
- musica/tools/prepare_build_environment_windows.sh,sha256=sBBWhJQaS2zWDVFLIDMNBMOMPw8auXwnwz7nhuB5Q_k,847
25
- musica/tools/repair_wheel_gpu.sh,sha256=bXFSgNjCE4D8NvLGfNkIDyt2Qsx6AlT1VfHEBlrRTz4,942
26
- musica/types.py,sha256=GA04nbo-m7Jg_TQMvFMdMC35kzSDynUHvt7alBnM8FI,15257
27
- musica-0.11.1.1.dist-info/METADATA,sha256=URpXjU5lo-wyROln6GI9YbAqGFDPH0gq8O30EzTW5uc,20814
28
- musica-0.11.1.1.dist-info/WHEEL,sha256=FmzxB5JvGlblMZ3nyeR4sHqjN8xvrDOf24fzxfEP0HA,106
29
- musica-0.11.1.1.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
30
- musica-0.11.1.1.dist-info/RECORD,,