-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from slayoo/dev
analytic solution in the shallow-water smoke test
- Loading branch information
Showing
2 changed files
with
30 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|