Skip to content

Commit

Permalink
Merge pull request #276 from slayoo/dev
Browse files Browse the repository at this point in the history
analytic solution in the shallow-water smoke test
  • Loading branch information
slayoo authored Oct 11, 2021
2 parents a49941a + 3ed053d commit 66a2b8b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test-time-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pytest
pytest-benchmark

# note: if cloning both PyMPDATA and PyMPDATA examples, consider "pip install -e"
PyMPDATA-examples @ git+git://github.com/atmos-cloud-sim-uj/PyMPDATA-examples@01ae90a#egg=PyMPDATA-examples
PyMPDATA-examples @ git+git://github.com/atmos-cloud-sim-uj/PyMPDATA-examples@21cbe3c#egg=PyMPDATA-examples
32 changes: 29 additions & 3 deletions tests/smoke_tests/Jarecka_et_al_2015/test_just_do_it.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
from PyMPDATA_examples.Jarecka_et_al_2015 import Settings, Simulation
import numpy as np
import pytest
from matplotlib import pylab
from PyMPDATA_examples.Jarecka_et_al_2015 import Settings, Simulation, formulae, plot_output
from PyMPDATA_examples.utils.error_norms import L2

def test_just_do_it():

@pytest.mark.parametrize("nx", (101, 100))
@pytest.mark.parametrize("ny", (101, 100))
def test_just_do_it(nx, ny, plot=False):
# arrange
settings = Settings()
settings.dx *= settings.nx / nx
settings.nx = nx
settings.dy *= settings.ny / ny
settings.ny = ny
simulation = Simulation(settings)
simulation.run()
times = (1, 3, 7)

# act
output = simulation.run()

# plot
plot_data = plot_output(times, output, settings, return_data=True)
if plot:
pylab.show()

# assert
for key, item in plot_data.items():
assert 2**L2(item['h_numeric'], item['h_analytic'], nt=settings.nt) < 5e-3
assert 2**L2(item['q_h_numeric'], item['q_h_analytic'], nt=settings.nt) < 5e-2

0 comments on commit 66a2b8b

Please sign in to comment.