PySDM 2.78__py3-none-any.whl → 2.80__py3-none-any.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.
- PySDM/__init__.py +1 -20
- PySDM/attributes/ice/cooling_rate.py +3 -0
- PySDM/backends/numba.py +4 -3
- PySDM-2.80.dist-info/METADATA +212 -0
- {PySDM-2.78.dist-info → PySDM-2.80.dist-info}/RECORD +8 -8
- {PySDM-2.78.dist-info → PySDM-2.80.dist-info}/WHEEL +1 -1
- PySDM-2.78.dist-info/METADATA +0 -903
- {PySDM-2.78.dist-info → PySDM-2.80.dist-info}/LICENSE +0 -0
- {PySDM-2.78.dist-info → PySDM-2.80.dist-info}/top_level.txt +0 -0
PySDM/__init__.py
CHANGED
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
# pylint:disable=invalid-name
|
|
2
2
|
"""
|
|
3
|
-
|
|
4
|
-
simulation systems revolving around the particle-based microphysics modelling concept
|
|
5
|
-
and the Super-Droplet Method algorithm ([Shima et al. 2009](https://doi.org/10.1002/qj.441))
|
|
6
|
-
for numerically tackling the probabilistic representation of particle coagulation.
|
|
7
|
-
|
|
8
|
-
For an overview of PySDM, see [Bartman, Arabas et al. 2021](https://arxiv.org/abs/2103.17238).
|
|
9
|
-
PySDM is released under the [GNU GPL v3 license](https://www.gnu.org/licenses/gpl-3.0.en.html).
|
|
10
|
-
PySDM development has been spearheaded at the Faculty of Mathematics and Computer Science,
|
|
11
|
-
[Jagiellonian University in Kraków](https://en.uj.edu.pl/en) (the copyright holder).
|
|
12
|
-
|
|
13
|
-
For details on PySDM dependencies and installation procedures, see project
|
|
14
|
-
[README.md file](https://github.com/open-atmos/PySDM/blob/master/README.md)
|
|
15
|
-
which also includes basic usage examples in **Python**, **Julia** and **Matlab**.
|
|
16
|
-
|
|
17
|
-
A set of more elaborate examples engineered in Python and accompanied by Jupyter
|
|
18
|
-
notebooks are maintained in the
|
|
19
|
-
[PySDM-examples package](https://github.com/open-atmos/PySDM-examples).
|
|
20
|
-
|
|
21
|
-
PySDM test-suite built using [pytest](https://docs.pytest.org/) is located in the
|
|
22
|
-
[tests package](https://github.com/open-atmos/PySDM/tree/master/tests).
|
|
3
|
+
.. include:: ../docs/markdown/pysdm_landing.md
|
|
23
4
|
"""
|
|
24
5
|
|
|
25
6
|
from importlib.metadata import PackageNotFoundError, version
|
|
@@ -21,6 +21,9 @@ class CoolingRate(DerivedAttribute):
|
|
|
21
21
|
builder.particulator.observers.append(self)
|
|
22
22
|
|
|
23
23
|
def notify(self):
|
|
24
|
+
"""triggers update to ensure recalculation is done before
|
|
25
|
+
overwriting `self.prev_T` with current temperature"""
|
|
26
|
+
self.update()
|
|
24
27
|
cell_id = self.particulator.attributes["cell id"]
|
|
25
28
|
self.prev_T[:] = self.particulator.environment["T"][cell_id]
|
|
26
29
|
|
PySDM/backends/numba.py
CHANGED
|
@@ -43,9 +43,10 @@ class Numba( # pylint: disable=too-many-ancestors,duplicate-code
|
|
|
43
43
|
|
|
44
44
|
parallel_default = True
|
|
45
45
|
if platform.machine() == "arm64":
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if "CI" not in os.environ:
|
|
47
|
+
warnings.warn(
|
|
48
|
+
"Disabling Numba threading due to ARM64 CPU (atomics do not work yet)"
|
|
49
|
+
)
|
|
49
50
|
parallel_default = False # TODO #1183 - atomics don't work on ARM64!
|
|
50
51
|
|
|
51
52
|
try:
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: PySDM
|
|
3
|
+
Version: 2.80
|
|
4
|
+
Summary: Pythonic particle-based (super-droplet) warm-rain/aqueous-chemistry cloud microphysics package with box, parcel & 1D/2D prescribed-flow examples in Python, Julia and Matlab
|
|
5
|
+
Home-page: https://github.com/open-atmos/PySDM
|
|
6
|
+
Author: https://github.com/open-atmos/PySDM/graphs/contributors
|
|
7
|
+
Author-email: sylwester.arabas@agh.edu.pl
|
|
8
|
+
License: GPL-3.0
|
|
9
|
+
Project-URL: Tracker, https://github.com/open-atmos/PySDM/issues
|
|
10
|
+
Project-URL: Documentation, https://open-atmos.github.io/PySDM
|
|
11
|
+
Project-URL: Source, https://github.com/open-atmos/PySDM
|
|
12
|
+
Keywords: physics-simulation,monte-carlo-simulation,gpu-computing,atmospheric-modelling,particle-system,numba,thrust,nvrtc,pint,atmospheric-physics
|
|
13
|
+
Platform: UNKNOWN
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: ThrustRTC==0.3.20
|
|
26
|
+
Requires-Dist: CURandRTC>=0.1.2
|
|
27
|
+
Requires-Dist: numba>=0.51.2
|
|
28
|
+
Requires-Dist: numpy
|
|
29
|
+
Requires-Dist: Pint
|
|
30
|
+
Requires-Dist: chempy
|
|
31
|
+
Requires-Dist: scipy
|
|
32
|
+
Requires-Dist: pyevtk
|
|
33
|
+
Requires-Dist: flexparser<0.4
|
|
34
|
+
Provides-Extra: tests
|
|
35
|
+
Requires-Dist: matplotlib; extra == "tests"
|
|
36
|
+
Requires-Dist: pytest; extra == "tests"
|
|
37
|
+
Requires-Dist: pytest-timeout; extra == "tests"
|
|
38
|
+
Requires-Dist: PyPartMC==1.3.6; extra == "tests"
|
|
39
|
+
Requires-Dist: pyrcel; extra == "tests"
|
|
40
|
+
Requires-Dist: jupyter-core<5.0.0; extra == "tests"
|
|
41
|
+
Requires-Dist: ipywidgets!=8.0.3; extra == "tests"
|
|
42
|
+
|
|
43
|
+
# <img src="https://raw.githubusercontent.com/open-atmos/PySDM/main/.github/pysdm_logo.png" width=100 height=146 alt="pysdm logo">
|
|
44
|
+
|
|
45
|
+
[](https://www.python.org/)
|
|
46
|
+
[](https://numba.pydata.org)
|
|
47
|
+
[](https://pypi.org/project/ThrustRTC/)
|
|
48
|
+
[](https://en.wikipedia.org/wiki/Linux)
|
|
49
|
+
[](https://en.wikipedia.org/wiki/macOS)
|
|
50
|
+
[](https://en.wikipedia.org/wiki/Windows)
|
|
51
|
+
[](https://jupyter.org/)
|
|
52
|
+
[](https://github.com/open-atmos/PySDM/graphs/commit-activity)
|
|
53
|
+
[](https://www.openhub.net/p/atmos-cloud-sim-uj-PySDM)
|
|
54
|
+
[](https://joss.theoj.org/papers/62cad07440b941f73f57d187df1aa6e9)
|
|
55
|
+
[](https://zenodo.org/badge/latestdoi/199064632)
|
|
56
|
+
[](https://www.fnp.org.pl/en/)
|
|
57
|
+
[](https://www.ncn.gov.pl/?language=en)
|
|
58
|
+
[](https://asr.science.energy.gov/)
|
|
59
|
+
|
|
60
|
+
[](https://www.gnu.org/licenses/gpl-3.0.html)
|
|
61
|
+
|
|
62
|
+
[](https://github.com/open-atmos/PySDM/actions)
|
|
63
|
+
[](https://ci.appveyor.com/project/slayoo/pysdm/branch/main)
|
|
64
|
+
[](https://app.codecov.io/gh/open-atmos/PySDM)
|
|
65
|
+
[](https://pypi.org/project/PySDM)
|
|
66
|
+
[](https://open-atmos.github.io/PySDM/)
|
|
67
|
+
|
|
68
|
+
PySDM is a package for simulating the dynamics of population of particles.
|
|
69
|
+
It is intended to serve as a building block for simulation systems modelling
|
|
70
|
+
fluid flows involving a dispersed phase,
|
|
71
|
+
with PySDM being responsible for representation of the dispersed phase.
|
|
72
|
+
Currently, the development is focused on atmospheric cloud physics
|
|
73
|
+
applications, in particular on modelling the dynamics of particles immersed in moist air
|
|
74
|
+
using the particle-based (a.k.a. super-droplet) approach
|
|
75
|
+
to represent aerosol/cloud/rain microphysics.
|
|
76
|
+
The package features a Pythonic high-performance implementation of the
|
|
77
|
+
Super-Droplet Method (SDM) Monte-Carlo algorithm for representing collisional growth
|
|
78
|
+
([Shima et al. 2009](https://rmets.onlinelibrary.wiley.com/doi/abs/10.1002/qj.441)), hence the name.
|
|
79
|
+
|
|
80
|
+
There is a growing set of example Jupyter notebooks exemplifying how to perform
|
|
81
|
+
various types of calculations and simulations using PySDM.
|
|
82
|
+
Most of the example notebooks reproduce results and plot from literature, see below for
|
|
83
|
+
a list of examples and links to the notebooks (which can be either executed or viewed
|
|
84
|
+
"in the cloud").
|
|
85
|
+
|
|
86
|
+
There are also a growing set of [tutorials](https://github.com/open-atmos/PySDM/tree/main/tutorials), also in the form of Jupyter notebooks.
|
|
87
|
+
These tutorials are intended for teaching purposes and include short explanations of cloud microphysical
|
|
88
|
+
concepts paired with widgets for running interactive simulations using PySDM.
|
|
89
|
+
Each tutorial also comes with a set of questions at the end that can be used as homework problems.
|
|
90
|
+
Like the examples, these tutorials can be executed or viewed "in the cloud" making it an especially
|
|
91
|
+
easy way for students to get started.
|
|
92
|
+
|
|
93
|
+
PySDM has two alternative parallel number-crunching backends
|
|
94
|
+
available: multi-threaded CPU backend based on [Numba](http://numba.pydata.org/)
|
|
95
|
+
and GPU-resident backend built on top of [ThrustRTC](https://pypi.org/project/ThrustRTC/).
|
|
96
|
+
The [`Numba`](https://open-atmos.github.io/PySDM/PySDM/backends/numba.html) backend (aliased ``CPU``) features multi-threaded parallelism for
|
|
97
|
+
multi-core CPUs, it uses the just-in-time compilation technique based on the LLVM infrastructure.
|
|
98
|
+
The [`ThrustRTC`](https://open-atmos.github.io/PySDM/PySDM/backends/thrust_rtc.html) backend (aliased ``GPU``) offers GPU-resident operation of PySDM
|
|
99
|
+
leveraging the [SIMT](https://en.wikipedia.org/wiki/Single_instruction,_multiple_threads)
|
|
100
|
+
parallelisation model.
|
|
101
|
+
Using the ``GPU`` backend requires nVidia hardware and [CUDA driver](https://developer.nvidia.com/cuda-downloads).
|
|
102
|
+
|
|
103
|
+
For an overview of PySDM features (and the preferred way to cite PySDM in papers), please refer to our JOSS papers:
|
|
104
|
+
- [Bartman et al. 2022](https://doi.org/10.21105/joss.03219) (PySDM v1).
|
|
105
|
+
- [de Jong, Singer et al. 2023](https://doi.org/10.21105/joss.04968) (PySDM v2).
|
|
106
|
+
|
|
107
|
+
PySDM includes an extension of the SDM scheme to represent collisional breakup described in [de Jong, Mackay et al. 2023](10.5194/gmd-16-4193-2023).
|
|
108
|
+
For a list of talks and other materials on PySDM as well as a list of published papers featuring PySDM simulations, see the [project wiki](https://github.com/open-atmos/PySDM/wiki).
|
|
109
|
+
|
|
110
|
+
A [pdoc-generated](https://pdoc.dev/) documentation of PySDM public API is maintained at: [https://open-atmos.github.io/PySDM](https://open-atmos.github.io/PySDM)
|
|
111
|
+
|
|
112
|
+
## Example Jupyter notebooks (reproducing results from literature):
|
|
113
|
+
|
|
114
|
+
See [PySDM-examples README](https://github.com/open-atmos/PySDM/blob/main/examples/README.md).
|
|
115
|
+
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
## Dependencies and Installation
|
|
119
|
+
|
|
120
|
+
PySDM dependencies are: [Numpy](https://numpy.org/), [Numba](http://numba.pydata.org/), [SciPy](https://scipy.org/),
|
|
121
|
+
[Pint](https://pint.readthedocs.io/), [chempy](https://pypi.org/project/chempy/),
|
|
122
|
+
[pyevtk](https://pypi.org/project/pyevtk/),
|
|
123
|
+
[ThrustRTC](https://fynv.github.io/ThrustRTC/) and [CURandRTC](https://github.com/fynv/CURandRTC).
|
|
124
|
+
|
|
125
|
+
To install PySDM using ``pip``, use: ``pip install PySDM``
|
|
126
|
+
(or ``pip install git+https://github.com/open-atmos/PySDM.git`` to get updates
|
|
127
|
+
beyond the latest release).
|
|
128
|
+
|
|
129
|
+
Conda users may use ``pip`` as well, see the [Installing non-conda packages](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#installing-non-conda-packages) section in the conda docs. Dependencies of PySDM are available at the following conda channels:
|
|
130
|
+
- numba: [numba](https://anaconda.org/numba/numba)
|
|
131
|
+
- conda-forge: [pyevtk](https://anaconda.org/conda-forge/pyevtk), [pint](https://anaconda.org/conda-forge/pint) and []()
|
|
132
|
+
- fyplus: [ThrustRTC](https://anaconda.org/fyplus/thrustrtc), [CURandRTC](https://anaconda.org/fyplus/curandrtc)
|
|
133
|
+
- bjodah: [chempy](https://anaconda.org/bjodah/chempy)
|
|
134
|
+
- nvidia: [cudatoolkit](https://anaconda.org/nvidia/cudatoolkit)
|
|
135
|
+
|
|
136
|
+
For development purposes, we suggest cloning the repository and installing it using ``pip -e``.
|
|
137
|
+
Test-time dependencies can be installed with ``pip -e .[tests]``.
|
|
138
|
+
|
|
139
|
+
PySDM examples constitute the [``PySDM-examples``](https://github.com/open-atmos/PySDM-examples) package.
|
|
140
|
+
The examples have additional dependencies listed in [``PySDM_examples`` package ``setup.py``](https://github.com/open-atmos/PySDM/blob/main/examples/setup.py) file.
|
|
141
|
+
Running the example Jupyter notebooks requires the ``PySDM_examples`` package to be installed.
|
|
142
|
+
The suggested install and launch steps are:
|
|
143
|
+
```
|
|
144
|
+
git clone https://github.com/open-atmos/PySDM.git
|
|
145
|
+
pip install -e PySDM
|
|
146
|
+
pip install -e PySDM/examples
|
|
147
|
+
jupyter-notebook PySDM/examples/PySDM_examples
|
|
148
|
+
```
|
|
149
|
+
Alternatively, one can also install the examples package from pypi.org by
|
|
150
|
+
using ``pip install PySDM-examples`` (note that this does not apply to notebooks itself,
|
|
151
|
+
only the supporting .py files).
|
|
152
|
+
|
|
153
|
+
## Contributing, reporting issues, seeking support
|
|
154
|
+
|
|
155
|
+
#### Our technologicial stack:
|
|
156
|
+
[](https://www.python.org/)
|
|
157
|
+
[](https://numba.pydata.org)
|
|
158
|
+
[](https://llvm.org)
|
|
159
|
+
[](https://pypi.org/project/ThrustRTC/)
|
|
160
|
+
[](https://numpy.org/)
|
|
161
|
+
[](https://pytest.org/)
|
|
162
|
+
[](https://colab.research.google.com/)
|
|
163
|
+
[](https://codecov.io/)
|
|
164
|
+
[](https://pypi.org/)
|
|
165
|
+
[](https://github.com/features/actions)
|
|
166
|
+
[](https://jupyter.org/)
|
|
167
|
+
[](https:///)
|
|
168
|
+
|
|
169
|
+
Submitting new code to the project, please preferably use [GitHub pull requests](https://github.com/open-atmos/PySDM/pulls) - it helps to keep record of code authorship,
|
|
170
|
+
track and archive the code review workflow and allows to benefit
|
|
171
|
+
from the continuous integration setup which automates execution of tests
|
|
172
|
+
with the newly added code.
|
|
173
|
+
|
|
174
|
+
Code contributions are assumed to imply transfer of copyright.
|
|
175
|
+
Should there be a need to make an exception, please indicate it when creating
|
|
176
|
+
a pull request or contributing code in any other way. In any case,
|
|
177
|
+
the license of the contributed code must be compatible with GPL v3.
|
|
178
|
+
|
|
179
|
+
Developing the code, we follow [The Way of Python](https://www.python.org/dev/peps/pep-0020/) and
|
|
180
|
+
the [KISS principle](https://en.wikipedia.org/wiki/KISS_principle).
|
|
181
|
+
The codebase has greatly benefited from [PyCharm code inspections](https://www.jetbrains.com/help/pycharm/code-inspection.html)
|
|
182
|
+
and [Pylint](https://pylint.org), [Black](https://black.readthedocs.io/en/stable/) and [isort](https://pycqa.github.io/isort/)
|
|
183
|
+
code analysis (which are all part of the CI workflows).
|
|
184
|
+
|
|
185
|
+
We also use [pre-commit hooks](https://pre-commit.com).
|
|
186
|
+
In our case, the hooks modify files and re-format them.
|
|
187
|
+
The pre-commit hooks can be run locally, and then the resultant changes need to be staged before committing.
|
|
188
|
+
To set up the hooks locally, install pre-commit via `pip install pre-commit` and
|
|
189
|
+
set up the git hooks via `pre-commit install` (this needs to be done every time you clone the project).
|
|
190
|
+
To run all pre-commit hooks, run `pre-commit run --all-files`.
|
|
191
|
+
The `.pre-commit-config.yaml` file can be modified in case new hooks are to be added or
|
|
192
|
+
existing ones need to be altered.
|
|
193
|
+
|
|
194
|
+
Further hints addressed at PySDM developers are maintained in the [open-atmos/python-dev-hints Wiki](https://github.com/open-atmos/python-dev-hints/wiki).
|
|
195
|
+
|
|
196
|
+
Issues regarding any incorrect, unintuitive or undocumented bahaviour of
|
|
197
|
+
PySDM are best to be reported on the [GitHub issue tracker](https://github.com/open-atmos/PySDM/issues/new).
|
|
198
|
+
Feature requests are recorded in the "Ideas..." [PySDM wiki page](https://github.com/open-atmos/PySDM/wiki/Ideas-for-new-features-and-examples).
|
|
199
|
+
|
|
200
|
+
We encourage to use the [GitHub Discussions](https://github.com/open-atmos/PySDM/discussions) feature
|
|
201
|
+
(rather than the issue tracker) for seeking support in understanding, using and extending PySDM code.
|
|
202
|
+
|
|
203
|
+
We look forward to your contributions and feedback.
|
|
204
|
+
|
|
205
|
+
## Licensing:
|
|
206
|
+
|
|
207
|
+
copyright: [Jagiellonian University](https://en.uj.edu.pl/en) (2019-2023) & [AGH University of Krakow](https://agh.edu.pl/en) (2023-...)
|
|
208
|
+
licence: [GPL v3](https://www.gnu.org/licenses/gpl-3.0.html)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
PySDM/__init__.py,sha256=
|
|
1
|
+
PySDM/__init__.py,sha256=AbawUM-8fsn8TRTp9mhy9YBVdPmGzG9KELdR24ZmrcY,504
|
|
2
2
|
PySDM/builder.py,sha256=6hgxvCFmDe9sJJDT9CgNf9c9ByLvOSvC9cXcc164Yac,5934
|
|
3
3
|
PySDM/formulae.py,sha256=KZmUm6JpVPt5Y8lc7BYc_EWY8ZSMDktFjVHnFENp6YM,13761
|
|
4
4
|
PySDM/particulator.py,sha256=pPI2yWD9RsKkiQPKODRtiaBo_cgsMMJH6HwmSJEbj94,18120
|
|
@@ -8,7 +8,7 @@ PySDM/attributes/chemistry/acidity.py,sha256=XGRhQEi7XH9WtBmwzsaMphzuq3ZYGhqClo4
|
|
|
8
8
|
PySDM/attributes/chemistry/concentration.py,sha256=SePyTjF_Xz7g8BuoxNauUGyrqSm28AJtY-ZnekiwJQc,782
|
|
9
9
|
PySDM/attributes/chemistry/hydrogen_ion_concentration.py,sha256=VUyZANuDIQ8YiF7r-fGh_3pLgtHULE3GpToa5lhE78E,475
|
|
10
10
|
PySDM/attributes/ice/__init__.py,sha256=H4geuX7GEkaLfMp5UqBUq7kYOQzziR4AIZ8e77NIhrI,222
|
|
11
|
-
PySDM/attributes/ice/cooling_rate.py,sha256
|
|
11
|
+
PySDM/attributes/ice/cooling_rate.py,sha256=nHLfDe1utVV4UQE431DOfjCt9u1H6_24-t7RfDQ3PrU,1320
|
|
12
12
|
PySDM/attributes/ice/freezing_temperature.py,sha256=20fvlNLNLMWRMJGuawflan-WU5fVBfTCJNHVJKQaCSc,364
|
|
13
13
|
PySDM/attributes/ice/immersed_surface_area.py,sha256=YGkvzX0vAMglTt2lowueDvmtCLtueTo1DcL7ukOwKWI,376
|
|
14
14
|
PySDM/attributes/impl/__init__.py,sha256=hcyb5nTVgRkQX91EIj6_6P2sUop1NtB8_PnFCTCoW20,520
|
|
@@ -47,7 +47,7 @@ PySDM/attributes/physics/terminal_velocity.py,sha256=zu0U0g-qGcx5HJqhTFJHuLyp7lm
|
|
|
47
47
|
PySDM/attributes/physics/volume.py,sha256=25eG5HEXeRMJV4iKywtZ0JTU5PiF2Ibp3X-WHC6BB6c,587
|
|
48
48
|
PySDM/attributes/physics/water_mass.py,sha256=fzmCjIWLWgghWy_Pa4KZoCd2XgdUv3tb-qB9FFmCUF8,392
|
|
49
49
|
PySDM/backends/__init__.py,sha256=6dPU5Y30rDovvkaTehryG9gA-tJk5sEOrmlxpQAP4Ek,2235
|
|
50
|
-
PySDM/backends/numba.py,sha256=
|
|
50
|
+
PySDM/backends/numba.py,sha256=vsIdVy0fXVTBqFv6pVMsPR-6me1jecbfVhi4pN0V1Hk,2833
|
|
51
51
|
PySDM/backends/thrust_rtc.py,sha256=5T2joHmLA5y-HPbLfw4m3wf9-BFuk-1YsmWJj62LPNU,2643
|
|
52
52
|
PySDM/backends/impl_common/__init__.py,sha256=hP2LHBlnzcaOh8MMNdm2fbChkfRakwbKn0PaKhLdyP8,37
|
|
53
53
|
PySDM/backends/impl_common/backend_methods.py,sha256=2TaqFIccgQfsNB0X_H4kTgUdgSUu3_H6lDyLUhN4Z2E,560
|
|
@@ -383,8 +383,8 @@ PySDM/products/size_spectral/size_standard_deviation.py,sha256=A7fSj_keQi_bHW41P
|
|
|
383
383
|
PySDM/products/size_spectral/total_particle_concentration.py,sha256=K7sO2jgUpYOwWvBK3jXp9KUxLRXk_Ve6ooOdY5q5jd0,470
|
|
384
384
|
PySDM/products/size_spectral/total_particle_specific_concentration.py,sha256=isLZt5j2vJGr-FrzYFcUNPHZqMKhOtl51za1Hogh6hQ,476
|
|
385
385
|
PySDM/products/size_spectral/water_mixing_ratio.py,sha256=PP54hfMy4SPDQDJgV4RNzVP03lmL1THZPa2KXrdgoQ4,1324
|
|
386
|
-
PySDM-2.
|
|
387
|
-
PySDM-2.
|
|
388
|
-
PySDM-2.
|
|
389
|
-
PySDM-2.
|
|
390
|
-
PySDM-2.
|
|
386
|
+
PySDM-2.80.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
387
|
+
PySDM-2.80.dist-info/METADATA,sha256=vyLdc5QilJm54i6Uy9Bxbpsq1-ZIf-GpLNWA7JW3vc8,17217
|
|
388
|
+
PySDM-2.80.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
|
|
389
|
+
PySDM-2.80.dist-info/top_level.txt,sha256=6NYaDAhUnaYMD7ebD_dQ7HlhiJS7NMuKEXb0ck7Wcsg,6
|
|
390
|
+
PySDM-2.80.dist-info/RECORD,,
|
PySDM-2.78.dist-info/METADATA
DELETED
|
@@ -1,903 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: PySDM
|
|
3
|
-
Version: 2.78
|
|
4
|
-
Summary: Pythonic particle-based (super-droplet) warm-rain/aqueous-chemistry cloud microphysics package with box, parcel & 1D/2D prescribed-flow examples in Python, Julia and Matlab
|
|
5
|
-
Home-page: https://github.com/open-atmos/PySDM
|
|
6
|
-
Author: https://github.com/open-atmos/PySDM/graphs/contributors
|
|
7
|
-
Author-email: sylwester.arabas@agh.edu.pl
|
|
8
|
-
License: GPL-3.0
|
|
9
|
-
Project-URL: Tracker, https://github.com/open-atmos/PySDM/issues
|
|
10
|
-
Project-URL: Documentation, https://open-atmos.github.io/PySDM
|
|
11
|
-
Project-URL: Source, https://github.com/open-atmos/PySDM
|
|
12
|
-
Keywords: physics-simulation,monte-carlo-simulation,gpu-computing,atmospheric-modelling,particle-system,numba,thrust,nvrtc,pint,atmospheric-physics
|
|
13
|
-
Platform: UNKNOWN
|
|
14
|
-
Classifier: Development Status :: 4 - Beta
|
|
15
|
-
Classifier: Intended Audience :: Science/Research
|
|
16
|
-
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
17
|
-
Classifier: Operating System :: OS Independent
|
|
18
|
-
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Topic :: Scientific/Engineering
|
|
20
|
-
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
|
|
21
|
-
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
22
|
-
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
23
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
Requires-Dist: ThrustRTC==0.3.20
|
|
26
|
-
Requires-Dist: CURandRTC>=0.1.2
|
|
27
|
-
Requires-Dist: numba>=0.51.2
|
|
28
|
-
Requires-Dist: numpy
|
|
29
|
-
Requires-Dist: Pint
|
|
30
|
-
Requires-Dist: chempy
|
|
31
|
-
Requires-Dist: scipy
|
|
32
|
-
Requires-Dist: pyevtk
|
|
33
|
-
Provides-Extra: tests
|
|
34
|
-
Requires-Dist: matplotlib; extra == "tests"
|
|
35
|
-
Requires-Dist: pytest; extra == "tests"
|
|
36
|
-
Requires-Dist: pytest-timeout; extra == "tests"
|
|
37
|
-
Requires-Dist: PyPartMC==1.3.3; extra == "tests"
|
|
38
|
-
Requires-Dist: pyrcel; extra == "tests"
|
|
39
|
-
Requires-Dist: jupyter-core<5.0.0; extra == "tests"
|
|
40
|
-
Requires-Dist: ipywidgets!=8.0.3; extra == "tests"
|
|
41
|
-
|
|
42
|
-
# <img src="https://raw.githubusercontent.com/open-atmos/PySDM/main/.github/pysdm_logo.png" width=100 height=146 alt="pysdm logo">
|
|
43
|
-
|
|
44
|
-
# PySDM
|
|
45
|
-
|
|
46
|
-
[](https://www.python.org/)
|
|
47
|
-
[](https://numba.pydata.org)
|
|
48
|
-
[](https://pypi.org/project/ThrustRTC/)
|
|
49
|
-
[](https://en.wikipedia.org/wiki/Linux)
|
|
50
|
-
[](https://en.wikipedia.org/wiki/macOS)
|
|
51
|
-
[](https://en.wikipedia.org/wiki/Windows)
|
|
52
|
-
[](https://jupyter.org/)
|
|
53
|
-
[](https://github.com/open-atmos/PySDM/graphs/commit-activity)
|
|
54
|
-
[](https://www.openhub.net/p/atmos-cloud-sim-uj-PySDM)
|
|
55
|
-
[](https://joss.theoj.org/papers/62cad07440b941f73f57d187df1aa6e9)
|
|
56
|
-
[](https://zenodo.org/badge/latestdoi/199064632)
|
|
57
|
-
[](https://www.fnp.org.pl/en/)
|
|
58
|
-
[](https://www.ncn.gov.pl/?language=en)
|
|
59
|
-
[](https://asr.science.energy.gov/)
|
|
60
|
-
|
|
61
|
-
[](https://www.gnu.org/licenses/gpl-3.0.html)
|
|
62
|
-
|
|
63
|
-
[](https://github.com/open-atmos/PySDM/actions)
|
|
64
|
-
[](https://ci.appveyor.com/project/slayoo/pysdm/branch/main)
|
|
65
|
-
[](https://app.codecov.io/gh/open-atmos/PySDM)
|
|
66
|
-
[](https://pypi.org/project/PySDM)
|
|
67
|
-
[](https://open-atmos.github.io/PySDM/)
|
|
68
|
-
|
|
69
|
-
PySDM is a package for simulating the dynamics of population of particles.
|
|
70
|
-
It is intended to serve as a building block for simulation systems modelling
|
|
71
|
-
fluid flows involving a dispersed phase,
|
|
72
|
-
with PySDM being responsible for representation of the dispersed phase.
|
|
73
|
-
Currently, the development is focused on atmospheric cloud physics
|
|
74
|
-
applications, in particular on modelling the dynamics of particles immersed in moist air
|
|
75
|
-
using the particle-based (a.k.a. super-droplet) approach
|
|
76
|
-
to represent aerosol/cloud/rain microphysics.
|
|
77
|
-
The package features a Pythonic high-performance implementation of the
|
|
78
|
-
Super-Droplet Method (SDM) Monte-Carlo algorithm for representing collisional growth
|
|
79
|
-
([Shima et al. 2009](https://rmets.onlinelibrary.wiley.com/doi/abs/10.1002/qj.441)), hence the name.
|
|
80
|
-
|
|
81
|
-
There is a growing set of example Jupyter notebooks exemplifying how to perform
|
|
82
|
-
various types of calculations and simulations using PySDM.
|
|
83
|
-
Most of the example notebooks reproduce results and plot from literature, see below for
|
|
84
|
-
a list of examples and links to the notebooks (which can be either executed or viewed
|
|
85
|
-
"in the cloud").
|
|
86
|
-
|
|
87
|
-
There are also a growing set of [tutorials](https://github.com/open-atmos/PySDM/tree/main/tutorials), also in the form of Jupyter notebooks.
|
|
88
|
-
These tutorials are intended for teaching purposes and include short explanations of cloud microphysical
|
|
89
|
-
concepts paired with widgets for running interactive simulations using PySDM.
|
|
90
|
-
Each tutorial also comes with a set of questions at the end that can be used as homework problems.
|
|
91
|
-
Like the examples, these tutorials can be executed or viewed "in the cloud" making it an especially
|
|
92
|
-
easy way for students to get started.
|
|
93
|
-
|
|
94
|
-
PySDM has two alternative parallel number-crunching backends
|
|
95
|
-
available: multi-threaded CPU backend based on [Numba](http://numba.pydata.org/)
|
|
96
|
-
and GPU-resident backend built on top of [ThrustRTC](https://pypi.org/project/ThrustRTC/).
|
|
97
|
-
The [`Numba`](https://open-atmos.github.io/PySDM/PySDM/backends/numba.html) backend (aliased ``CPU``) features multi-threaded parallelism for
|
|
98
|
-
multi-core CPUs, it uses the just-in-time compilation technique based on the LLVM infrastructure.
|
|
99
|
-
The [`ThrustRTC`](https://open-atmos.github.io/PySDM/PySDM/backends/thrust_rtc.html) backend (aliased ``GPU``) offers GPU-resident operation of PySDM
|
|
100
|
-
leveraging the [SIMT](https://en.wikipedia.org/wiki/Single_instruction,_multiple_threads)
|
|
101
|
-
parallelisation model.
|
|
102
|
-
Using the ``GPU`` backend requires nVidia hardware and [CUDA driver](https://developer.nvidia.com/cuda-downloads).
|
|
103
|
-
|
|
104
|
-
For an overview of PySDM features (and the preferred way to cite PySDM in papers), please refer to our JOSS papers:
|
|
105
|
-
- [Bartman et al. 2022](https://doi.org/10.21105/joss.03219) (PySDM v1).
|
|
106
|
-
- [de Jong, Singer et al. 2023](https://doi.org/10.21105/joss.04968) (PySDM v2).
|
|
107
|
-
|
|
108
|
-
PySDM includes an extension of the SDM scheme to represent collisional breakup described in [de Jong, Mackay et al. 2023](10.5194/gmd-16-4193-2023).
|
|
109
|
-
For a list of talks and other materials on PySDM as well as a list of published papers featuring PySDM simulations, see the [project wiki](https://github.com/open-atmos/PySDM/wiki).
|
|
110
|
-
|
|
111
|
-
A [pdoc-generated](https://pdoc.dev/) documentation of PySDM public API is maintained at: [https://open-atmos.github.io/PySDM](https://open-atmos.github.io/PySDM)
|
|
112
|
-
|
|
113
|
-
## Example Jupyter notebooks (reproducing results from literature):
|
|
114
|
-
|
|
115
|
-
See [PySDM-examples README](https://github.com/open-atmos/PySDM/blob/main/examples/README.md).
|
|
116
|
-
|
|
117
|
-

|
|
118
|
-
|
|
119
|
-
## Dependencies and Installation
|
|
120
|
-
|
|
121
|
-
PySDM dependencies are: [Numpy](https://numpy.org/), [Numba](http://numba.pydata.org/), [SciPy](https://scipy.org/),
|
|
122
|
-
[Pint](https://pint.readthedocs.io/), [chempy](https://pypi.org/project/chempy/),
|
|
123
|
-
[pyevtk](https://pypi.org/project/pyevtk/),
|
|
124
|
-
[ThrustRTC](https://fynv.github.io/ThrustRTC/) and [CURandRTC](https://github.com/fynv/CURandRTC).
|
|
125
|
-
|
|
126
|
-
To install PySDM using ``pip``, use: ``pip install PySDM``
|
|
127
|
-
(or ``pip install git+https://github.com/open-atmos/PySDM.git`` to get updates
|
|
128
|
-
beyond the latest release).
|
|
129
|
-
|
|
130
|
-
Conda users may use ``pip`` as well, see the [Installing non-conda packages](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#installing-non-conda-packages) section in the conda docs. Dependencies of PySDM are available at the following conda channels:
|
|
131
|
-
- numba: [numba](https://anaconda.org/numba/numba)
|
|
132
|
-
- conda-forge: [pyevtk](https://anaconda.org/conda-forge/pyevtk), [pint](https://anaconda.org/conda-forge/pint) and []()
|
|
133
|
-
- fyplus: [ThrustRTC](https://anaconda.org/fyplus/thrustrtc), [CURandRTC](https://anaconda.org/fyplus/curandrtc)
|
|
134
|
-
- bjodah: [chempy](https://anaconda.org/bjodah/chempy)
|
|
135
|
-
- nvidia: [cudatoolkit](https://anaconda.org/nvidia/cudatoolkit)
|
|
136
|
-
|
|
137
|
-
For development purposes, we suggest cloning the repository and installing it using ``pip -e``.
|
|
138
|
-
Test-time dependencies can be installed with ``pip -e .[tests]``.
|
|
139
|
-
|
|
140
|
-
PySDM examples constitute the [``PySDM-examples``](https://github.com/open-atmos/PySDM-examples) package.
|
|
141
|
-
The examples have additional dependencies listed in [``PySDM_examples`` package ``setup.py``](https://github.com/open-atmos/PySDM/blob/main/examples/setup.py) file.
|
|
142
|
-
Running the example Jupyter notebooks requires the ``PySDM_examples`` package to be installed.
|
|
143
|
-
The suggested install and launch steps are:
|
|
144
|
-
```
|
|
145
|
-
git clone https://github.com/open-atmos/PySDM.git
|
|
146
|
-
pip install -e PySDM
|
|
147
|
-
pip install -e PySDM/examples
|
|
148
|
-
jupyter-notebook PySDM/examples/PySDM_examples
|
|
149
|
-
```
|
|
150
|
-
Alternatively, one can also install the examples package from pypi.org by
|
|
151
|
-
using ``pip install PySDM-examples`` (note that this does not apply to notebooks itself,
|
|
152
|
-
only the supporting .py files).
|
|
153
|
-
|
|
154
|
-
## Submodule organization
|
|
155
|
-
```mermaid
|
|
156
|
-
mindmap
|
|
157
|
-
root((PySDM))
|
|
158
|
-
Builder
|
|
159
|
-
Formulae
|
|
160
|
-
Particulator
|
|
161
|
-
((attributes))
|
|
162
|
-
(physics)
|
|
163
|
-
DryVolume: ExtensiveAttribute
|
|
164
|
-
Kappa: DerivedAttribute
|
|
165
|
-
...
|
|
166
|
-
(chemistry)
|
|
167
|
-
Acidity
|
|
168
|
-
...
|
|
169
|
-
(...)
|
|
170
|
-
((backends))
|
|
171
|
-
CPU
|
|
172
|
-
GPU
|
|
173
|
-
((dynamics))
|
|
174
|
-
AqueousChemistry
|
|
175
|
-
Collision
|
|
176
|
-
Condensation
|
|
177
|
-
...
|
|
178
|
-
((environments))
|
|
179
|
-
Box
|
|
180
|
-
Parcel
|
|
181
|
-
Kinematic2D
|
|
182
|
-
...
|
|
183
|
-
((initialisation))
|
|
184
|
-
(spectra)
|
|
185
|
-
Lognormal
|
|
186
|
-
Exponential
|
|
187
|
-
...
|
|
188
|
-
(sampling)
|
|
189
|
-
(spectral_sampling)
|
|
190
|
-
ConstantMultiplicity
|
|
191
|
-
UniformRandom
|
|
192
|
-
Logarithmic
|
|
193
|
-
...
|
|
194
|
-
(...)
|
|
195
|
-
(...)
|
|
196
|
-
((physics))
|
|
197
|
-
(hygroscopicity)
|
|
198
|
-
KappaKoehler
|
|
199
|
-
...
|
|
200
|
-
(condensation_coordinate)
|
|
201
|
-
Volume
|
|
202
|
-
VolumeLogarithm
|
|
203
|
-
(...)
|
|
204
|
-
((products))
|
|
205
|
-
(size_spectral)
|
|
206
|
-
EffectiveRadius
|
|
207
|
-
WaterMixingRatio
|
|
208
|
-
...
|
|
209
|
-
(ambient_thermodynamics)
|
|
210
|
-
AmbientRelativeHumidity
|
|
211
|
-
...
|
|
212
|
-
(...)
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Hello-world coalescence example in Python, Julia and Matlab
|
|
216
|
-
|
|
217
|
-
In order to depict the PySDM API with a practical example, the following
|
|
218
|
-
listings provide sample code roughly reproducing the
|
|
219
|
-
Figure 2 from [Shima et al. 2009 paper](http://doi.org/10.1002/qj.441)
|
|
220
|
-
using PySDM from Python, Julia and Matlab.
|
|
221
|
-
It is a [`Coalescence`](https://open-atmos.github.io/PySDM/PySDM/dynamics/collisions/sollision.html#Coalescence)-only set-up in which the initial particle size
|
|
222
|
-
spectrum is [`Exponential`](https://open-atmos.github.io/PySDM/PySDM/initialisation/spectra/exponential.html#Exponential) and is deterministically sampled to match
|
|
223
|
-
the condition of each super-droplet having equal initial multiplicity:
|
|
224
|
-
<details>
|
|
225
|
-
<summary>Julia (click to expand)</summary>
|
|
226
|
-
|
|
227
|
-
```Julia
|
|
228
|
-
using Pkg
|
|
229
|
-
Pkg.add("PyCall")
|
|
230
|
-
Pkg.add("Plots")
|
|
231
|
-
Pkg.add("PlotlyJS")
|
|
232
|
-
|
|
233
|
-
using PyCall
|
|
234
|
-
si = pyimport("PySDM.physics").si
|
|
235
|
-
ConstantMultiplicity = pyimport("PySDM.initialisation.sampling.spectral_sampling").ConstantMultiplicity
|
|
236
|
-
Exponential = pyimport("PySDM.initialisation.spectra").Exponential
|
|
237
|
-
|
|
238
|
-
n_sd = 2^15
|
|
239
|
-
initial_spectrum = Exponential(norm_factor=8.39e12, scale=1.19e5 * si.um^3)
|
|
240
|
-
attributes = Dict()
|
|
241
|
-
attributes["volume"], attributes["multiplicity"] = ConstantMultiplicity(spectrum=initial_spectrum).sample(n_sd)
|
|
242
|
-
```
|
|
243
|
-
</details>
|
|
244
|
-
<details>
|
|
245
|
-
<summary>Matlab (click to expand)</summary>
|
|
246
|
-
|
|
247
|
-
```Matlab
|
|
248
|
-
si = py.importlib.import_module('PySDM.physics').si;
|
|
249
|
-
ConstantMultiplicity = py.importlib.import_module('PySDM.initialisation.sampling.spectral_sampling').ConstantMultiplicity;
|
|
250
|
-
Exponential = py.importlib.import_module('PySDM.initialisation.spectra').Exponential;
|
|
251
|
-
|
|
252
|
-
n_sd = 2^15;
|
|
253
|
-
initial_spectrum = Exponential(pyargs(...
|
|
254
|
-
'norm_factor', 8.39e12, ...
|
|
255
|
-
'scale', 1.19e5 * si.um ^ 3 ...
|
|
256
|
-
));
|
|
257
|
-
tmp = ConstantMultiplicity(initial_spectrum).sample(int32(n_sd));
|
|
258
|
-
attributes = py.dict(pyargs('volume', tmp{1}, 'multiplicity', tmp{2}));
|
|
259
|
-
```
|
|
260
|
-
</details>
|
|
261
|
-
<details open>
|
|
262
|
-
<summary>Python (click to expand)</summary>
|
|
263
|
-
|
|
264
|
-
```Python
|
|
265
|
-
from PySDM.physics import si
|
|
266
|
-
from PySDM.initialisation.sampling.spectral_sampling import ConstantMultiplicity
|
|
267
|
-
from PySDM.initialisation.spectra.exponential import Exponential
|
|
268
|
-
|
|
269
|
-
n_sd = 2 ** 15
|
|
270
|
-
initial_spectrum = Exponential(norm_factor=8.39e12, scale=1.19e5 * si.um ** 3)
|
|
271
|
-
attributes = {}
|
|
272
|
-
attributes['volume'], attributes['multiplicity'] = ConstantMultiplicity(initial_spectrum).sample(n_sd)
|
|
273
|
-
```
|
|
274
|
-
</details>
|
|
275
|
-
|
|
276
|
-
The key element of the PySDM interface is the [``Particulator``](https://open-atmos.github.io/PySDM/PySDM/particulator.html#Particulator)
|
|
277
|
-
class instances of which are used to manage the system state and control the simulation.
|
|
278
|
-
Instantiation of the [``Particulator``](https://open-atmos.github.io/PySDM/PySDM/particulator.html#Particulator) class is handled by the [``Builder``](https://open-atmos.github.io/PySDM/PySDM/builder.html#Builder)
|
|
279
|
-
as exemplified below:
|
|
280
|
-
<details>
|
|
281
|
-
<summary>Julia (click to expand)</summary>
|
|
282
|
-
|
|
283
|
-
```Julia
|
|
284
|
-
Builder = pyimport("PySDM").Builder
|
|
285
|
-
Box = pyimport("PySDM.environments").Box
|
|
286
|
-
Coalescence = pyimport("PySDM.dynamics").Coalescence
|
|
287
|
-
Golovin = pyimport("PySDM.dynamics.collisions.collision_kernels").Golovin
|
|
288
|
-
CPU = pyimport("PySDM.backends").CPU
|
|
289
|
-
ParticleVolumeVersusRadiusLogarithmSpectrum = pyimport("PySDM.products").ParticleVolumeVersusRadiusLogarithmSpectrum
|
|
290
|
-
|
|
291
|
-
radius_bins_edges = 10 .^ range(log10(10*si.um), log10(5e3*si.um), length=32)
|
|
292
|
-
|
|
293
|
-
env = Box(dt=1 * si.s, dv=1e6 * si.m^3)
|
|
294
|
-
builder = Builder(n_sd=n_sd, backend=CPU(), environment=env)
|
|
295
|
-
builder.add_dynamic(Coalescence(collision_kernel=Golovin(b=1.5e3 / si.s)))
|
|
296
|
-
products = [ParticleVolumeVersusRadiusLogarithmSpectrum(radius_bins_edges=radius_bins_edges, name="dv/dlnr")]
|
|
297
|
-
particulator = builder.build(attributes, products)
|
|
298
|
-
```
|
|
299
|
-
</details>
|
|
300
|
-
<details>
|
|
301
|
-
<summary>Matlab (click to expand)</summary>
|
|
302
|
-
|
|
303
|
-
```Matlab
|
|
304
|
-
Builder = py.importlib.import_module('PySDM').Builder;
|
|
305
|
-
Box = py.importlib.import_module('PySDM.environments').Box;
|
|
306
|
-
Coalescence = py.importlib.import_module('PySDM.dynamics').Coalescence;
|
|
307
|
-
Golovin = py.importlib.import_module('PySDM.dynamics.collisions.collision_kernels').Golovin;
|
|
308
|
-
CPU = py.importlib.import_module('PySDM.backends').CPU;
|
|
309
|
-
ParticleVolumeVersusRadiusLogarithmSpectrum = py.importlib.import_module('PySDM.products').ParticleVolumeVersusRadiusLogarithmSpectrum;
|
|
310
|
-
|
|
311
|
-
radius_bins_edges = logspace(log10(10 * si.um), log10(5e3 * si.um), 32);
|
|
312
|
-
|
|
313
|
-
env = Box(pyargs('dt', 1 * si.s, 'dv', 1e6 * si.m ^ 3));
|
|
314
|
-
builder = Builder(pyargs('n_sd', int32(n_sd), 'backend', CPU(), 'environment', env));
|
|
315
|
-
builder.add_dynamic(Coalescence(pyargs('collision_kernel', Golovin(1.5e3 / si.s))));
|
|
316
|
-
products = py.list({ ParticleVolumeVersusRadiusLogarithmSpectrum(pyargs( ...
|
|
317
|
-
'radius_bins_edges', py.numpy.array(radius_bins_edges), ...
|
|
318
|
-
'name', 'dv/dlnr' ...
|
|
319
|
-
)) });
|
|
320
|
-
particulator = builder.build(attributes, products);
|
|
321
|
-
```
|
|
322
|
-
</details>
|
|
323
|
-
<details open>
|
|
324
|
-
<summary>Python (click to expand)</summary>
|
|
325
|
-
|
|
326
|
-
```Python
|
|
327
|
-
import numpy as np
|
|
328
|
-
from PySDM import Builder
|
|
329
|
-
from PySDM.environments import Box
|
|
330
|
-
from PySDM.dynamics import Coalescence
|
|
331
|
-
from PySDM.dynamics.collisions.collision_kernels import Golovin
|
|
332
|
-
from PySDM.backends import CPU
|
|
333
|
-
from PySDM.products import ParticleVolumeVersusRadiusLogarithmSpectrum
|
|
334
|
-
|
|
335
|
-
radius_bins_edges = np.logspace(np.log10(10 * si.um), np.log10(5e3 * si.um), num=32)
|
|
336
|
-
|
|
337
|
-
env = Box(dt=1 * si.s, dv=1e6 * si.m ** 3)
|
|
338
|
-
builder = Builder(n_sd=n_sd, backend=CPU(), environment=env)
|
|
339
|
-
builder.add_dynamic(Coalescence(collision_kernel=Golovin(b=1.5e3 / si.s)))
|
|
340
|
-
products = [ParticleVolumeVersusRadiusLogarithmSpectrum(radius_bins_edges=radius_bins_edges, name='dv/dlnr')]
|
|
341
|
-
particulator = builder.build(attributes, products)
|
|
342
|
-
```
|
|
343
|
-
</details>
|
|
344
|
-
|
|
345
|
-
The ``backend`` argument may be set to ``CPU`` or ``GPU``
|
|
346
|
-
what translates to choosing the multi-threaded backend or the
|
|
347
|
-
GPU-resident computation mode, respectively.
|
|
348
|
-
The employed [`Box`](https://open-atmos.github.io/PySDM/PySDM/environments/box.html#Box) environment corresponds to a zero-dimensional framework
|
|
349
|
-
(particle positions are not considered).
|
|
350
|
-
The vectors of particle multiplicities ``n`` and particle volumes ``v`` are
|
|
351
|
-
used to initialise super-droplet attributes.
|
|
352
|
-
The [`Coalescence`](https://open-atmos.github.io/PySDM/PySDM/dynamics/collisions/collision.html#Coalescence)
|
|
353
|
-
Monte-Carlo algorithm (Super Droplet Method) is registered as the only
|
|
354
|
-
dynamic in the system.
|
|
355
|
-
Finally, the [`build()`](https://open-atmos.github.io/PySDM/PySDM/builder.html#Builder.build) method is used to obtain an instance
|
|
356
|
-
of [`Particulator`](https://open-atmos.github.io/PySDM/PySDM/particulator.html#Particulator) which can then be used to control time-stepping and
|
|
357
|
-
access simulation state.
|
|
358
|
-
|
|
359
|
-
The [`run(nt)`](https://open-atmos.github.io/PySDM/PySDM/particulator.html#Particulator.run) method advances the simulation by ``nt`` timesteps.
|
|
360
|
-
In the listing below, its usage is interleaved with plotting logic
|
|
361
|
-
which displays a histogram of particle mass distribution
|
|
362
|
-
at selected timesteps:
|
|
363
|
-
<details>
|
|
364
|
-
<summary>Julia (click to expand)</summary>
|
|
365
|
-
|
|
366
|
-
```Julia
|
|
367
|
-
using Plots; plotlyjs()
|
|
368
|
-
|
|
369
|
-
for step = 0:1200:3600
|
|
370
|
-
particulator.run(step - particulator.n_steps)
|
|
371
|
-
plot!(
|
|
372
|
-
radius_bins_edges[1:end-1] / si.um,
|
|
373
|
-
particulator.formulae.particle_shape_and_density.volume_to_mass(
|
|
374
|
-
particulator.products["dv/dlnr"].get()[:]
|
|
375
|
-
)/ si.g,
|
|
376
|
-
linetype=:steppost,
|
|
377
|
-
xaxis=:log,
|
|
378
|
-
xlabel="particle radius [µm]",
|
|
379
|
-
ylabel="dm/dlnr [g/m^3/(unit dr/r)]",
|
|
380
|
-
label="t = $step s"
|
|
381
|
-
)
|
|
382
|
-
end
|
|
383
|
-
savefig("plot.svg")
|
|
384
|
-
```
|
|
385
|
-
</details>
|
|
386
|
-
<details>
|
|
387
|
-
<summary>Matlab (click to expand)</summary>
|
|
388
|
-
|
|
389
|
-
```Matlab
|
|
390
|
-
for step = 0:1200:3600
|
|
391
|
-
particulator.run(int32(step - particulator.n_steps));
|
|
392
|
-
x = radius_bins_edges / si.um;
|
|
393
|
-
y = particulator.formulae.particle_shape_and_density.volume_to_mass( ...
|
|
394
|
-
particulator.products{"dv/dlnr"}.get() ...
|
|
395
|
-
) / si.g;
|
|
396
|
-
stairs(...
|
|
397
|
-
x(1:end-1), ...
|
|
398
|
-
double(py.array.array('d',py.numpy.nditer(y))), ...
|
|
399
|
-
'DisplayName', sprintf("t = %d s", step) ...
|
|
400
|
-
);
|
|
401
|
-
hold on
|
|
402
|
-
end
|
|
403
|
-
hold off
|
|
404
|
-
set(gca,'XScale','log');
|
|
405
|
-
xlabel('particle radius [µm]')
|
|
406
|
-
ylabel("dm/dlnr [g/m^3/(unit dr/r)]")
|
|
407
|
-
legend()
|
|
408
|
-
```
|
|
409
|
-
</details>
|
|
410
|
-
<details open>
|
|
411
|
-
<summary>Python (click to expand)</summary>
|
|
412
|
-
|
|
413
|
-
```Python
|
|
414
|
-
from matplotlib import pyplot
|
|
415
|
-
|
|
416
|
-
for step in [0, 1200, 2400, 3600]:
|
|
417
|
-
particulator.run(step - particulator.n_steps)
|
|
418
|
-
pyplot.step(
|
|
419
|
-
x=radius_bins_edges[:-1] / si.um,
|
|
420
|
-
y=particulator.formulae.particle_shape_and_density.volume_to_mass(
|
|
421
|
-
particulator.products['dv/dlnr'].get()[0]
|
|
422
|
-
) / si.g,
|
|
423
|
-
where='post', label=f"t = {step}s"
|
|
424
|
-
)
|
|
425
|
-
|
|
426
|
-
pyplot.xscale('log')
|
|
427
|
-
pyplot.xlabel('particle radius [µm]')
|
|
428
|
-
pyplot.ylabel("dm/dlnr [g/m$^3$/(unit dr/r)]")
|
|
429
|
-
pyplot.legend()
|
|
430
|
-
pyplot.savefig('readme.png')
|
|
431
|
-
```
|
|
432
|
-
</details>
|
|
433
|
-
|
|
434
|
-
The resultant plot (generated with the Python code) looks as follows:
|
|
435
|
-
|
|
436
|
-

|
|
437
|
-
|
|
438
|
-
The component submodules used to create this simulation are visualized below:
|
|
439
|
-
```mermaid
|
|
440
|
-
graph
|
|
441
|
-
COAL[":Coalescence"] --->|passed as arg to| BUILDER_ADD_DYN(["Builder.add_dynamic()"])
|
|
442
|
-
BUILDER_INSTANCE["builder :Builder"] -...-|has a method| BUILDER_BUILD(["Builder.build()"])
|
|
443
|
-
ATTRIBUTES[attributes: dict] -->|passed as arg to| BUILDER_BUILD
|
|
444
|
-
N_SD["n_sd :int"] ---->|passed as arg to| BUILDER_INIT
|
|
445
|
-
BUILDER_INIT(["Builder.__init__()"]) --->|instantiates| BUILDER_INSTANCE
|
|
446
|
-
BUILDER_INSTANCE -..-|has a method| BUILDER_ADD_DYN(["Builder.add_dynamic()"])
|
|
447
|
-
ENV_INIT(["Box.__init__()"]) -->|instantiates| ENV
|
|
448
|
-
DT[dt :float] -->|passed as arg to| ENV_INIT
|
|
449
|
-
DV[dv :float] -->|passed as arg to| ENV_INIT
|
|
450
|
-
ENV[":Box"] -->|passed as arg to| BUILDER_INIT
|
|
451
|
-
B["b: float"] --->|passed as arg to| KERNEL_INIT(["Golovin.__init__()"])
|
|
452
|
-
KERNEL_INIT -->|instantiates| KERNEL
|
|
453
|
-
KERNEL[collision_kernel: Golovin] -->|passed as arg to| COAL_INIT(["Coalesncence.__init__()"])
|
|
454
|
-
COAL_INIT -->|instantiates| COAL
|
|
455
|
-
PRODUCTS[products: list] ----->|passed as arg to| BUILDER_BUILD
|
|
456
|
-
NORM_FACTOR[norm_factor: float]-->|passed as arg to| EXP_INIT
|
|
457
|
-
SCALE[scale: float]-->|passed as arg to| EXP_INIT
|
|
458
|
-
EXP_INIT(["Exponential.__init__()"]) -->|instantiates| IS
|
|
459
|
-
IS["initial_spectrum :Exponential"] -->|passed as arg to| CM_INIT
|
|
460
|
-
CM_INIT(["ConstantMultiplicity.__init__()"]) -->|instantiates| CM_INSTANCE
|
|
461
|
-
CM_INSTANCE[":ConstantMultiplicity"] -.-|has a method| SAMPLE
|
|
462
|
-
SAMPLE(["ConstantMultiplicity.sample()"]) -->|returns| n
|
|
463
|
-
SAMPLE -->|returns| volume
|
|
464
|
-
n -->|added as element of| ATTRIBUTES
|
|
465
|
-
PARTICULATOR_INSTANCE -.-|has a method| PARTICULATOR_RUN(["Particulator.run()"])
|
|
466
|
-
volume -->|added as element of| ATTRIBUTES
|
|
467
|
-
BUILDER_BUILD -->|returns| PARTICULATOR_INSTANCE["particulator :Particulator"]
|
|
468
|
-
PARTICULATOR_INSTANCE -.-|has a field| PARTICULATOR_PROD(["Particulator.products:dict"])
|
|
469
|
-
BACKEND_INSTANCE["backend :CPU"] ---->|passed as arg to| BUILDER_INIT
|
|
470
|
-
PRODUCTS -.-|accessible via| PARTICULATOR_PROD
|
|
471
|
-
NP_LOGSPACE(["np.logspace()"]) -->|returns| EDGES
|
|
472
|
-
EDGES[radius_bins_edges: np.ndarray] -->|passed as arg to| SPECTRUM_INIT
|
|
473
|
-
SPECTRUM_INIT["ParticleVolumeVersusRadiusLogarithmSpectrum.__init__()"] -->|instantiates| SPECTRUM
|
|
474
|
-
SPECTRUM[":ParticleVolumeVersusRadiusLogarithmSpectrum"] -->|added as element of| PRODUCTS
|
|
475
|
-
|
|
476
|
-
click COAL "https://open-atmos.github.io/PySDM/PySDM/dynamics/collisions/collision.html#Coalescence"
|
|
477
|
-
click BUILDER_INSTANCE "https://open-atmos.github.io/PySDM/PySDM/builder.html"
|
|
478
|
-
click BUILDER_INIT "https://open-atmos.github.io/PySDM/PySDM/builder.html"
|
|
479
|
-
click BUILDER_ADD_DYN "https://open-atmos.github.io/PySDM/PySDM/builder.html"
|
|
480
|
-
click ENV_INIT "https://open-atmos.github.io/PySDM/PySDM/environments.html"
|
|
481
|
-
click ENV "https://open-atmos.github.io/PySDM/PySDM/environments.html"
|
|
482
|
-
click KERNEL_INIT "https://open-atmos.github.io/PySDM/PySDM/dynamics/collisions/collision_kernels.html"
|
|
483
|
-
click KERNEL "https://open-atmos.github.io/PySDM/PySDM/dynamics/collisions/collision_kernels.html"
|
|
484
|
-
click EXP_INIT "https://open-atmos.github.io/PySDM/PySDM/initialisation/spectra.html"
|
|
485
|
-
click IS "https://open-atmos.github.io/PySDM/PySDM/initialisation/spectra.html"
|
|
486
|
-
click CM_INIT "https://open-atmos.github.io/PySDM/PySDM/initialisation/sampling/spectral_sampling.html"
|
|
487
|
-
click CM_INSTANCE "https://open-atmos.github.io/PySDM/PySDM/initialisation/sampling/spectral_sampling.html"
|
|
488
|
-
click SAMPLE "https://open-atmos.github.io/PySDM/PySDM/initialisation/sampling/spectral_sampling.html"
|
|
489
|
-
click PARTICULATOR_INSTANCE "https://open-atmos.github.io/PySDM/PySDM/particulator.html"
|
|
490
|
-
click BACKEND_INSTANCE "https://open-atmos.github.io/PySDM/PySDM/backends/numba.html"
|
|
491
|
-
click BUILDER_BUILD "https://open-atmos.github.io/PySDM/PySDM/builder.html"
|
|
492
|
-
click NP_LOGSPACE "https://numpy.org/doc/stable/reference/generated/numpy.logspace.html"
|
|
493
|
-
click SPECTRUM_INIT "https://open-atmos.github.io/PySDM/PySDM/products/size_spectral/particle_volume_versus_radius_logarithm_spectrum.html"
|
|
494
|
-
click SPECTRUM "https://open-atmos.github.io/PySDM/PySDM/products/size_spectral/particle_volume_versus_radius_logarithm_spectrum.html"
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
## Hello-world condensation example in Python, Julia and Matlab
|
|
498
|
-
|
|
499
|
-
In the following example, a condensation-only setup is used with the adiabatic
|
|
500
|
-
[`Parcel`](https://open-atmos.github.io/PySDM/PySDM/environments/parcel.html) environment.
|
|
501
|
-
An initial [`Lognormal`](https://open-atmos.github.io/PySDM/PySDM/initialisation/spectra/lognormal.html#Lognormal)
|
|
502
|
-
spectrum of dry aerosol particles is first initialised to equilibrium wet size for the given
|
|
503
|
-
initial humidity.
|
|
504
|
-
Subsequent particle growth due to [`Condensation`](https://open-atmos.github.io/PySDM/PySDM/dynamics/condensation.html) of water vapour (coupled with the release of latent heat)
|
|
505
|
-
causes a subset of particles to activate into cloud droplets.
|
|
506
|
-
Results of the simulation are plotted against vertical
|
|
507
|
-
[`ParcelDisplacement`](https://open-atmos.github.io/PySDM/PySDM/products/housekeeping/parcel_displacement.html)
|
|
508
|
-
and depict the evolution of
|
|
509
|
-
[`PeakSupersaturation`](https://open-atmos.github.io/PySDM/PySDM/products/condensation/peak_supersaturation.html),
|
|
510
|
-
[`EffectiveRadius`](https://open-atmos.github.io/PySDM/PySDM/products/size_spectral/effective_radius.html),
|
|
511
|
-
[`ParticleConcentration`](https://open-atmos.github.io/PySDM/PySDM/products/size_spectral/particle_concentration.html#ParticleConcentration)
|
|
512
|
-
and the
|
|
513
|
-
[`WaterMixingRatio `](https://open-atmos.github.io/PySDM/PySDM/products/size_spectral/water_mixing_ratio.html).
|
|
514
|
-
|
|
515
|
-
<details>
|
|
516
|
-
<summary>Julia (click to expand)</summary>
|
|
517
|
-
|
|
518
|
-
```Julia
|
|
519
|
-
using PyCall
|
|
520
|
-
using Plots; plotlyjs()
|
|
521
|
-
si = pyimport("PySDM.physics").si
|
|
522
|
-
spectral_sampling = pyimport("PySDM.initialisation.sampling").spectral_sampling
|
|
523
|
-
discretise_multiplicities = pyimport("PySDM.initialisation").discretise_multiplicities
|
|
524
|
-
Lognormal = pyimport("PySDM.initialisation.spectra").Lognormal
|
|
525
|
-
equilibrate_wet_radii = pyimport("PySDM.initialisation").equilibrate_wet_radii
|
|
526
|
-
CPU = pyimport("PySDM.backends").CPU
|
|
527
|
-
AmbientThermodynamics = pyimport("PySDM.dynamics").AmbientThermodynamics
|
|
528
|
-
Condensation = pyimport("PySDM.dynamics").Condensation
|
|
529
|
-
Parcel = pyimport("PySDM.environments").Parcel
|
|
530
|
-
Builder = pyimport("PySDM").Builder
|
|
531
|
-
Formulae = pyimport("PySDM").Formulae
|
|
532
|
-
products = pyimport("PySDM.products")
|
|
533
|
-
|
|
534
|
-
env = Parcel(
|
|
535
|
-
dt=.25 * si.s,
|
|
536
|
-
mass_of_dry_air=1e3 * si.kg,
|
|
537
|
-
p0=1122 * si.hPa,
|
|
538
|
-
initial_water_vapour_mixing_ratio=20 * si.g / si.kg,
|
|
539
|
-
T0=300 * si.K,
|
|
540
|
-
w= 2.5 * si.m / si.s
|
|
541
|
-
)
|
|
542
|
-
spectrum = Lognormal(norm_factor=1e4/si.mg, m_mode=50*si.nm, s_geom=1.4)
|
|
543
|
-
kappa = .5 * si.dimensionless
|
|
544
|
-
cloud_range = (.5 * si.um, 25 * si.um)
|
|
545
|
-
output_interval = 4
|
|
546
|
-
output_points = 40
|
|
547
|
-
n_sd = 256
|
|
548
|
-
|
|
549
|
-
formulae = Formulae()
|
|
550
|
-
builder = Builder(backend=CPU(formulae), n_sd=n_sd, environment=env)
|
|
551
|
-
builder.add_dynamic(AmbientThermodynamics())
|
|
552
|
-
builder.add_dynamic(Condensation())
|
|
553
|
-
|
|
554
|
-
r_dry, specific_concentration = spectral_sampling.Logarithmic(spectrum).sample(n_sd)
|
|
555
|
-
v_dry = formulae.trivia.volume(radius=r_dry)
|
|
556
|
-
r_wet = equilibrate_wet_radii(r_dry=r_dry, environment=builder.particulator.environment, kappa_times_dry_volume=kappa * v_dry)
|
|
557
|
-
|
|
558
|
-
attributes = Dict()
|
|
559
|
-
attributes["multiplicity"] = discretise_multiplicities(specific_concentration * env.mass_of_dry_air)
|
|
560
|
-
attributes["dry volume"] = v_dry
|
|
561
|
-
attributes["kappa times dry volume"] = kappa * v_dry
|
|
562
|
-
attributes["volume"] = formulae.trivia.volume(radius=r_wet)
|
|
563
|
-
|
|
564
|
-
particulator = builder.build(attributes, products=[
|
|
565
|
-
products.PeakSupersaturation(name="S_max", unit="%"),
|
|
566
|
-
products.EffectiveRadius(name="r_eff", unit="um", radius_range=cloud_range),
|
|
567
|
-
products.ParticleConcentration(name="n_c_cm3", unit="cm^-3", radius_range=cloud_range),
|
|
568
|
-
products.WaterMixingRatio(name="liquid water mixing ratio", unit="g/kg", radius_range=cloud_range),
|
|
569
|
-
products.ParcelDisplacement(name="z")
|
|
570
|
-
])
|
|
571
|
-
|
|
572
|
-
cell_id=1
|
|
573
|
-
output = Dict()
|
|
574
|
-
for (_, product) in particulator.products
|
|
575
|
-
output[product.name] = Array{Float32}(undef, output_points+1)
|
|
576
|
-
output[product.name][1] = product.get()[cell_id]
|
|
577
|
-
end
|
|
578
|
-
|
|
579
|
-
for step = 2:output_points+1
|
|
580
|
-
particulator.run(steps=output_interval)
|
|
581
|
-
for (_, product) in particulator.products
|
|
582
|
-
output[product.name][step] = product.get()[cell_id]
|
|
583
|
-
end
|
|
584
|
-
end
|
|
585
|
-
|
|
586
|
-
plots = []
|
|
587
|
-
ylbl = particulator.products["z"].unit
|
|
588
|
-
for (_, product) in particulator.products
|
|
589
|
-
if product.name != "z"
|
|
590
|
-
append!(plots, [plot(output[product.name], output["z"], ylabel=ylbl, xlabel=product.unit, title=product.name)])
|
|
591
|
-
end
|
|
592
|
-
global ylbl = ""
|
|
593
|
-
end
|
|
594
|
-
plot(plots..., layout=(1, length(output)-1))
|
|
595
|
-
savefig("parcel.svg")
|
|
596
|
-
```
|
|
597
|
-
</details>
|
|
598
|
-
<details>
|
|
599
|
-
<summary>Matlab (click to expand)</summary>
|
|
600
|
-
|
|
601
|
-
```Matlab
|
|
602
|
-
si = py.importlib.import_module('PySDM.physics').si;
|
|
603
|
-
spectral_sampling = py.importlib.import_module('PySDM.initialisation.sampling').spectral_sampling;
|
|
604
|
-
discretise_multiplicities = py.importlib.import_module('PySDM.initialisation').discretise_multiplicities;
|
|
605
|
-
Lognormal = py.importlib.import_module('PySDM.initialisation.spectra').Lognormal;
|
|
606
|
-
equilibrate_wet_radii = py.importlib.import_module('PySDM.initialisation').equilibrate_wet_radii;
|
|
607
|
-
CPU = py.importlib.import_module('PySDM.backends').CPU;
|
|
608
|
-
AmbientThermodynamics = py.importlib.import_module('PySDM.dynamics').AmbientThermodynamics;
|
|
609
|
-
Condensation = py.importlib.import_module('PySDM.dynamics').Condensation;
|
|
610
|
-
Parcel = py.importlib.import_module('PySDM.environments').Parcel;
|
|
611
|
-
Builder = py.importlib.import_module('PySDM').Builder;
|
|
612
|
-
Formulae = py.importlib.import_module('PySDM').Formulae;
|
|
613
|
-
products = py.importlib.import_module('PySDM.products');
|
|
614
|
-
|
|
615
|
-
env = Parcel(pyargs( ...
|
|
616
|
-
'dt', .25 * si.s, ...
|
|
617
|
-
'mass_of_dry_air', 1e3 * si.kg, ...
|
|
618
|
-
'p0', 1122 * si.hPa, ...
|
|
619
|
-
'initial_water_vapour_mixing_ratio', 20 * si.g / si.kg, ...
|
|
620
|
-
'T0', 300 * si.K, ...
|
|
621
|
-
'w', 2.5 * si.m / si.s ...
|
|
622
|
-
));
|
|
623
|
-
spectrum = Lognormal(pyargs('norm_factor', 1e4/si.mg, 'm_mode', 50 * si.nm, 's_geom', 1.4));
|
|
624
|
-
kappa = .5;
|
|
625
|
-
cloud_range = py.tuple({.5 * si.um, 25 * si.um});
|
|
626
|
-
output_interval = 4;
|
|
627
|
-
output_points = 40;
|
|
628
|
-
n_sd = 256;
|
|
629
|
-
|
|
630
|
-
formulae = Formulae();
|
|
631
|
-
builder = Builder(pyargs('backend', CPU(formulae), 'n_sd', int32(n_sd), 'environment', env));
|
|
632
|
-
builder.add_dynamic(AmbientThermodynamics());
|
|
633
|
-
builder.add_dynamic(Condensation());
|
|
634
|
-
|
|
635
|
-
tmp = spectral_sampling.Logarithmic(spectrum).sample(int32(n_sd));
|
|
636
|
-
r_dry = tmp{1};
|
|
637
|
-
v_dry = formulae.trivia.volume(pyargs('radius', r_dry));
|
|
638
|
-
specific_concentration = tmp{2};
|
|
639
|
-
r_wet = equilibrate_wet_radii(pyargs(...
|
|
640
|
-
'r_dry', r_dry, ...
|
|
641
|
-
'environment', builder.particulator.environment, ...
|
|
642
|
-
'kappa_times_dry_volume', kappa * v_dry...
|
|
643
|
-
));
|
|
644
|
-
|
|
645
|
-
attributes = py.dict(pyargs( ...
|
|
646
|
-
'multiplicity', discretise_multiplicities(specific_concentration * env.mass_of_dry_air), ...
|
|
647
|
-
'dry volume', v_dry, ...
|
|
648
|
-
'kappa times dry volume', kappa * v_dry, ...
|
|
649
|
-
'volume', formulae.trivia.volume(pyargs('radius', r_wet)) ...
|
|
650
|
-
));
|
|
651
|
-
|
|
652
|
-
particulator = builder.build(attributes, py.list({ ...
|
|
653
|
-
products.PeakSupersaturation(pyargs('name', 'S_max', 'unit', '%')), ...
|
|
654
|
-
products.EffectiveRadius(pyargs('name', 'r_eff', 'unit', 'um', 'radius_range', cloud_range)), ...
|
|
655
|
-
products.ParticleConcentration(pyargs('name', 'n_c_cm3', 'unit', 'cm^-3', 'radius_range', cloud_range)), ...
|
|
656
|
-
products.WaterMixingRatio(pyargs('name', 'liquid water mixing ratio', 'unit', 'g/kg', 'radius_range', cloud_range)) ...
|
|
657
|
-
products.ParcelDisplacement(pyargs('name', 'z')) ...
|
|
658
|
-
}));
|
|
659
|
-
|
|
660
|
-
cell_id = int32(0);
|
|
661
|
-
output_size = [output_points+1, length(py.list(particulator.products.keys()))];
|
|
662
|
-
output_types = repelem({'double'}, output_size(2));
|
|
663
|
-
output_names = [cellfun(@string, cell(py.list(particulator.products.keys())))];
|
|
664
|
-
output = table(...
|
|
665
|
-
'Size', output_size, ...
|
|
666
|
-
'VariableTypes', output_types, ...
|
|
667
|
-
'VariableNames', output_names ...
|
|
668
|
-
);
|
|
669
|
-
for pykey = py.list(keys(particulator.products))
|
|
670
|
-
get = py.getattr(particulator.products{pykey{1}}.get(), '__getitem__');
|
|
671
|
-
key = string(pykey{1});
|
|
672
|
-
output{1, key} = get(cell_id);
|
|
673
|
-
end
|
|
674
|
-
|
|
675
|
-
for i=2:output_points+1
|
|
676
|
-
particulator.run(pyargs('steps', int32(output_interval)));
|
|
677
|
-
for pykey = py.list(keys(particulator.products))
|
|
678
|
-
get = py.getattr(particulator.products{pykey{1}}.get(), '__getitem__');
|
|
679
|
-
key = string(pykey{1});
|
|
680
|
-
output{i, key} = get(cell_id);
|
|
681
|
-
end
|
|
682
|
-
end
|
|
683
|
-
|
|
684
|
-
i=1;
|
|
685
|
-
for pykey = py.list(keys(particulator.products))
|
|
686
|
-
product = particulator.products{pykey{1}};
|
|
687
|
-
if string(product.name) ~= "z"
|
|
688
|
-
subplot(1, width(output)-1, i);
|
|
689
|
-
plot(output{:, string(pykey{1})}, output.z, '-o');
|
|
690
|
-
title(string(product.name), 'Interpreter', 'none');
|
|
691
|
-
xlabel(string(product.unit));
|
|
692
|
-
end
|
|
693
|
-
if i == 1
|
|
694
|
-
ylabel(string(particulator.products{"z"}.unit));
|
|
695
|
-
end
|
|
696
|
-
i=i+1;
|
|
697
|
-
end
|
|
698
|
-
saveas(gcf, "parcel.png");
|
|
699
|
-
```
|
|
700
|
-
</details>
|
|
701
|
-
<details open>
|
|
702
|
-
<summary>Python (click to expand)</summary>
|
|
703
|
-
|
|
704
|
-
```Python
|
|
705
|
-
from matplotlib import pyplot
|
|
706
|
-
from PySDM.physics import si
|
|
707
|
-
from PySDM.initialisation import discretise_multiplicities, equilibrate_wet_radii
|
|
708
|
-
from PySDM.initialisation.spectra import Lognormal
|
|
709
|
-
from PySDM.initialisation.sampling import spectral_sampling
|
|
710
|
-
from PySDM.backends import CPU
|
|
711
|
-
from PySDM.dynamics import AmbientThermodynamics, Condensation
|
|
712
|
-
from PySDM.environments import Parcel
|
|
713
|
-
from PySDM import Builder, Formulae, products
|
|
714
|
-
|
|
715
|
-
env = Parcel(
|
|
716
|
-
dt=.25 * si.s,
|
|
717
|
-
mass_of_dry_air=1e3 * si.kg,
|
|
718
|
-
p0=1122 * si.hPa,
|
|
719
|
-
initial_water_vapour_mixing_ratio=20 * si.g / si.kg,
|
|
720
|
-
T0=300 * si.K,
|
|
721
|
-
w=2.5 * si.m / si.s
|
|
722
|
-
)
|
|
723
|
-
spectrum = Lognormal(norm_factor=1e4 / si.mg, m_mode=50 * si.nm, s_geom=1.5)
|
|
724
|
-
kappa = .5 * si.dimensionless
|
|
725
|
-
cloud_range = (.5 * si.um, 25 * si.um)
|
|
726
|
-
output_interval = 4
|
|
727
|
-
output_points = 40
|
|
728
|
-
n_sd = 256
|
|
729
|
-
|
|
730
|
-
formulae = Formulae()
|
|
731
|
-
builder = Builder(backend=CPU(formulae), n_sd=n_sd, environment=env)
|
|
732
|
-
builder.add_dynamic(AmbientThermodynamics())
|
|
733
|
-
builder.add_dynamic(Condensation())
|
|
734
|
-
|
|
735
|
-
r_dry, specific_concentration = spectral_sampling.Logarithmic(spectrum).sample(n_sd)
|
|
736
|
-
v_dry = formulae.trivia.volume(radius=r_dry)
|
|
737
|
-
r_wet = equilibrate_wet_radii(r_dry=r_dry, environment=builder.particulator.environment, kappa_times_dry_volume=kappa * v_dry)
|
|
738
|
-
|
|
739
|
-
attributes = {
|
|
740
|
-
'multiplicity': discretise_multiplicities(specific_concentration * env.mass_of_dry_air),
|
|
741
|
-
'dry volume': v_dry,
|
|
742
|
-
'kappa times dry volume': kappa * v_dry,
|
|
743
|
-
'volume': formulae.trivia.volume(radius=r_wet)
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
particulator = builder.build(attributes, products=[
|
|
747
|
-
products.PeakSupersaturation(name='S_max', unit='%'),
|
|
748
|
-
products.EffectiveRadius(name='r_eff', unit='um', radius_range=cloud_range),
|
|
749
|
-
products.ParticleConcentration(name='n_c_cm3', unit='cm^-3', radius_range=cloud_range),
|
|
750
|
-
products.WaterMixingRatio(name='liquid water mixing ratio', unit='g/kg', radius_range=cloud_range),
|
|
751
|
-
products.ParcelDisplacement(name='z')
|
|
752
|
-
])
|
|
753
|
-
|
|
754
|
-
cell_id = 0
|
|
755
|
-
output = {product.name: [product.get()[cell_id]] for product in particulator.products.values()}
|
|
756
|
-
|
|
757
|
-
for step in range(output_points):
|
|
758
|
-
particulator.run(steps=output_interval)
|
|
759
|
-
for product in particulator.products.values():
|
|
760
|
-
output[product.name].append(product.get()[cell_id])
|
|
761
|
-
|
|
762
|
-
fig, axs = pyplot.subplots(1, len(particulator.products) - 1, sharey="all")
|
|
763
|
-
for i, (key, product) in enumerate(particulator.products.items()):
|
|
764
|
-
if key != 'z':
|
|
765
|
-
axs[i].plot(output[key], output['z'], marker='.')
|
|
766
|
-
axs[i].set_title(product.name)
|
|
767
|
-
axs[i].set_xlabel(product.unit)
|
|
768
|
-
axs[i].grid()
|
|
769
|
-
axs[0].set_ylabel(particulator.products['z'].unit)
|
|
770
|
-
pyplot.savefig('parcel.svg')
|
|
771
|
-
```
|
|
772
|
-
</details>
|
|
773
|
-
|
|
774
|
-
The resultant plot (generated with the Matlab code) looks as follows:
|
|
775
|
-
|
|
776
|
-

|
|
777
|
-
|
|
778
|
-
## Contributing, reporting issues, seeking support
|
|
779
|
-
|
|
780
|
-
#### Our technologicial stack:
|
|
781
|
-
[](https://www.python.org/)
|
|
782
|
-
[](https://numba.pydata.org)
|
|
783
|
-
[](https://llvm.org)
|
|
784
|
-
[](https://pypi.org/project/ThrustRTC/)
|
|
785
|
-
[](https://numpy.org/)
|
|
786
|
-
[](https://pytest.org/)
|
|
787
|
-
[](https://colab.research.google.com/)
|
|
788
|
-
[](https://codecov.io/)
|
|
789
|
-
[](https://pypi.org/)
|
|
790
|
-
[](https://github.com/features/actions)
|
|
791
|
-
[](https://jupyter.org/)
|
|
792
|
-
[](https:///)
|
|
793
|
-
|
|
794
|
-
Submitting new code to the project, please preferably use [GitHub pull requests](https://github.com/open-atmos/PySDM/pulls) - it helps to keep record of code authorship,
|
|
795
|
-
track and archive the code review workflow and allows to benefit
|
|
796
|
-
from the continuous integration setup which automates execution of tests
|
|
797
|
-
with the newly added code.
|
|
798
|
-
|
|
799
|
-
Code contributions are assumed to imply transfer of copyright.
|
|
800
|
-
Should there be a need to make an exception, please indicate it when creating
|
|
801
|
-
a pull request or contributing code in any other way. In any case,
|
|
802
|
-
the license of the contributed code must be compatible with GPL v3.
|
|
803
|
-
|
|
804
|
-
Developing the code, we follow [The Way of Python](https://www.python.org/dev/peps/pep-0020/) and
|
|
805
|
-
the [KISS principle](https://en.wikipedia.org/wiki/KISS_principle).
|
|
806
|
-
The codebase has greatly benefited from [PyCharm code inspections](https://www.jetbrains.com/help/pycharm/code-inspection.html)
|
|
807
|
-
and [Pylint](https://pylint.org), [Black](https://black.readthedocs.io/en/stable/) and [isort](https://pycqa.github.io/isort/)
|
|
808
|
-
code analysis (which are all part of the CI workflows).
|
|
809
|
-
|
|
810
|
-
We also use [pre-commit hooks](https://pre-commit.com).
|
|
811
|
-
In our case, the hooks modify files and re-format them.
|
|
812
|
-
The pre-commit hooks can be run locally, and then the resultant changes need to be staged before committing.
|
|
813
|
-
To set up the hooks locally, install pre-commit via `pip install pre-commit` and
|
|
814
|
-
set up the git hooks via `pre-commit install` (this needs to be done every time you clone the project).
|
|
815
|
-
To run all pre-commit hooks, run `pre-commit run --all-files`.
|
|
816
|
-
The `.pre-commit-config.yaml` file can be modified in case new hooks are to be added or
|
|
817
|
-
existing ones need to be altered.
|
|
818
|
-
|
|
819
|
-
Further hints addressed at PySDM developers are maintained in the [open-atmos/python-dev-hints Wiki](https://github.com/open-atmos/python-dev-hints/wiki).
|
|
820
|
-
|
|
821
|
-
Issues regarding any incorrect, unintuitive or undocumented bahaviour of
|
|
822
|
-
PySDM are best to be reported on the [GitHub issue tracker](https://github.com/open-atmos/PySDM/issues/new).
|
|
823
|
-
Feature requests are recorded in the "Ideas..." [PySDM wiki page](https://github.com/open-atmos/PySDM/wiki/Ideas-for-new-features-and-examples).
|
|
824
|
-
|
|
825
|
-
We encourage to use the [GitHub Discussions](https://github.com/open-atmos/PySDM/discussions) feature
|
|
826
|
-
(rather than the issue tracker) for seeking support in understanding, using and extending PySDM code.
|
|
827
|
-
|
|
828
|
-
We look forward to your contributions and feedback.
|
|
829
|
-
|
|
830
|
-
## Credits:
|
|
831
|
-
|
|
832
|
-
The development and maintenance of PySDM is led by [Sylwester Arabas](https://github.com/slayoo/).
|
|
833
|
-
[Piotr Bartman](https://github.com/piotrbartman/) had been the architect and main developer
|
|
834
|
-
of technological solutions in PySDM.
|
|
835
|
-
PySDM includes contributions from researchers
|
|
836
|
-
from [Jagiellonian University](https://en.uj.edu.pl/en) departments of computer science, physics and chemistry;
|
|
837
|
-
from [Caltech's Climate Modelling Alliance](https://clima.caltech.edu/),
|
|
838
|
-
from [University of Warsaw](https://en.uw.edu.pl/) (dept. physics), and
|
|
839
|
-
from [AGH University of Krakow](https://agh.edu.pl/en) (dept. physics \& applied computer science) where release maintenance takes place currently.
|
|
840
|
-
|
|
841
|
-
Development of PySDM had been initially supported by the EU through a grant of the
|
|
842
|
-
[Foundation for Polish Science](https://www.fnp.org.pl/)) (grant no. POIR.04.04.00-00-5E1C/18)
|
|
843
|
-
realised at the [Jagiellonian University](https://en.uj.edu.pl/en).
|
|
844
|
-
The immersion freezing support in PySDM was developed with support from the
|
|
845
|
-
US Department of Energy [Atmospheric System Research](https://asr.science.energy.gov/) programme
|
|
846
|
-
through a grant (no. DE-SC0021034) realised at the
|
|
847
|
-
[University of Illinois at Urbana-Champaign](https://illinois.edu/).
|
|
848
|
-
Development of isotopic fractionation representation and mixed-phase support is carried out with support from
|
|
849
|
-
the [Polish National Science Centre](https://ncn.gov.pl/en) (grant no. 2020/39/D/ST10/01220).
|
|
850
|
-
|
|
851
|
-
copyright: [Jagiellonian University](https://en.uj.edu.pl/en) (2019-2023) & [AGH University of Krakow](https://agh.edu.pl/en) (2023-...)
|
|
852
|
-
licence: [GPL v3](https://www.gnu.org/licenses/gpl-3.0.html)
|
|
853
|
-
|
|
854
|
-
## Related resources and open-source projects
|
|
855
|
-
|
|
856
|
-
### SDM patents (some expired, some withdrawn):
|
|
857
|
-
- https://patents.google.com/patent/US7756693B2
|
|
858
|
-
- https://patents.google.com/patent/EP1847939A3
|
|
859
|
-
- https://patents.google.com/patent/JP4742387B2
|
|
860
|
-
- https://patents.google.com/patent/CN101059821B
|
|
861
|
-
|
|
862
|
-
### Other SDM implementations:
|
|
863
|
-
- SCALE-SDM (Fortran):
|
|
864
|
-
https://github.com/Shima-Lab/SCALE-SDM_BOMEX_Sato2018/blob/master/contrib/SDM/sdm_coalescence.f90
|
|
865
|
-
- Pencil Code (Fortran):
|
|
866
|
-
https://github.com/pencil-code/pencil-code/blob/master/src/particles_coagulation.f90
|
|
867
|
-
- PALM LES (Fortran):
|
|
868
|
-
https://palm.muk.uni-hannover.de/trac/browser/palm/trunk/SOURCE/lagrangian_particle_model_mod.f90
|
|
869
|
-
- libcloudph++ (C++):
|
|
870
|
-
https://github.com/igfuw/libcloudphxx/blob/master/src/impl/particles_impl_coal.ipp
|
|
871
|
-
- LCM1D (Python)
|
|
872
|
-
https://github.com/SimonUnterstrasser/ColumnModel
|
|
873
|
-
- superdroplet (Cython/Numba/C++11/Fortran 2008/Julia)
|
|
874
|
-
https://github.com/darothen/superdroplet
|
|
875
|
-
- NTLP (FORTRAN)
|
|
876
|
-
https://github.com/Folca/NTLP/blob/SuperDroplet/les.F
|
|
877
|
-
- CLEO (C++)
|
|
878
|
-
https://yoctoyotta1024.github.io/CLEO/
|
|
879
|
-
- droplets.jl (Julia)
|
|
880
|
-
https://github.com/emmacware/droplets.jl
|
|
881
|
-
- LacmoPy (Python/Numba)
|
|
882
|
-
https://github.com/JanKBohrer/LacmoPy/blob/master/collision/all_or_nothing.py
|
|
883
|
-
- McSnow (FORTRAN):
|
|
884
|
-
https://gitlab.dkrz.de/mcsnow/mcsnow/-/blob/master/src/mo_coll.f90
|
|
885
|
-
|
|
886
|
-
### non-SDM probabilistic particle-based coagulation solvers
|
|
887
|
-
|
|
888
|
-
- PartMC (Fortran):
|
|
889
|
-
https://github.com/compdyn/partmc
|
|
890
|
-
|
|
891
|
-
### Python models with discrete-particle (moving-sectional) representation of particle size spectrum
|
|
892
|
-
|
|
893
|
-
- pyrcel: https://github.com/darothen/pyrcel
|
|
894
|
-
- PyBox: https://github.com/loftytopping/PyBox
|
|
895
|
-
- py-cloud-parcel-model: https://github.com/emmasimp/py-cloud-parcel-model
|
|
896
|
-
|
|
897
|
-
### non-Python cloud microphysics open-source software
|
|
898
|
-
|
|
899
|
-
- CloudMicrophysics.jl: https://github.com/CliMA/CloudMicrophysics.jl
|
|
900
|
-
- McSnow: https://gitlab.dkrz.de/mcsnow/mcsnow
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
File without changes
|
|
File without changes
|