Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/bibliography.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,14 @@
"title": "A short course in clouds physics",
"label": "Rogers & Yau 1989 (Pergamon Press)"
},
"https://doi.org/10.1080/00046973.1975.9648397": {
"usages": [
"examples/PySDM_examples/Rogers_1975/__init__.py",
"examples/PySDM_examples/Rogers_1975/fig_1.ipynb"
],
"title": "An Elementary Parcel Model with Explicit Condensation and Supersaturation",
"label": "Rogers 1975"
},
"https://doi.org/10.1016/b978-0-444-42225-5.50007-3": {
"usages": ["PySDM/physics/constants_defaults.py"],
"title": "Isotopes in cloud physics: Multiphase and multistage condensation process",
Expand Down
9 changes: 9 additions & 0 deletions examples/PySDM_examples/Rogers_1975/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
based on Rogers 1975 (Atmosphere)
https://doi.org/10.1080/00046973.1975.9648397

fig_1.ipynb:
.. include:: ./fig_1.ipynb.badges.md
"""

# pylint: disable=invalid-name
403 changes: 403 additions & 0 deletions examples/PySDM_examples/Rogers_1975/fig_1.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/examples_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def findfiles(path, regex):
"Grabowski_and_Pawlowska_2023",
"Jensen_and_Nugent_2017",
"Abade_and_Albuquerque_2024",
"Rogers_1975",
],
"coagulation": ["Berry_1967", "Shima_et_al_2009"],
"breakup": ["Bieli_et_al_2022", "deJong_Mackay_et_al_2023", "Srivastava_1982"],
Expand Down
59 changes: 59 additions & 0 deletions tests/smoke_tests/parcel_d/rogers_1975/test_fig_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""test values on the plot against paper"""

from pathlib import Path

import numpy as np
import pytest

from open_atmos_jupyter_utils import notebook_vars
from PySDM_examples import Rogers_1975
from PySDM.physics.constants import PER_CENT


@pytest.fixture(scope="session", name="variables")
def variables_fixture():
return notebook_vars(
file=Path(Rogers_1975.__file__).parent / "fig_1.ipynb", plot=False
)


class TestFig1:
@staticmethod
def test_fig1_saturation_peak_against_paper(variables):
# arrange
SS = variables["solution"].S - 1
time = variables["tsteps"]
expected_peak_time = 7
expected_peak_value = 0.97 * PER_CENT

# act
peak_value = np.max(SS)
peak_time = time[np.argmax(SS)]

# assert
np.testing.assert_allclose(
actual=peak_value.magnitude, desired=expected_peak_value, rtol=1e-3
)
np.testing.assert_allclose(
actual=peak_time.magnitude, desired=expected_peak_time, atol=0.5
)

@staticmethod
def test_fig1_radius_scope(variables):
"""
Check if for first 2.5 seconds slope is smaller than after this time.
It represents slower droplets growth with small supersaturation.
"""
# arrange
radius = variables["solution"].r
time_less_than = np.sum(variables["tsteps"].to_base_units().magnitude <= 2.5)
dr_before = np.diff(radius[:time_less_than]).to_base_units().magnitude
dr_after = np.diff(radius[time_less_than:]).to_base_units().magnitude

# act
sut = np.mean(dr_before) / np.mean(dr_after)

# assert
assert sut < 1
assert sut > 0
assert (dr_before > 0).all()
Loading