Skip to content

Commit e401d7e

Browse files
slayooCaastlefoxCastlefox
authoredJan 29, 2025··
new example: buoyant-bubble with a Boussinesq system (velocity extrapolation in time + pressure solver) (AGH eng. project by Michał Kowalczyk @Caastlefox) (#495)
Co-authored-by: Caastlefox <[email protected]> Co-authored-by: Castlefox <[email protected]>
1 parent ddecbf2 commit e401d7e

File tree

10 files changed

+839
-12
lines changed

10 files changed

+839
-12
lines changed
 

‎.github/workflows/tests.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ jobs:
126126
- run: |
127127
python -m pip install $PIP_INSTALL_ARGS -e . # to check if usable without test/example dependencies
128128
python -We -c "import PyMPDATA"
129-
python -m pip install $PIP_INSTALL_ARGS -e .[tests] ./examples
129+
python -m pip install $PIP_INSTALL_ARGS -e .[tests] -e ./examples
130130
131131
# https://github.com/numba/numba/issues/6350#issuecomment-728174860
132132
- if: startsWith(matrix.platform, 'ubuntu-')
@@ -161,7 +161,7 @@ jobs:
161161
with:
162162
python-version: ${{ matrix.python-version }}
163163

164-
- run: python -m pip install $PIP_INSTALL_ARGS -e .[tests] ./examples
164+
- run: python -m pip install $PIP_INSTALL_ARGS -e .[tests] -e ./examples
165165
- run: python -m pip install $PIP_INSTALL_ARGS -r tests/devops_tests/requirements.txt
166166
- if: matrix.platform == 'ubuntu-latest'
167167
run: |
@@ -189,6 +189,7 @@ jobs:
189189
run: |
190190
mkdir -p /home/runner/work/_temp/_github_home/figures
191191
rm /tmp/pytest-of-runner/pytest-current/test_run_notebooks_examples_Pycurrent
192+
mv /tmp/pytest-of-runner/pytest-current/test_run_notebooks_examples_*/boussinesq_2d_anim.gif /home/runner/work/_temp/_github_home/figures
192193
mv /tmp/pytest-of-runner/pytest-current/test_run_notebooks_examples_*/fig_4.svg /home/runner/work/_temp/_github_home/figures
193194
mv /tmp/pytest-of-runner/pytest-current/test_run_notebooks_examples_*/advection_diffusion.gif /home/runner/work/_temp/_github_home/figures
194195

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ cython_debug/
157157
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160-
.idea/
160+
.idea/

‎.zenodo.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@
2525
"name": "Drenda, Szymon"
2626
},
2727
{
28-
"affiliation": "Jagiellonian University, Kraków, Poland",
29-
"name": "Manna, Maciej"
30-
},
31-
{
32-
"affiliation": "Jagiellonian University, Kraków, Poland",
33-
"name": "Olesik, Michael",
34-
"orcid": "0000-0002-6319-9358"
28+
"affiliation": "AGH University of Krakow, Poland",
29+
"name": "Michał Kowalczyk"
3530
},
3631
{
3732
"affiliation": "AGH University of Krakow, Poland",
@@ -42,6 +37,11 @@
4237
"affiliation": "Jagiellonian University, Kraków, Poland",
4338
"name": "Manna, Maciej"
4439
},
40+
{
41+
"affiliation": "Jagiellonian University, Kraków, Poland",
42+
"name": "Olesik, Michael",
43+
"orcid": "0000-0002-6319-9358"
44+
},
4545
{
4646
"affiliation": "Jagiellonian University, Kraków, Poland",
4747
"name": "Rozwoda, Paweł"

‎docs/bibliography.json

+20-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"https://doi.org/10.1006/jcph.1998.5901": {
4040
"usages": [
4141
"README.md",
42-
"docs/markdown/pympdata_landing.md"
42+
"docs/markdown/pympdata_landing.md",
43+
"examples/PyMPDATA_examples/Jaruga_et_al_2015/fig19.ipynb"
4344
],
4445
"label": "Smolarkiewicz & Margolin 1998 (J. Comp. Phys. 140)",
4546
"title": "MPDATA: A Finite-Difference Solver for Geophysical Flows"
@@ -112,7 +113,9 @@
112113
"usages": [
113114
"docs/markdown/pympdata_landing.md",
114115
"examples/PyMPDATA_examples/Molenkamp_test_as_in_Jaruga_et_al_2015_Fig_12/demo.ipynb",
115-
"examples/PyMPDATA_examples/Molenkamp_test_as_in_Jaruga_et_al_2015_Fig_12/__init__.py"
116+
"examples/PyMPDATA_examples/Molenkamp_test_as_in_Jaruga_et_al_2015_Fig_12/__init__.py",
117+
"tests/smoke_tests/jaruga_et_al_2015/test_boussinesq.py",
118+
"examples/PyMPDATA_examples/Jaruga_et_al_2015/fig19.ipynb"
116119
],
117120
"label": "Jaruga et al. 2015 (Geosci. Model Dev. 8)",
118121
"title": "libmpdata++ 1.0: a library of parallel MPDATA solvers for systems of generalised transport equations "
@@ -153,5 +156,20 @@
153156
],
154157
"label": "Molenkamp 1968 (J. Appl. Meteorol. Climatol. 7)",
155158
"title": "Accuracy of Finite-Difference Methods Applied to the Advection Equation"
159+
},
160+
"https://osti.gov/biblio/785403": {
161+
"usages": [
162+
"examples/PyMPDATA_examples/Jaruga_et_al_2015/fig19.ipynb"
163+
],
164+
"label": "Smolarkiewicz & Margolin 2000 (LANL report)",
165+
"title": "Variational methods for elliptic problems in fluid models"
166+
},
167+
"https://doi.org/10.1175/1520-0469(1992)049%3C2082:ACOSLA%3E2.0.CO;2": {
168+
"usages": [
169+
"examples/PyMPDATA_examples/Jaruga_et_al_2015/fig19.ipynb",
170+
"tests/smoke_tests/jaruga_et_al_2015/test_boussinesq.py"
171+
],
172+
"label": "Smolarkiewicz and Pudykiewicz 1992 (J. Atmos. Sci. 49)",
173+
"title": "A Class of Semi-Lagrangian Approximations for Fluids"
156174
}
157175
}

‎docs/templates/index.html.jinja2

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<h2>What is PyMPDATA?</h2>
3434
<p>
3535
<img align="right" src="https://github.com/open-atmos/PyMPDATA-MPI/releases/download/latest-generated-plots/n_iters.3_rank_0_size_1_c_field_.0.5.0.25._mpi_dim_0_n_threads_3-CartesianScenario-anim.gif">
36+
<img align="right" src="https://github.com/open-atmos/PyMPDATA/releases/download/tip/boussinesq_2d_anim.gif">
3637
PyMPDATA is a <b><a href="https://numba.pydata.org">Numba-accelerated</a></b> <mark>multi-threaded</mark> Pythonic implementation of the
3738
<b>MPDATA algorithm</b> of <a href="https://doi.org/10.1016/0021-9991(84)90121-9">Smolarkiewicz et al.</a> used in
3839
<mark>geophysical fluid dynamics</mark> and beyond for

‎examples/PyMPDATA_examples/Jaruga_et_al_2015/__init__.py

Whitespace-only changes.

‎examples/PyMPDATA_examples/Jaruga_et_al_2015/fig19.ipynb

+746
Large diffs are not rendered by default.

‎examples/docs/pympdata_examples_landing.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The examples are grouped by the dimensionality of the computational grid.
2424
## in 2D
2525
| tags | link |
2626
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
27+
| <mark>Boussinesq equations</mark> for buoyancy-driven flows<br/>$$\begin{eqnarray} \partial_t v+\mathrm{\nabla}\cdot\left(\vec{v}\otimes \vec{v}\right)=-\nabla\pi-\vec{g}\frac{\theta^\prime}{\theta_0}~ \\\ \partial_t \theta+ \nabla\cdot\left(\vec{v}\theta\right)=0~ \\\ \nabla\cdot\ \vec{v}=0$$ | `PyMPDATA_examples.Jaruga_et_al_2015`<br/><img src="https://github.com/open-atmos/PyMPDATA/releases/download/tip/boussinesq_2d_anim.gif" width="50%" alt="boussinesq-2d"> |
2728
| <mark>advection-diffusion equation</mark><br/>$$ \partial_t (\psi) + \nabla \cdot (u \psi) + \mu \Delta (\psi) = 0 $$ | `PyMPDATA_examples.advection_diffusion_2d`*<br/><img src="https://github.com/open-atmos/PyMPDATA/releases/download/tip/advection_diffusion.gif" width="50%" alt="adv-diff"> |
2829
| <mark>Spectral-spatial advection</mark>, particle population condensational growth in a vertical column of air, time dependent flow | `PyMPDATA_examples.Shipway_and_Hill_2012`<br/><img src="https://github.com/open-atmos/PyMPDATA/wiki/files/KiD-1D_PyMPDATA_n_iters=3.gif" width="50%" alt="spectral-spatial"> |
2930
| <mark>shallow-water equations</mark><br/>$$\begin{eqnarray} \partial_t h + \partial_x (uh) + \partial_y (vh) &=& 0~ \\\ \partial_t (uh) + \partial_x ( uuh) + \partial_y (vuh) &=& - h \partial_x h~ \\\ \partial_t (vh) + \partial_x ( uvh) + \partial_y (vvh) &=& - h \partial_y h~ \end{eqnarray}$$ | `PyMPDATA_examples.Jarecka_et_al_2015`* |

‎setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ def get_long_description():
7979
),
8080
"jupyter-core" + ("<5.0.0" if CI else ""),
8181
"ipywidgets" + ("!=8.0.3" if CI else ""),
82+
"ipykernel" + ("<6.22.0" if CI else ""),
8283
"ghapi",
8384
"pytest",
8485
"pytest-benchmark",
8586
"joblib" + ("==1.4.0" if CI else ""),
8687
"imageio",
88+
"nbformat",
8789
]
8890
},
8991
author="https://github.com/open-atmos/PyMPDATA/graphs/contributors",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
""" tests for buoyant-bubble test case from Fig. 3 in [Smolarkiewicz & Pudykiewicz
2+
1992](https://doi.org/10.1175/1520-0469(1992)049%3C2082:ACOSLA%3E2.0.CO;2),
3+
as in libmpdata++ paper ([Jaruga et al. 2015](https://doi.org/10.5194/gmd-8-1005-2015), Fig. 19)"""
4+
5+
# pylint: disable=missing-class-docstring,missing-function-docstring
6+
7+
from pathlib import Path
8+
9+
import numpy as np
10+
import pytest
11+
from open_atmos_jupyter_utils import notebook_vars
12+
from PyMPDATA_examples import Jaruga_et_al_2015
13+
14+
PLOT = False
15+
16+
17+
@pytest.fixture(scope="session", name="variables")
18+
def variables_fixture():
19+
return notebook_vars(
20+
file=Path(Jaruga_et_al_2015.__file__).parent / "fig19.ipynb",
21+
plot=PLOT,
22+
)
23+
24+
25+
class TestFig19:
26+
@staticmethod
27+
def test_maximal_theta(variables):
28+
max_at_t0 = variables["SETUP"].Tht_ref + variables["SETUP"].Tht_dlt
29+
acceptable_overshoot = 1e-4
30+
assert (
31+
max_at_t0 < np.amax(variables["output"]) < max_at_t0 + acceptable_overshoot
32+
)
33+
34+
@staticmethod
35+
def test_minimal_theta(variables):
36+
min_at_t0 = variables["SETUP"].Tht_ref
37+
acceptable_undershoot = 5e-3
38+
assert (
39+
min_at_t0 - acceptable_undershoot < np.amin(variables["output"]) < min_at_t0
40+
)
41+
42+
@staticmethod
43+
@pytest.mark.parametrize(
44+
"area",
45+
(
46+
(slice(0, 20), slice(None)),
47+
(slice(80, None), slice(None)),
48+
(slice(None), slice(0, 30)),
49+
(slice(None), slice(70, None)),
50+
),
51+
)
52+
def test_theta_at_domain_edges_equal_to_reference_value(area, variables):
53+
psi_at_last_step = variables["output"][-1, :, :]
54+
np.testing.assert_allclose(
55+
actual=psi_at_last_step[area],
56+
desired=variables["SETUP"].Tht_ref,
57+
rtol=1.5e-5,
58+
)

0 commit comments

Comments
 (0)
Please sign in to comment.