PyPartMC 1.3.13__cp310-cp310-win_amd64.whl → 2.0.0rc3__cp310-cp310-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.

Potentially problematic release.


This version of PyPartMC might be problematic. Click here for more details.

PyPartMC/__init__.py CHANGED
@@ -1,13 +1,18 @@
1
1
  """
2
- .. include::../README.md
2
+ .. include::../../README.md
3
3
  """
4
4
 
5
+ # pylint: disable=invalid-name
6
+ import importlib.metadata
7
+
5
8
  # pylint: disable=invalid-name,wrong-import-position
6
9
  import os
7
10
  from collections import namedtuple
8
11
  from contextlib import contextmanager
9
12
  from pathlib import Path
10
13
 
14
+ import nanobind
15
+
11
16
 
12
17
  # https://github.com/diegoferigo/cmake-build-extension/blob/master/src/cmake_build_extension/__init__.py
13
18
  @contextmanager
@@ -69,10 +74,13 @@ si = __generate_si()
69
74
  SI-prefix-aware unit multipliers, resulting in e.g.: `p = 1000 * si.hPa`
70
75
  notation. Note: no dimensional analysis is done! """
71
76
 
72
- with __build_extension_env():
73
- import _PyPartMC
74
- from _PyPartMC import *
75
- from _PyPartMC import __all__ as _PyPartMC_all # pylint: disable=no-name-in-module
76
- from _PyPartMC import __version__, __versions_of_build_time_dependencies__
77
+ from ._PyPartMC import * # pylint: disable=import-error
78
+ from ._PyPartMC import ( # pylint: disable=import-error
79
+ __versions_of_build_time_dependencies__,
80
+ )
81
+
82
+ __version__ = importlib.metadata.version(__package__)
77
83
 
78
- __all__ = tuple([*_PyPartMC_all, "si"])
84
+ # walkaround for MATLAB bindings
85
+ # pylint: disable=undefined-variable
86
+ setattr(nanobind, "nb_type_0", type(_PyPartMC.AeroData))
@@ -1,329 +1,388 @@
1
- Metadata-Version: 2.2
2
- Name: PyPartMC
3
- Version: 1.3.13
4
- Summary: Python interface to PartMC
5
- Author: PyPartMC team (see https://github.com/open-atmos/PyPartMC/graphs/contributors)
6
- Author-email: nriemer@illinois.edu
7
- License: GPL-3.0
8
- Project-URL: Tracker, https://github.com/open-atmos/PyPartMC/issues
9
- Project-URL: Documentation, https://open-atmos.github.io/PyPartMC
10
- Project-URL: Source, https://github.com/open-atmos/PyPartMC/
11
- Requires-Python: >=3.7
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: numpy
15
- Provides-Extra: tests
16
- Requires-Dist: pytest; extra == "tests"
17
- Requires-Dist: pytest-order; extra == "tests"
18
- Requires-Dist: fastcore!=1.5.8; extra == "tests"
19
- Requires-Dist: ghapi; extra == "tests"
20
- Requires-Dist: scipy; extra == "tests"
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: description
24
- Dynamic: description-content-type
25
- Dynamic: license
26
- Dynamic: project-url
27
- Dynamic: provides-extra
28
- Dynamic: requires-dist
29
- Dynamic: requires-python
30
- Dynamic: summary
31
-
32
- ![logo](https://raw.githubusercontent.com/wiki/open-atmos/PyPartMC/logo.svg)
33
-
34
- # PyPartMC
35
-
36
- PyPartMC is a Python interface to [PartMC](https://lagrange.mechse.illinois.edu/partmc/),
37
- a particle-resolved Monte-Carlo code for atmospheric aerosol simulation.
38
- Development of PyPartMC has been intended to remove limitations to the use of Fortran-implemented PartMC.
39
- PyPartMC facilitates the dissemination of computational research results by streamlining independent execution
40
- of PartMC simulations (also during peer-review processes).
41
- Additionally, the ability to easily package examples, simple simulations, and results in a web-based notebook
42
- allows PyPartMC to support the efforts of many members of the scientific community, including researchers,
43
- instructors, and students, with nominal software and hardware requirements.
44
-
45
- PyPartMC is implemented in C++ and it also constitutes a C++ API to the PartMC Fortran internals.
46
- The Python API can facilitate using PartMC from other environments - see, e.g., Julia and Matlab examples below.
47
-
48
- For an outline of the project, rationale, architecture, and features, refer to: [D'Aquino et al., 2024 (SoftwareX)](https://doi.org/10.1016/j.softx.2023.101613) (please cite if PyPartMC is used in your research).
49
- For a list of talks and other relevant resources, please see [project Wiki](https://github.com/open-atmos/PyPartMC/wiki/).
50
- If interested in contributing to PyPartMC, please have a look a the [notes for developers](https://github.com/open-atmos/PyPartMC/tree/main/CONTRIBUTING.md).
51
-
52
- [![US Funding](https://img.shields.io/static/v1?label=US%20DOE%20Funding%20by&color=267c32&message=ASR&logoWidth=25&logo=image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAMAAAA25D/gAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAASFBMVEVOTXyyIjRDQnNZWINZWITtzdFUU4BVVIFVVYHWiZM9PG/KZnNXVoJaWYT67/FKSXhgX4hgX4lcW4VbWoX03uHQeIN2VXj///9pZChlAAAAAWJLR0QXC9aYjwAAAAd0SU1FB+EICRMGJV+KCCQAAABdSURBVBjThdBJDoAgEETRkkkZBBX0/kd11QTTpH1/STqpAAwWBkobSlkGbt0o5xmEfqxDZJB2Q6XMoBwnVSbTylWp0hi42rmbwTOYPDfR5Kc+07IIUQQvghX9THsBHcES8/SiF0kAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDgtMDlUMTk6MDY6MzcrMDA6MDCX1tBgAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA4LTA5VDE5OjA2OjM3KzAwOjAw5oto3AAAAABJRU5ErkJggg==)](https://asr.science.energy.gov/) [![PL Funding](https://img.shields.io/static/v1?label=PL%20Funding%20by&color=d21132&message=NCN&logoWidth=25&logo=image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAABmJLR0QA/wD/AP+gvaeTAAAAKUlEQVQ4jWP8////fwYqAiZqGjZqIHUAy4dJS6lqIOMdEZvRZDPcDQQAb3cIaY1Sbi4AAAAASUVORK5CYII=)](https://www.ncn.gov.pl/?language=en)
53
-
54
- [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
55
- [![Copyright](https://img.shields.io/static/v1?label=Copyright&color=249fe2&message=UIUC&)](https://atmos.illinois.edu/)
56
- [![Github Actions Build Status](https://github.com/open-atmos/PyPartMC/workflows/tests+pypi/badge.svg?branch=main)](https://github.com/open-atmos/PyPartMC/actions)
57
- [![API docs](https://shields.mitmproxy.org/badge/docs-pdoc.dev-brightgreen.svg)](https://open-atmos.github.io/PyPartMC/)
58
- [![codecov](https://codecov.io/gh/open-atmos/PyPartMC/graph/badge.svg?token=27IK9ZIQXE)](https://codecov.io/gh/open-atmos/PyPartMC)
59
- [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7662635.svg)](https://doi.org/10.5281/zenodo.7662635)
60
- [![PyPI version](https://badge.fury.io/py/PyPartMC.svg)](https://pypi.org/p/PyPartMC)
61
- [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
62
-
63
- ## TL;DR (try in a Jupyter notebook)
64
-
65
- [![Python 3](https://img.shields.io/static/v1?label=Python&logo=Python&color=3776AB&message=3)](https://www.python.org/)
66
- [![Linux OK](https://img.shields.io/static/v1?label=Linux&logo=Linux&color=yellow&message=%E2%9C%93)](https://en.wikipedia.org/wiki/Linux)
67
- [![macOS OK](https://img.shields.io/static/v1?label=macOS&logo=Apple&color=silver&message=%E2%9C%93)](https://en.wikipedia.org/wiki/macOS)
68
- [![Windows OK](https://img.shields.io/static/v1?label=Windows&logo=Windows&color=white&message=%E2%9C%93)](https://en.wikipedia.org/wiki/Windows)
69
- [![Jupyter](https://img.shields.io/static/v1?label=Jupyter&logo=Jupyter&color=f37626&message=%E2%9C%93)](https://jupyter.org/)
70
-
71
- ```python
72
- ! pip install PyPartMC
73
- import PyPartMC
74
- ```
75
-
76
- Note that, depending on the environment (OS, hardware, Python version), the pip-install invocation
77
- may either trigger a download of a pre-compiled binary, or trigger compilation of PyPartMC.
78
- In the latter case, a Fortran compiler and some development tools includiong CMake, m4 and perl
79
- are required (while all non-Python dependencies are included in the PyPartMC source archive).
80
- In both cases, all Python dependencies will be resolved by pip.
81
-
82
- #### Jupyter notebooks with examples
83
- Note: clicking the badges below redirects to cloud-computing platforms. The mybinder.org links allow anonymous execution, Google Colab requires logging in with a Google account, ARM JupyerHub requires logging in with an ARM account (and directing Jupyter to a particular notebook within the `examples` folder).
84
-
85
- - Urban plume scenario demo (as in [PartMC](https://github.com/compdyn/partmc/tree/master/scenarios/1_urban_plume)):
86
- [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/particle_simulation.ipynb)
87
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/particle_simulation.ipynb)
88
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/particle_simulation.ipynb)
89
- [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
90
- - Dry-Wet Particle Size Equilibration with PartMC and PySDM:
91
- [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/lognorm_ex.ipynb)
92
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/lognorm_ex.ipynb)
93
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/lognorm_ex.ipynb)
94
- [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
95
- [![Voila](https://img.shields.io/static/v1?label=Voil%C3%A0&logo=jupyter&color=teal&message=web+app)](https://mybinder.org/v2/gh/open-atmos/PyPartMC/main?urlpath=voila%2Frender%2Fexamples%2Flognorm_ex.ipynb)
96
- - Simulation output processing example (loading from netCDF files using PyPartMC):
97
- [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/process_simulation_output.ipynb)
98
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/process_simulation_output.ipynb)
99
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/process_simulation_output.ipynb)
100
- [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
101
- - Optical properties calculation using external Python package ([PyMieScatt](https://pymiescatt.readthedocs.io/en/latest/)):
102
- [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/mie_optical.ipynb)
103
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/mie_optical.ipynb)
104
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/mie_optical.ipynb)
105
- [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
106
- - Cloud parcel example featuring supersaturation-evolution-coupled CCN activation and drop growth:
107
- [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/cloud_parcel.ipynb)
108
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/cloud_parcel.ipynb)
109
- [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/cloud_parcel.ipynb)
110
- [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
111
-
112
- ## Features
113
-
114
- - works on Linux, macOS and Windows (compatibility assured with [CI builds](https://github.com/open-atmos/PyPartMC/blob/main/.github/workflows/tests.yml))
115
- - hassle-free installation using `pip` (prior PartMC installation **not needed**)
116
- - works out of the box on [mybinder.org](https://mybinder.org/), [Google Colab](colab.research.google.com/) and alike
117
- - ships with [a set of examples](https://github.com/open-atmos/PyPartMC/tree/main/examples) maintained in a form of Jupyter notebooks
118
- - Pythonic API (but retaining PartMC jargon) incl. Python GC deallocation of Fortran objects
119
- - specification of parameters using native Python datatypes (lists, dicts) in place of PartMC spec files
120
- - code snippets in README depicting how to use PyPartMC from Julia and Matlab (also executed on CI)
121
- - auto-generated [API docs on the web](https://open-atmos.github.io/PyPartMC/)
122
- - support for [de]serialization of selected wrapped structures using JSON
123
- - based on [unmodified PartMC code](https://github.com/open-atmos/PyPartMC/tree/main/gitmodules)
124
- - does not use or require shell or any pre-installed libraries
125
- - aiming at 100% [unit test coverage](https://github.com/open-atmos/PyPartMC/tree/main/tests)
126
-
127
- ## Usage examples
128
-
129
- The listings below depict how the identical task of randomly sampling particles from an aerosol size distribution in PartMC can be
130
- done in different programming languages.
131
-
132
- For a Fortran equivalent of the Python, Julia and Matlab programs below, see the [`readme_fortran` folder](https://github.com/open-atmos/PyPartMC/tree/main/readme_fortran).
133
-
134
- #### Python
135
-
136
- ```Python
137
- import numpy as np
138
-
139
- import PyPartMC as ppmc
140
- from PyPartMC import si
141
-
142
- aero_data = ppmc.AeroData((
143
- # [density, ions in solution, molecular weight, kappa]
144
- {"OC": [1000 *si.kg/si.m**3, 0, 1e-3 *si.kg/si.mol, 0.001]},
145
- {"BC": [1800 *si.kg/si.m**3, 0, 1e-3 *si.kg/si.mol, 0]},
146
- ))
147
-
148
- aero_dist = ppmc.AeroDist(
149
- aero_data,
150
- [{
151
- "cooking": {
152
- "mass_frac": [{"OC": [1]}],
153
- "diam_type": "geometric",
154
- "mode_type": "log_normal",
155
- "num_conc": 3200 / si.cm**3,
156
- "geom_mean_diam": 8.64 * si.nm,
157
- "log10_geom_std_dev": 0.28,
158
- }
159
- },
160
- {
161
- "diesel": {
162
- "mass_frac": [{"OC": [0.3]}, {"BC": [0.7]}],
163
- "diam_type": "geometric",
164
- "mode_type": "log_normal",
165
- "num_conc": 2900 / si.cm**3,
166
- "geom_mean_diam": 50 * si.nm,
167
- "log10_geom_std_dev": 0.24,
168
- }
169
- }],
170
- )
171
-
172
- n_part = 100
173
- aero_state = ppmc.AeroState(aero_data, n_part, "nummass_source")
174
- aero_state.dist_sample(aero_dist)
175
- print(np.dot(aero_state.masses(), aero_state.num_concs), "# kg/m3")
176
- ```
177
-
178
- #### Julia (using [PyCall.jl](https://github.com/JuliaPy/PyCall.jl))
179
- ```Julia
180
- using Pkg
181
- Pkg.add("PyCall")
182
-
183
- using PyCall
184
- ppmc = pyimport("PyPartMC")
185
- si = ppmc["si"]
186
-
187
- aero_data = ppmc.AeroData((
188
- # (density, ions in solution, molecular weight, kappa)
189
- Dict("OC"=>(1000 * si.kg/si.m^3, 0, 1e-3 * si.kg/si.mol, 0.001)),
190
- Dict("BC"=>(1800 * si.kg/si.m^3, 0, 1e-3 * si.kg/si.mol, 0))
191
- ))
192
-
193
- aero_dist = ppmc.AeroDist(aero_data, (
194
- Dict(
195
- "cooking" => Dict(
196
- "mass_frac" => (Dict("OC" => (1,)),),
197
- "diam_type" => "geometric",
198
- "mode_type" => "log_normal",
199
- "num_conc" => 3200 / si.cm^3,
200
- "geom_mean_diam" => 8.64 * si.nm,
201
- "log10_geom_std_dev" => .28,
202
- )
203
- ),
204
- Dict(
205
- "diesel" => Dict(
206
- "mass_frac" => (Dict("OC" => (.3,)), Dict("BC" => (.7,))),
207
- "diam_type" => "geometric",
208
- "mode_type" => "log_normal",
209
- "num_conc" => 2900 / si.cm^3,
210
- "geom_mean_diam" => 50 * si.nm,
211
- "log10_geom_std_dev" => .24,
212
- )
213
- )
214
- ))
215
-
216
- n_part = 100
217
- aero_state = ppmc.AeroState(aero_data, n_part, "nummass_source")
218
- aero_state.dist_sample(aero_dist)
219
- print(aero_state.masses()'aero_state.num_concs, "# kg/m3")
220
- ```
221
-
222
- #### Matlab (using [Matlab's built-in Python interface](https://www.mathworks.com/help/matlab/python-language.html))
223
-
224
- notes (see the [PyPartMC Matlab CI workflow](https://github.com/open-atmos/PyPartMC/blob/main/.github/workflows/readme_listings.yml) for an example on how to achieve it on Ubuntu 20):
225
- - Matlab ships with convenience copies of C, C++ and Fortran runtime libraries which are `dlopened()` by default; one way to make PyPartMC OK with it is to [pip-]install by compiling from source using the very same version of GCC that Matlab borrowed these libraries from (e.g., [GCC 9 for Matlab R2022a, etc](https://www.mathworks.com/support/requirements/supported-compilers-linux.html));
226
- - Matlab needs to [use the same Python interpretter/venv](https://www.mathworks.com/support/requirements/python-compatibility.html) as the pip invocation used to install PyPartMC;
227
- - a single-line `pybind11_builtins.py` file with just `pybind11_type=type` inside needs to be placed within Matlab's `PYTHONPATH` to sort out a [Matlab-pybind11 incompatibility](https://github.com/pybind/pybind11/issues/3945).
228
-
229
- ````Matlab
230
- ppmc = py.importlib.import_module('PyPartMC');
231
- si = py.importlib.import_module('PyPartMC').si;
232
-
233
- aero_data = ppmc.AeroData(py.tuple({ ...
234
- py.dict(pyargs("OC", py.tuple({1000 * si.kg/si.m^3, 0, 1e-3 * si.kg/si.mol, 0.001}))), ...
235
- py.dict(pyargs("BC", py.tuple({1800 * si.kg/si.m^3, 0, 1e-3 * si.kg/si.mol, 0}))) ...
236
- }));
237
-
238
- aero_dist = ppmc.AeroDist(aero_data, py.tuple({ ...
239
- py.dict(pyargs( ...
240
- "cooking", py.dict(pyargs( ...
241
- "mass_frac", py.tuple({py.dict(pyargs("OC", py.tuple({1})))}), ...
242
- "diam_type", "geometric", ...
243
- "mode_type", "log_normal", ...
244
- "num_conc", 3200 / si.cm^3, ...
245
- "geom_mean_diam", 8.64 * si.nm, ...
246
- "log10_geom_std_dev", .28 ...
247
- )) ...
248
- )), ...
249
- py.dict(pyargs( ...
250
- "diesel", py.dict(pyargs( ...
251
- "mass_frac", py.tuple({ ...
252
- py.dict(pyargs("OC", py.tuple({.3}))), ...
253
- py.dict(pyargs("BC", py.tuple({.7}))), ...
254
- }), ...
255
- "diam_type", "geometric", ...
256
- "mode_type", "log_normal", ...
257
- "num_conc", 2900 / si.cm^3, ...
258
- "geom_mean_diam", 50 * si.nm, ...
259
- "log10_geom_std_dev", .24 ...
260
- )) ...
261
- )) ...
262
- }));
263
-
264
- n_part = 100;
265
- aero_state = ppmc.AeroState(aero_data, n_part, "nummass_source");
266
- aero_state.dist_sample(aero_dist);
267
- masses = cell(aero_state.masses());
268
- num_concs = cell(aero_state.num_concs);
269
- fprintf('%g # kg/m3\n', dot([masses{:}], [num_concs{:}]))
270
- ````
271
-
272
- #### usage in other projects
273
-
274
- PyPartMC is used within the [test workflow of the PySDM project](https://github.com/atmos-cloud-sim-uj/PySDM/tree/main/tests/smoke_tests/box/partmc).
275
-
276
- ## FAQ
277
- - Q: How to install PyPartMC with MOSAIC enabled?
278
- A: Installation can be done using `pip`, however, `pip` needs to be instructed not to use binary packages available at pypi.org but rather to compile from source (pip will download the source from pip.org), and the path to compiled MOSAIC library needs to be provided at compile-time; the following command should convey it:
279
- ```bash
280
- MOSAIC_HOME=<<PATH_TO_MOSAIC_LIB>> pip install --force-reinstall --no-binary=PyPartMC PyPartMC
281
- ```
282
-
283
- - Q: Why `pip install PyPartMC` triggers compilation on my brand new Apple machine, while it quickly downloads and installs binary packages when executed on older Macs, Windows or Linux?
284
- A: We are providing binary wheels on PyPI for Apple-silicon (arm64) machines for selected macOS version made available by Github. In case the macOS version you are using is newer, compilation from source is triggered.
285
-
286
- - Q: Why some of the constructors expect data to be passed as **lists of single-entry dictionaries** instead of multi-element dictionaries?
287
- A: This is intentional and related with PartMC relying on the order of elements within spec-file input; while Python dictionaries preserve ordering (insertion order), JSON format does not, and we intend to make these data structures safe to be [de]serialized using JSON.
288
-
289
- - Q: How to check the version of PartMC that PyPartMC was compiled against?
290
- A: Version numbers of compile-time dependencies of PyPartMC, including PartMC, can be accessed as follows:
291
- ```Python
292
- import PyPartMC
293
- PyPartMC.__versions_of_build_time_dependencies__['PartMC']
294
- ```
295
-
296
- - Q: Why m4 and perl are required at compile time?
297
- A: PyPartMC includes parts of netCDF and HDF5 codebases which depend on m4 and perl, respectively, for generating source files before compilation.
298
-
299
- ## Troubleshooting
300
-
301
- #### Common installation issues
302
- ```
303
- error: [Errno 2] No such file or directory: 'cmake'
304
- ```
305
- Try rerunning after installing CMake, e.g., using `apt-get install cmake` (Ubuntu/Debian), `brew install cmake` (homebrew on macOS) or using [MSYS2](https://www.msys2.org/docs/cmake/) on Windows.
306
-
307
- ```
308
- No CMAKE_Fortran_COMPILER could be found.
309
- ```
310
- Try installing a Fortran compiler (e.g., `brew reinstall gcc` with Homebrew on macOS or using [MSYS2](https://packages.msys2.org/package/mingw-w64-x86_64-gcc-fortran?repo=mingw64) on Windows).
311
-
312
- ```
313
- Could not find NC_M4 using the following names: m4, m4.exe
314
- ```
315
- Try installing `m4` (e.g., using [MSYS2](https://packages.msys2.org/package/m4?repo=msys&variant=x86_64) on Windows).
316
-
317
- ## Credits
318
-
319
- #### PyPartMC:
320
-
321
- authors: [PyPartMC developers](https://github.com/open-atmos/PyPartMC/graphs/contributors)
322
- funding: [US Department of Energy Atmospheric System Research programme](https://asr.science.energy.gov/), [Polish National Science Centre](https://ncn.gov.pl/en)
323
- copyright: [University of Illinois at Urbana-Champaign](https://atmos.illinois.edu/)
324
- licence: [GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html)
325
-
326
- #### PartMC:
327
- authors: [Nicole Riemer](https://www.atmos.uiuc.edu/~nriemer/), [Matthew West](https://lagrange.mechse.illinois.edu/mwest/), [Jeff Curtis](https://publish.illinois.edu/jcurtis2/) et al.
328
- licence: [GPL v2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) or later
329
-
1
+ Metadata-Version: 2.4
2
+ Name: PyPartMC
3
+ Version: 2.0.0rc3
4
+ Summary: Python interface to PartMC
5
+ Author-Email: "https://github.com/open-atmos/PyPartMC/graphs/contributors" <nriemer@illinois.edu>
6
+ License-Expression: GPL-3.0
7
+ Project-URL: Documentation, https://open-atmos.github.io/PyPartMC
8
+ Project-URL: Source, https://github.com/open-atmos/PyPartMC/
9
+ Project-URL: Tracker, https://github.com/open-atmos/PyPartMC/issues
10
+ Requires-Python: >=3.8
11
+ Requires-Dist: numpy
12
+ Requires-Dist: nanobind
13
+ Provides-Extra: tests
14
+ Requires-Dist: pytest; extra == "tests"
15
+ Requires-Dist: pytest-order; extra == "tests"
16
+ Provides-Extra: examples
17
+ Requires-Dist: matplotlib!=3.10.0; extra == "examples"
18
+ Requires-Dist: ipywidgets; extra == "examples"
19
+ Requires-Dist: voila; extra == "examples"
20
+ Requires-Dist: open-atmos-jupyter-utils; extra == "examples"
21
+ Requires-Dist: PySDM; extra == "examples"
22
+ Requires-Dist: PyMieScatt; extra == "examples"
23
+ Requires-Dist: SciPy; extra == "examples"
24
+ Requires-Dist: dustpy; platform_system != "Windows" and extra == "examples"
25
+ Description-Content-Type: text/markdown
26
+
27
+ ![logo](https://raw.githubusercontent.com/wiki/open-atmos/PyPartMC/logo.svg)
28
+
29
+ # PyPartMC
30
+
31
+ PyPartMC is a Python interface to [PartMC](https://lagrange.mechse.illinois.edu/partmc/),
32
+ a particle-resolved Monte-Carlo code for atmospheric aerosol simulation.
33
+ Development of PyPartMC has been intended to remove limitations to the use of Fortran-implemented PartMC.
34
+ PyPartMC facilitates the dissemination of computational research results by streamlining independent execution
35
+ of PartMC simulations (also during peer-review processes).
36
+ Additionally, the ability to easily package examples, simple simulations, and results in a web-based notebook
37
+ allows PyPartMC to support the efforts of many members of the scientific community, including researchers,
38
+ instructors, and students, with nominal software and hardware requirements.
39
+
40
+ Documentation of PyPartMC is hosted at https://open-atmos.github.io/PyPartMC.
41
+ PyPartMC is implemented in C++ and it also constitutes a C++ API to the PartMC Fortran internals.
42
+ The Python API can facilitate using PartMC from other environments - see, e.g., Julia and Matlab examples below.
43
+
44
+ For an outline of the project, rationale, architecture, and features, refer to: [D'Aquino et al., 2024 (SoftwareX)](https://doi.org/10.1016/j.softx.2023.101613) (please cite if PyPartMC is used in your research).
45
+ For a list of talks and other relevant resources, please see [project Wiki](https://github.com/open-atmos/PyPartMC/wiki/).
46
+ If interested in contributing to PyPartMC, please have a look a the [notes for developers](https://github.com/open-atmos/PyPartMC/tree/main/CONTRIBUTING.md).
47
+
48
+ [![US Funding](https://img.shields.io/static/v1?label=US%20DOE%20Funding%20by&color=267c32&message=ASR&logoWidth=25&logo=image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAMAAAA25D/gAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAASFBMVEVOTXyyIjRDQnNZWINZWITtzdFUU4BVVIFVVYHWiZM9PG/KZnNXVoJaWYT67/FKSXhgX4hgX4lcW4VbWoX03uHQeIN2VXj///9pZChlAAAAAWJLR0QXC9aYjwAAAAd0SU1FB+EICRMGJV+KCCQAAABdSURBVBjThdBJDoAgEETRkkkZBBX0/kd11QTTpH1/STqpAAwWBkobSlkGbt0o5xmEfqxDZJB2Q6XMoBwnVSbTylWp0hi42rmbwTOYPDfR5Kc+07IIUQQvghX9THsBHcES8/SiF0kAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDgtMDlUMTk6MDY6MzcrMDA6MDCX1tBgAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA4LTA5VDE5OjA2OjM3KzAwOjAw5oto3AAAAABJRU5ErkJggg==)](https://asr.science.energy.gov/) [![PL Funding](https://img.shields.io/static/v1?label=PL%20Funding%20by&color=d21132&message=NCN&logoWidth=25&logo=image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAABmJLR0QA/wD/AP+gvaeTAAAAKUlEQVQ4jWP8////fwYqAiZqGjZqIHUAy4dJS6lqIOMdEZvRZDPcDQQAb3cIaY1Sbi4AAAAASUVORK5CYII=)](https://www.ncn.gov.pl/?language=en)
49
+
50
+ [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
51
+ [![Copyright](https://img.shields.io/static/v1?label=Copyright&color=249fe2&message=UIUC&)](https://atmos.illinois.edu/)
52
+ [![tests+pypi](https://github.com/open-atmos/PyPartMC/actions/workflows/buildwheels.yml/badge.svg)](https://github.com/open-atmos/PyPartMC/actions/workflows/buildwheels.yml)
53
+ [![API docs](https://shields.mitmproxy.org/badge/docs-pdoc.dev-brightgreen.svg)](https://open-atmos.github.io/PyPartMC/)
54
+ [![codecov](https://codecov.io/gh/open-atmos/PyPartMC/graph/badge.svg?token=27IK9ZIQXE)](https://codecov.io/gh/open-atmos/PyPartMC)
55
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7662635.svg)](https://doi.org/10.5281/zenodo.7662635)
56
+ [![PyPI version](https://badge.fury.io/py/PyPartMC.svg)](https://pypi.org/p/PyPartMC)
57
+ [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
58
+ [![pyOpenSci Peer-Reviewed](https://pyopensci.org/badges/peer-reviewed.svg)](https://github.com/pyOpenSci/software-review/issues/179)
59
+
60
+ [![Python 3](https://img.shields.io/static/v1?label=Python&logo=Python&color=3776AB&message=3)](https://www.python.org/)
61
+ [![Linux OK](https://img.shields.io/static/v1?label=Linux&logo=Linux&color=yellow&message=%E2%9C%93)](https://en.wikipedia.org/wiki/Linux)
62
+ [![macOS OK](https://img.shields.io/static/v1?label=macOS&logo=Apple&color=silver&message=%E2%9C%93)](https://en.wikipedia.org/wiki/macOS)
63
+ [![Windows OK](https://img.shields.io/static/v1?label=Windows&logo=Windows&color=white&message=%E2%9C%93)](https://en.wikipedia.org/wiki/Windows)
64
+ [![Jupyter](https://img.shields.io/static/v1?label=Jupyter&logo=Jupyter&color=f37626&message=%E2%9C%93)](https://jupyter.org/)
65
+
66
+ ## Installation
67
+
68
+ ### Using the command-line `pip` tool (also applies to conda environments)
69
+ ```bash
70
+ pip install PyPartMC
71
+ ```
72
+
73
+ Note that, depending on the environment (OS, hardware, Python version), the pip-install invocation
74
+ may either trigger a download of a pre-compiled binary, or trigger compilation of PyPartMC.
75
+ In the latter case, a Fortran compiler and some development tools includiong CMake, m4 and perl
76
+ are required (while all non-Python dependencies are included in the PyPartMC source archive).
77
+ In both cases, all Python dependencies will be resolved by pip.
78
+
79
+ ### In a Jupyter notebook cell (also on Colab or jupyter-hub instances)
80
+
81
+ ```python
82
+ ! pip install PyPartMC
83
+ import PyPartMC
84
+ ```
85
+
86
+ #### Jupyter notebooks with examples
87
+ Note: clicking the badges below redirects to cloud-computing platforms. The mybinder.org links allow anonymous execution, Google Colab requires logging in with a Google account, ARM JupyerHub requires logging in with an ARM account (and directing Jupyter to a particular notebook within the `examples` folder).
88
+
89
+ The example notebooks feature additional dependencies that can be installed with:
90
+ ```bash
91
+ pip install PyPartMC[examples]
92
+ ```
93
+
94
+ - Urban plume scenario demo (as in [PartMC](https://github.com/compdyn/partmc/tree/master/scenarios/1_urban_plume)):
95
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/particle_simulation.ipynb)
96
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/particle_simulation.ipynb)
97
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/particle_simulation.ipynb)
98
+ [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
99
+ - Dry-Wet Particle Size Equilibration with PartMC and PySDM:
100
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/lognorm_ex.ipynb)
101
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/lognorm_ex.ipynb)
102
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/lognorm_ex.ipynb)
103
+ [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
104
+ [![Voila](https://img.shields.io/static/v1?label=Voil%C3%A0&logo=jupyter&color=teal&message=web+app)](https://mybinder.org/v2/gh/open-atmos/PyPartMC/main?urlpath=voila%2Frender%2Fexamples%2Flognorm_ex.ipynb)
105
+ - Simulation output processing example (loading from netCDF files using PyPartMC):
106
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/process_simulation_output.ipynb)
107
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/process_simulation_output.ipynb)
108
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/process_simulation_output.ipynb)
109
+ [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
110
+ - Optical properties calculation using external Python package ([PyMieScatt](https://pymiescatt.readthedocs.io/en/latest/)):
111
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/mie_optical.ipynb)
112
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/mie_optical.ipynb)
113
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/mie_optical.ipynb)
114
+ [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
115
+ - Cloud parcel example featuring supersaturation-evolution-coupled CCN activation and drop growth:
116
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PyPartMC/blob/main/examples/cloud_parcel.ipynb)
117
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/cloud_parcel.ipynb)
118
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/cloud_parcel.ipynb)
119
+ [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
120
+ - Coagulation model intercomparison for additive (Golovin) kernel with: PyPartMC, [PySDM](https://open-atmos.github.io/PySDM), [Droplets.jl](https://github.com/emmacware/droplets.jl) and [dustpy](https://stammler.github.io/dustpy/):
121
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos//PyPartMC/blob/main/examples/additive_coag_comparison.ipynb)
122
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PyPartMC/blob/main/examples/additive_coag_comparison.ipynb)
123
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PyPartMC.git/main?urlpath=lab/tree/examples/additive_coag_comparison.ipynb)
124
+ [![ARM JupyterHub](https://img.shields.io/static/v1?label=launch%20in&logo=jupyter&color=lightblue&message=ARM+JupyterHub)](https://jupyterhub.arm.gov/hub/user-redirect/git-pull?repo=https%3A//github.com/open-atmos/PyPartMC&branch=main&urlPath=)
125
+
126
+ ## Features
127
+
128
+ - works on Linux, macOS and Windows (compatibility assured with [CI builds](https://github.com/open-atmos/PyPartMC/blob/main/.github/workflows/tests.yml))
129
+ - hassle-free installation using `pip` (prior PartMC installation **not needed**)
130
+ - works out of the box on [mybinder.org](https://mybinder.org/), [Google Colab](colab.research.google.com/) and alike
131
+ - ships with [a set of examples](https://github.com/open-atmos/PyPartMC/tree/main/examples) maintained in a form of Jupyter notebooks
132
+ - Pythonic API (but retaining PartMC jargon) incl. Python GC deallocation of Fortran objects
133
+ - specification of parameters using native Python datatypes (lists, dicts) in place of PartMC spec files
134
+ - code snippets in README depicting how to use PyPartMC from Julia and Matlab (also executed on CI)
135
+ - auto-generated [API docs on the web](https://open-atmos.github.io/PyPartMC/)
136
+ - support for [de]serialization of selected wrapped structures using JSON
137
+ - based on [unmodified PartMC code](https://github.com/open-atmos/PyPartMC/tree/main/gitmodules)
138
+ - does not use or require shell or any pre-installed libraries
139
+ - aiming at 100% [unit test coverage](https://github.com/open-atmos/PyPartMC/tree/main/tests)
140
+
141
+ ## Usage examples
142
+
143
+ The listings below depict how the identical task of randomly sampling particles from an aerosol size distribution in PartMC can be
144
+ done in different programming languages.
145
+
146
+ For a Fortran equivalent of the Python, Julia and Matlab programs below, see the [`readme_fortran` folder](https://github.com/open-atmos/PyPartMC/tree/main/readme_fortran).
147
+
148
+ #### Python
149
+
150
+ ```Python
151
+ import numpy as np
152
+
153
+ import PyPartMC as ppmc
154
+ from PyPartMC import si
155
+
156
+ aero_data = ppmc.AeroData((
157
+ # [density, ions in solution, molecular weight, kappa]
158
+ {"OC": [1000 *si.kg/si.m**3, 0, 1e-3 *si.kg/si.mol, 0.001]},
159
+ {"BC": [1800 *si.kg/si.m**3, 0, 1e-3 *si.kg/si.mol, 0]},
160
+ ))
161
+
162
+ aero_dist = ppmc.AeroDist(
163
+ aero_data,
164
+ [{
165
+ "cooking": {
166
+ "mass_frac": [{"OC": [1]}],
167
+ "diam_type": "geometric",
168
+ "mode_type": "log_normal",
169
+ "num_conc": 3200 / si.cm**3,
170
+ "geom_mean_diam": 8.64 * si.nm,
171
+ "log10_geom_std_dev": 0.28,
172
+ },
173
+ "diesel": {
174
+ "mass_frac": [{"OC": [0.3]}, {"BC": [0.7]}],
175
+ "diam_type": "geometric",
176
+ "mode_type": "log_normal",
177
+ "num_conc": 2900 / si.cm**3,
178
+ "geom_mean_diam": 50 * si.nm,
179
+ "log10_geom_std_dev": 0.24,
180
+ }
181
+ }],
182
+ )
183
+
184
+ n_part = 100
185
+ aero_state = ppmc.AeroState(aero_data, n_part, "nummass_source")
186
+ aero_state.dist_sample(aero_dist)
187
+ print(np.dot(aero_state.masses(), aero_state.num_concs), "# kg/m3")
188
+ ```
189
+
190
+ #### Julia (using [PyCall.jl](https://github.com/JuliaPy/PyCall.jl))
191
+ ```Julia
192
+ using Pkg
193
+ Pkg.add("PyCall")
194
+
195
+ using PyCall
196
+ ppmc = pyimport("PyPartMC")
197
+ si = ppmc["si"]
198
+
199
+ aero_data = ppmc.AeroData((
200
+ # (density, ions in solution, molecular weight, kappa)
201
+ Dict("OC"=>(1000 * si.kg/si.m^3, 0, 1e-3 * si.kg/si.mol, 0.001)),
202
+ Dict("BC"=>(1800 * si.kg/si.m^3, 0, 1e-3 * si.kg/si.mol, 0))
203
+ ))
204
+
205
+ aero_dist = ppmc.AeroDist(aero_data, (
206
+ Dict(
207
+ "cooking" => Dict(
208
+ "mass_frac" => (Dict("OC" => (1,)),),
209
+ "diam_type" => "geometric",
210
+ "mode_type" => "log_normal",
211
+ "num_conc" => 3200 / si.cm^3,
212
+ "geom_mean_diam" => 8.64 * si.nm,
213
+ "log10_geom_std_dev" => .28,
214
+ ),
215
+ "diesel" => Dict(
216
+ "mass_frac" => (Dict("OC" => (.3,)), Dict("BC" => (.7,))),
217
+ "diam_type" => "geometric",
218
+ "mode_type" => "log_normal",
219
+ "num_conc" => 2900 / si.cm^3,
220
+ "geom_mean_diam" => 50 * si.nm,
221
+ "log10_geom_std_dev" => .24,
222
+ )
223
+ ),
224
+ ))
225
+
226
+ n_part = 100
227
+ aero_state = ppmc.AeroState(aero_data, n_part, "nummass_source")
228
+ aero_state.dist_sample(aero_dist)
229
+ print(aero_state.masses()'aero_state.num_concs, "# kg/m3")
230
+ ```
231
+
232
+ #### Matlab (using [Matlab's built-in Python interface](https://www.mathworks.com/help/matlab/python-language.html))
233
+
234
+ notes (see the [PyPartMC Matlab CI workflow](https://github.com/open-atmos/PyPartMC/blob/main/.github/workflows/readme_listings.yml) for an example on how to achieve it on Ubuntu 20):
235
+ - Matlab ships with convenience copies of C, C++ and Fortran runtime libraries which are `dlopened()` by default; one way to make PyPartMC OK with it is to [pip-]install by compiling from source using the very same version of GCC that Matlab borrowed these libraries from (e.g., [GCC 9 for Matlab R2022a, etc](https://www.mathworks.com/support/requirements/supported-compilers-linux.html));
236
+ - Matlab needs to [use the same Python interpretter/venv](https://www.mathworks.com/support/requirements/python-compatibility.html) as the pip invocation used to install PyPartMC;
237
+
238
+ ````Matlab
239
+ ppmc = py.importlib.import_module('PyPartMC');
240
+ si = py.importlib.import_module('PyPartMC').si;
241
+
242
+ aero_data = ppmc.AeroData(py.tuple({ ...
243
+ py.dict(pyargs("OC", py.tuple({1000 * si.kg/si.m^3, 0, 1e-3 * si.kg/si.mol, 0.001}))), ...
244
+ py.dict(pyargs("BC", py.tuple({1800 * si.kg/si.m^3, 0, 1e-3 * si.kg/si.mol, 0}))) ...
245
+ }));
246
+
247
+ aero_dist = ppmc.AeroDist(aero_data, py.tuple({ ...
248
+ py.dict(pyargs( ...
249
+ "cooking", py.dict(pyargs( ...
250
+ "mass_frac", py.tuple({py.dict(pyargs("OC", py.tuple({1})))}), ...
251
+ "diam_type", "geometric", ...
252
+ "mode_type", "log_normal", ...
253
+ "num_conc", 3200 / si.cm^3, ...
254
+ "geom_mean_diam", 8.64 * si.nm, ...
255
+ "log10_geom_std_dev", .28 ...
256
+ )), ...
257
+ "diesel", py.dict(pyargs( ...
258
+ "mass_frac", py.tuple({ ...
259
+ py.dict(pyargs("OC", py.tuple({.3}))), ...
260
+ py.dict(pyargs("BC", py.tuple({.7}))), ...
261
+ }), ...
262
+ "diam_type", "geometric", ...
263
+ "mode_type", "log_normal", ...
264
+ "num_conc", 2900 / si.cm^3, ...
265
+ "geom_mean_diam", 50 * si.nm, ...
266
+ "log10_geom_std_dev", .24 ...
267
+ )) ...
268
+ )) ...
269
+ }));
270
+
271
+ n_part = 100;
272
+ aero_state = ppmc.AeroState(aero_data, n_part, "nummass_source");
273
+ aero_state.dist_sample(aero_dist);
274
+ masses = cell(aero_state.masses());
275
+ num_concs = cell(aero_state.num_concs);
276
+ fprintf('%g # kg/m3\n', dot([masses{:}], [num_concs{:}]))
277
+ ````
278
+
279
+ #### usage in other projects
280
+
281
+ PyPartMC is used within the [test workflow of the PySDM project](https://github.com/atmos-cloud-sim-uj/PySDM/tree/main/tests/smoke_tests/box/partmc).
282
+
283
+ ## Other packages with relevant feature scope
284
+
285
+ - [aerosolGDEFoam](https://openaerosol.sourceforge.io/): OpenFOAM CFD-coupled aerosol dynamics including nucleation, coagulation, and surface growth
286
+ - [AIOMFAC and AIOMFAC-web](http://www.aiomfac.caltech.edu/): Fortran-implemented aerosol thermodynamic model for calculation of activity coefficients in organic-inorganic mixtures from simple binary solutions to complex multicomponent systems
287
+ - [DustPy](https://stammler.github.io/dustpy/): Python package for modelling dust evolution in protoplanetary disks (differences: focus on astrophysical applications vs. atmospheric aerosol)
288
+ - [multilayerpy](https://github.com/tintin554/multilayerpy): kinetic multi-layer model for aerosol particles and films
289
+ - [PyBox](https://pybox.readthedocs.io): aerosol simulation model featuring gas and particle chamistry (differences: PyBox focuses on chemical mechanisms; PyPartMC is an interface to PartMC which focuses on physics - e.g., collisions of aerosol particles - while chemical processes are handled with external software, e.g., CAMP or MOSAIC)
290
+ - [PyCHAM](https://github.com/simonom/PyCHAM): CHemistry with Aerosol Microphysics in Python Box Model for modelling of indoor environments, including aerosol chambers
291
+ - [PySDM](https://open-atmos.github.io/PySDM): particle-based Monte-Carlo aerosol-cloud simulation package (differences: PySDM focuses on growth and breakup processes relevant to cloud droplets; PyPartMC focuses on processes relevant to air pollutants and their chemical and physical transformations)
292
+ - [SSH-aerosol](https://github.com/sshaerosol/ssh-aerosol): C++/Fortran package for simulating evolution of primary and secondary atmospheric aerosols
293
+
294
+ ## FAQ
295
+ - Q: How to install PyPartMC with MOSAIC enabled?
296
+ A: Installation can be done using `pip`, however, `pip` needs to be instructed not to use binary packages available at pypi.org but rather to compile from source (pip will download the source from pip.org), and the path to compiled MOSAIC library needs to be provided at compile-time; the following command should convey it:
297
+ ```bash
298
+ MOSAIC_HOME=<<PATH_TO_MOSAIC_LIB>> pip install --force-reinstall --no-binary=PyPartMC PyPartMC
299
+ ```
300
+
301
+ - Q: Why `pip install PyPartMC` triggers compilation on my brand new Apple machine, while it quickly downloads and installs binary packages when executed on older Macs, Windows or Linux?
302
+ A: We are providing binary wheels on PyPI for Apple-silicon (arm64) machines for selected macOS version made available by Github. In case the macOS version you are using is newer, compilation from source is triggered.
303
+
304
+ - Q: Why some of the constructors expect data to be passed as **lists of single-entry dictionaries** instead of multi-element dictionaries?
305
+ A: This is intentional and related with PartMC relying on the order of elements within spec-file input; while Python dictionaries preserve ordering (insertion order), JSON format does not, and we intend to make these data structures safe to be [de]serialized using JSON.
306
+
307
+ - Q: How to check the version of PartMC that PyPartMC was compiled against?
308
+ A: Version numbers of compile-time dependencies of PyPartMC, including PartMC, can be accessed as follows:
309
+ ```Python
310
+ import PyPartMC
311
+ PyPartMC.__versions_of_build_time_dependencies__['PartMC']
312
+ ```
313
+
314
+ - Q: Why m4 and perl are required at compile time?
315
+ A: PyPartMC includes parts of netCDF and HDF5 codebases which depend on m4 and perl, respectively, for generating source files before compilation.
316
+
317
+ ## Troubleshooting
318
+
319
+ #### Common installation issues
320
+ ```
321
+ error: [Errno 2] No such file or directory: 'cmake'
322
+ ```
323
+ Try rerunning after installing CMake, e.g., using `apt-get install cmake` (Ubuntu/Debian), `brew install cmake` (homebrew on macOS) or using [MSYS2](https://www.msys2.org/docs/cmake/) on Windows.
324
+
325
+ ```
326
+ No CMAKE_Fortran_COMPILER could be found.
327
+ ```
328
+ Try installing a Fortran compiler (e.g., `brew reinstall gcc` with Homebrew on macOS or using [MSYS2](https://packages.msys2.org/package/mingw-w64-x86_64-gcc-fortran?repo=mingw64) on Windows).
329
+
330
+ ```
331
+ Could not find NC_M4 using the following names: m4, m4.exe
332
+ ```
333
+ Try installing `m4` (e.g., using [MSYS2](https://packages.msys2.org/package/m4?repo=msys&variant=x86_64) on Windows).
334
+
335
+ ## Acknowledgement and citations
336
+
337
+ We would greatly appreciate citation of the PartMC model description paper (Riemer et al., 2009)
338
+ and the PyPartMC description paper (D’Aquino et al., 2024) if PyPartMC was used in your study.
339
+ The citations are:
340
+ - Riemer, N., M. West, R. A. Zaveri, R. C. Easter: Simulating the evolution of soot
341
+ mixing-state with a particle-resolved aerosol model
342
+ J. Geophys. Res., 114, D09202, 2009, DOI: [10.1029/2008JD011073](https://doi.org/10.1029/2008JD011073)
343
+ - D’Aquino, Z., S. Arabas, J. H. Curtis, A. Vaishnav, N. Riemer, M. West: PyPartMC: A
344
+ pythonic interfact to a particle-resolved, Monte Carlo aerosol simulation framework
345
+ SoftwareX, 25, 101613, 2024, DOI: [10.1016/j.softx.2023.101613](https://doi.org/10.1016/j.softx.2023.101613)
346
+
347
+ The following paragraph provides a more substantial description of PartMC (text released into the public domain and can be freely copied by anyone for any purpose):
348
+
349
+ > PartMC is a stochastic, particle-resolved aerosol box model. It tracks the
350
+ composition of many computational particles (10<sup>4</sup> to 10<sup>6</sup>) within a well-mixed air
351
+ volume, each represented by a composition vector that evolves based on physical
352
+ and chemical processes. The physical processes—including Brownian coagulation,
353
+ new particle formation, emissions, dilution, and deposition—are simulated using a
354
+ stochastic Monte Carlo approach via a Poisson process while chemical processes are
355
+ simulated deterministically for each computational particle. The weighted flow
356
+ algorithm (DeVille, Riemer, and West, 2011, 2019) enhances efficiency and reduces
357
+ ensemble variance. Detailed numerical methods are described in Riemer et al.
358
+ (2009), DeVille et al. (2011, 2019), and Curtis et al. (2016). PartMC is open-source
359
+ under the GNU GPL v2 and available at
360
+ [github.com/compdyn/partmc](https://github.com/compdyn/partmc).
361
+ >
362
+ > References:
363
+ > - Curtis, J. H., M. D. Michelotti, N. Riemer, M. T. Heath, M. West: Accelerated
364
+ simulation of stochastic particle removal processes in particle-resolved aerosol
365
+ models, J. Computational Phys., 322, 21-32, 2016, DOI: [10.1016/j.jcp.2016.06.029](https://doi.org/10.1016/j.jcp.2016.06.029)
366
+ > - DeVille, L., N. Riemer, M. West, Convergence of a generalized weighted flow
367
+ algorithm for stochastic particle coagulation, J. Computational Dynamics, 6, 69-94,
368
+ 2019, DOI: [10.3934/jcd.2019003](https://doi.org/10.3934/jcd.2019003)
369
+ > - DeVille, R. E. L., N. Riemer, M. West, The Weighted Flow Algorithm (WFA) for
370
+ stochastic particle coagulation, J. Computational Phys., 230, 8427-8451, 2011,
371
+ DOI: [10.1016/j.jcp.2011.07.027](https://doi.org/10.1016/j.jcp.2011.07.027)
372
+ > - Riemer, N., M. West, R. A. Zaveri, R. C. Easter, Simulating the evolution of soot
373
+ mixing-state with a particle-resolved aerosol model, J. Geophys. Res., 114, D09202,
374
+ 2009., DOI: [10.1029/2008JD011073](https://doi.org/10.1029/2008JD011073)
375
+
376
+ ## Credits
377
+
378
+ #### PyPartMC:
379
+
380
+ authors: [PyPartMC developers](https://github.com/open-atmos/PyPartMC/graphs/contributors)
381
+ funding: [US Department of Energy Atmospheric System Research programme](https://asr.science.energy.gov/), [Polish National Science Centre](https://ncn.gov.pl/en)
382
+ copyright: [University of Illinois at Urbana-Champaign](https://atmos.illinois.edu/)
383
+ licence: [GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html)
384
+
385
+ #### PartMC:
386
+ authors: [Nicole Riemer](https://www.atmos.uiuc.edu/~nriemer/), [Matthew West](https://lagrange.mechse.illinois.edu/mwest/), [Jeff Curtis](https://publish.illinois.edu/jcurtis2/) et al.
387
+ licence: [GPL v2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) or later
388
+
@@ -0,0 +1,6 @@
1
+ PyPartMC/__init__.py,sha256=UxEKfxEgrPz4tNfNPCzWf3WGLCCuDcZ7HpJHV-efZ5Y,2435
2
+ PyPartMC/_PyPartMC.cp310-win_amd64.pyd,sha256=Eum4F_ZXdpTYdHc48nqUkqRLfTu50m-uueOVgqxvR-k,9400832
3
+ pypartmc-2.0.0rc3.dist-info/METADATA,sha256=4aUTawjPsb6pM4Ri_j8vmVSsCzx-O8mdi8jichPcoSs,26630
4
+ pypartmc-2.0.0rc3.dist-info/WHEEL,sha256=dD8EM_eb3pZmEbkvPEPxqrbrFtr3mwlecsbXbps1z7Y,106
5
+ pypartmc-2.0.0rc3.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
6
+ pypartmc-2.0.0rc3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: scikit-build-core 0.11.5
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp310-cp310-win_amd64
5
5
 
@@ -1,7 +0,0 @@
1
- _PyPartMC.cp310-win_amd64.pyd,sha256=ZmErblUYkbfszi7L_aEjZDkYIC7amyXZrRETWvPDy9o,9585152
2
- PyPartMC/__init__.py,sha256=72fDfFXn4xRxfdLGOx8NCml41RxzBitBNZ-sUuvH-x0,2295
3
- PyPartMC-1.3.13.dist-info/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
4
- PyPartMC-1.3.13.dist-info/METADATA,sha256=N_3ehnEBJXVh7CEAhaaKWdbULbUM7-UUFNiX23IsWp0,20976
5
- PyPartMC-1.3.13.dist-info/WHEEL,sha256=rzGfZgUcGeKSgIHGYMuqg4xE4VPHxnaldXH6BG0zjVk,101
6
- PyPartMC-1.3.13.dist-info/top_level.txt,sha256=PJxy22pTnxcBhqrb6r4AIL32rkxA61gzw7ohlzybgSM,19
7
- PyPartMC-1.3.13.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- PyPartMC
2
- _PyPartMC