Skip to content

Commit 9a27794

Browse files
Removing advections tests in v3 that are already covered
1 parent 88eb065 commit 9a27794

1 file changed

Lines changed: 0 additions & 75 deletions

File tree

tests/test_advection.py

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import math
2-
from datetime import timedelta
32

43
import numpy as np
54
import pytest
@@ -29,13 +28,6 @@
2928
"AdvDiffM1": AdvectionDiffusionM1,
3029
}
3130

32-
# Some constants
33-
f = 1.0e-4
34-
u_0 = 0.3
35-
u_g = 0.04
36-
gamma = 1 / (86400.0 * 2.89)
37-
gamma_g = 1 / (86400.0 * 28.9)
38-
3931

4032
@pytest.fixture
4133
def lon():
@@ -55,43 +47,6 @@ def depth():
5547
return np.linspace(0, 30, zdim, dtype=np.float32)
5648

5749

58-
@pytest.mark.v4alpha
59-
@pytest.mark.xfail(reason="GH1946")
60-
def test_advection_meridional(lon, lat):
61-
"""Particles at high latitude move geographically faster due to the pole correction in `GeographicPolar`."""
62-
npart = 10
63-
data = {"U": np.zeros((lat.size, lon.size), dtype=np.float32), "V": np.ones((lat.size, lon.size), dtype=np.float32)}
64-
dimensions = {"lon": lon, "lat": lat}
65-
fieldset = FieldSet.from_data(data, dimensions, mesh="spherical")
66-
67-
pset = ParticleSet(fieldset, pclass=Particle, lon=np.linspace(-60, 60, npart), lat=np.linspace(0, 30, npart))
68-
delta_lat = np.diff(pset.lat)
69-
pset.execute(AdvectionRK4, runtime=timedelta(hours=2), dt=timedelta(seconds=30))
70-
assert np.allclose(np.diff(pset.lat), delta_lat, rtol=1.0e-4)
71-
72-
73-
@pytest.mark.v4alpha
74-
@pytest.mark.xfail(reason="GH1946")
75-
@pytest.mark.parametrize("rk45_tol", [10, 100])
76-
def test_advection_RK45(lon, lat, rk45_tol):
77-
npart = 10
78-
data2D = {
79-
"U": np.ones((lat.size, lon.size), dtype=np.float32),
80-
"V": np.zeros((lat.size, lon.size), dtype=np.float32),
81-
}
82-
dimensions = {"lon": lon, "lat": lat}
83-
fieldset = FieldSet.from_data(data2D, dimensions, mesh="spherical")
84-
fieldset.add_constant("RK45_tol", rk45_tol)
85-
86-
dt = timedelta(seconds=30).total_seconds()
87-
RK45Particles = Particle.add_variable("next_dt", dtype=np.float32, initial=dt)
88-
pset = ParticleSet(fieldset, pclass=RK45Particles, lon=np.zeros(npart) + 20.0, lat=np.linspace(0, 80, npart))
89-
pset.execute(AdvectionRK45, runtime=timedelta(hours=2), dt=dt)
90-
assert (np.diff(pset.lon) > 1.0e-4).all()
91-
assert np.isclose(fieldset.RK45_tol, rk45_tol / (1852 * 60))
92-
print(fieldset.RK45_tol)
93-
94-
9550
@pytest.mark.v4alpha
9651
@pytest.mark.xfail(reason="When refactoring fieldfilebuffer croco support was dropped. This will be fixed in v4.")
9752
def test_conversion_3DCROCO():
@@ -186,36 +141,6 @@ def periodicBC(particle, fieldset, time): # pragma: no cover
186141
particle.lat = math.fmod(particle.lat, 1)
187142

188143

189-
@pytest.mark.v4alpha
190-
@pytest.mark.xfail(reason="Calls fieldset.add_periodic_halo(). In v4, interpolation should work without adding halo.")
191-
def test_advection_periodic_meridional():
192-
xdim, ydim = 100, 100
193-
fieldset = create_periodic_fieldset(xdim, ydim, uvel=0.0, vvel=1.0)
194-
fieldset.add_periodic_halo(meridional=True)
195-
assert len(fieldset.U.lat) == ydim + 10 # default halo size is 5 grid points
196-
197-
pset = ParticleSet(fieldset, pclass=Particle, lon=[0.5], lat=[0.5])
198-
pset.execute(AdvectionRK4 + pset.Kernel(periodicBC), runtime=timedelta(hours=20), dt=timedelta(seconds=30))
199-
assert abs(pset.lat[0] - 0.15) < 0.1
200-
201-
202-
@pytest.mark.v4alpha
203-
@pytest.mark.xfail(reason="Calls fieldset.add_periodic_halo(). In v4, interpolation should work without adding halo.")
204-
def test_advection_periodic_zonal_meridional():
205-
xdim, ydim = 100, 100
206-
fieldset = create_periodic_fieldset(xdim, ydim, uvel=1.0, vvel=1.0)
207-
fieldset.add_periodic_halo(zonal=True, meridional=True)
208-
assert len(fieldset.U.lat) == ydim + 10 # default halo size is 5 grid points
209-
assert len(fieldset.U.lon) == xdim + 10 # default halo size is 5 grid points
210-
assert np.allclose(np.diff(fieldset.U.lat), fieldset.U.lat[1] - fieldset.U.lat[0], rtol=0.001)
211-
assert np.allclose(np.diff(fieldset.U.lon), fieldset.U.lon[1] - fieldset.U.lon[0], rtol=0.001)
212-
213-
pset = ParticleSet(fieldset, pclass=Particle, lon=[0.4], lat=[0.5])
214-
pset.execute(AdvectionRK4 + pset.Kernel(periodicBC), runtime=timedelta(hours=20), dt=timedelta(seconds=30))
215-
assert abs(pset.lon[0] - 0.05) < 0.1
216-
assert abs(pset.lat[0] - 0.15) < 0.1
217-
218-
219144
@pytest.mark.v4alpha
220145
@pytest.mark.xfail(reason="GH1946")
221146
@pytest.mark.parametrize("u", [-0.3, np.array(0.2)])

0 commit comments

Comments
 (0)