Skip to content

Commit 8e75c71

Browse files
new example: R.R. Rogers 1975 (Atmosphere 13(4)) fig 1 (parcel model using SciPy+Pint, without PySDM) (#1441)
Co-authored-by: AgnieszkaZaba <56157996+AgnieszkaZaba@users.noreply.github.com> Co-authored-by: Agnieszka Żaba <azaba@agh.edu.pl>
1 parent 44a9b05 commit 8e75c71

File tree

5 files changed

+480
-0
lines changed

5 files changed

+480
-0
lines changed

docs/bibliography.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,14 @@
739739
"title": "A short course in clouds physics",
740740
"label": "Rogers & Yau 1989 (Pergamon Press)"
741741
},
742+
"https://doi.org/10.1080/00046973.1975.9648397": {
743+
"usages": [
744+
"examples/PySDM_examples/Rogers_1975/__init__.py",
745+
"examples/PySDM_examples/Rogers_1975/fig_1.ipynb"
746+
],
747+
"title": "An Elementary Parcel Model with Explicit Condensation and Supersaturation",
748+
"label": "Rogers 1975"
749+
},
742750
"https://doi.org/10.1016/b978-0-444-42225-5.50007-3": {
743751
"usages": ["PySDM/physics/constants_defaults.py"],
744752
"title": "Isotopes in cloud physics: Multiphase and multistage condensation process",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
based on Rogers 1975 (Atmosphere)
3+
https://doi.org/10.1080/00046973.1975.9648397
4+
5+
fig_1.ipynb:
6+
.. include:: ./fig_1.ipynb.badges.md
7+
"""
8+
9+
# pylint: disable=invalid-name

examples/PySDM_examples/Rogers_1975/fig_1.ipynb

Lines changed: 403 additions & 0 deletions
Large diffs are not rendered by default.

tests/examples_tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def findfiles(path, regex):
5757
"Grabowski_and_Pawlowska_2023",
5858
"Jensen_and_Nugent_2017",
5959
"Abade_and_Albuquerque_2024",
60+
"Rogers_1975",
6061
],
6162
"coagulation": ["Berry_1967", "Shima_et_al_2009"],
6263
"breakup": ["Bieli_et_al_2022", "deJong_Mackay_et_al_2023", "Srivastava_1982"],
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""test values on the plot against paper"""
2+
3+
from pathlib import Path
4+
5+
import numpy as np
6+
import pytest
7+
8+
from open_atmos_jupyter_utils import notebook_vars
9+
from PySDM_examples import Rogers_1975
10+
from PySDM.physics.constants import PER_CENT
11+
12+
13+
@pytest.fixture(scope="session", name="variables")
14+
def variables_fixture():
15+
return notebook_vars(
16+
file=Path(Rogers_1975.__file__).parent / "fig_1.ipynb", plot=False
17+
)
18+
19+
20+
class TestFig1:
21+
@staticmethod
22+
def test_fig1_saturation_peak_against_paper(variables):
23+
# arrange
24+
SS = variables["solution"].S - 1
25+
time = variables["tsteps"]
26+
expected_peak_time = 7
27+
expected_peak_value = 0.97 * PER_CENT
28+
29+
# act
30+
peak_value = np.max(SS)
31+
peak_time = time[np.argmax(SS)]
32+
33+
# assert
34+
np.testing.assert_allclose(
35+
actual=peak_value.magnitude, desired=expected_peak_value, rtol=1e-3
36+
)
37+
np.testing.assert_allclose(
38+
actual=peak_time.magnitude, desired=expected_peak_time, atol=0.5
39+
)
40+
41+
@staticmethod
42+
def test_fig1_radius_scope(variables):
43+
"""
44+
Check if for first 2.5 seconds slope is smaller than after this time.
45+
It represents slower droplets growth with small supersaturation.
46+
"""
47+
# arrange
48+
radius = variables["solution"].r
49+
time_less_than = np.sum(variables["tsteps"].to_base_units().magnitude <= 2.5)
50+
dr_before = np.diff(radius[:time_less_than]).to_base_units().magnitude
51+
dr_after = np.diff(radius[time_less_than:]).to_base_units().magnitude
52+
53+
# act
54+
sut = np.mean(dr_before) / np.mean(dr_after)
55+
56+
# assert
57+
assert sut < 1
58+
assert sut > 0
59+
assert (dr_before > 0).all()

0 commit comments

Comments
 (0)