Skip to content

Commit 12108cf

Browse files
Adding unit test that throws OutsideTimeInterval error
In order to try to fix #2375
1 parent a760d04 commit 12108cf

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/test_particleset_execute.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,24 @@ def SampleU(particles, fieldset): # pragma: no cover
162162
assert pset[0].time == endtime
163163

164164

165+
def test_particleset_run_RK_to_endtime_fwd_bwd(fieldset):
166+
"""Test that RK kernels can be run to the endtime of a fieldset (and not throw OutsideTimeInterval)"""
167+
starttime = fieldset.time_interval.left
168+
endtime = fieldset.time_interval.right
169+
dt = np.timedelta64(1, "D")
170+
171+
# Setting zero velocities to avoid OutofBoundsErrors
172+
fieldset.U.data[:] = 0.0
173+
fieldset.V.data[:] = 0.0
174+
175+
pset = ParticleSet(fieldset, lon=[0.2], lat=[5.0], time=[starttime])
176+
pset.execute(AdvectionRK4, endtime=endtime, dt=dt)
177+
assert pset[0].time == endtime
178+
179+
pset.execute(AdvectionRK4, endtime=starttime, dt=-dt)
180+
assert pset[0].time == starttime
181+
182+
165183
def test_particleset_interpolate_on_domainedge(zonal_flow_fieldset):
166184
fieldset = zonal_flow_fieldset
167185

0 commit comments

Comments
 (0)