@@ -285,8 +285,13 @@ def test_moving_eddy(kernel, rtol):
285285
286286 if kernel == AdvectionRK45 :
287287 fieldset .add_constant ("RK45_tol" , rtol )
288+ MyParticle = Particle .add_variable (Variable ("next_dt" , dtype = "timedelta64[s]" , initial = dt ))
289+ else :
290+ MyParticle = Particle
288291
289- pset = ParticleSet (fieldset , lon = start_lon , lat = start_lat , z = start_z , time = np .timedelta64 (0 , "s" ))
292+ pset = ParticleSet (
293+ fieldset , pclass = MyParticle , lon = start_lon , lat = start_lat , z = start_z , time = np .timedelta64 (0 , "s" )
294+ )
290295 pset .execute (kernel , dt = dt , endtime = np .timedelta64 (1 , "h" ))
291296
292297 def truth_moving (x_0 , y_0 , t ):
@@ -325,8 +330,11 @@ def test_decaying_moving_eddy(kernel, rtol):
325330 if kernel == AdvectionRK45 :
326331 fieldset .add_constant ("RK45_tol" , rtol )
327332 fieldset .add_constant ("RK45_min_dt" , 10 * 60 )
333+ MyParticle = Particle .add_variable (Variable ("next_dt" , dtype = "timedelta64[s]" , initial = dt ))
334+ else :
335+ MyParticle = Particle
328336
329- pset = ParticleSet (fieldset , lon = start_lon , lat = start_lat , time = np .timedelta64 (0 , "s" ))
337+ pset = ParticleSet (fieldset , pclass = MyParticle , lon = start_lon , lat = start_lat , time = np .timedelta64 (0 , "s" ))
330338 pset .execute (kernel , dt = dt , endtime = np .timedelta64 (23 , "h" ))
331339
332340 def truth_moving (x_0 , y_0 , t ):
@@ -373,13 +381,15 @@ def test_stommelgyre_fieldset(kernel, rtol, grid_type):
373381 start_lon = np .linspace (10e3 , 100e3 , npart )
374382 start_lat = np .ones_like (start_lon ) * 5000e3
375383
376- if kernel == AdvectionRK45 :
377- fieldset .add_constant ("RK45_tol" , rtol )
378-
379384 SampleParticle = Particle .add_variable (
380385 [Variable ("p" , initial = 0.0 , dtype = np .float32 ), Variable ("p_start" , initial = 0.0 , dtype = np .float32 )]
381386 )
382387
388+ if kernel == AdvectionRK45 :
389+ fieldset .add_constant ("RK45_tol" , rtol )
390+ fieldset .add_constant ("RK45_min_dt" , 5 * 60 )
391+ SampleParticle = SampleParticle .add_variable (Variable ("next_dt" , dtype = "timedelta64[s]" , initial = dt ))
392+
383393 def UpdateP (particles , fieldset ): # pragma: no cover
384394 particles .p = fieldset .P [particles .time , particles .z , particles .lat , particles .lon ]
385395 particles .p_start = np .where (particles .time == 0 , particles .p , particles .p_start )
@@ -394,7 +404,7 @@ def UpdateP(particles, fieldset): # pragma: no cover
394404 [
395405 (AdvectionRK2 , 2e-2 ),
396406 (AdvectionRK4 , 5e-3 ),
397- (AdvectionRK45 , 1e-4 ),
407+ (AdvectionRK45 , 1e-3 ),
398408 ],
399409)
400410@pytest .mark .parametrize ("grid_type" , ["A" ]) # TODO also implement C-grid once available
@@ -413,13 +423,15 @@ def test_peninsula_fieldset(kernel, rtol, grid_type):
413423 start_lat = np .linspace (3e3 , 47e3 , npart )
414424 start_lon = 3e3 * np .ones_like (start_lat )
415425
416- if kernel == AdvectionRK45 :
417- fieldset .add_constant ("RK45_tol" , rtol )
418-
419426 SampleParticle = Particle .add_variable (
420427 [Variable ("p" , initial = 0.0 , dtype = np .float32 ), Variable ("p_start" , initial = 0.0 , dtype = np .float32 )]
421428 )
422429
430+ if kernel == AdvectionRK45 :
431+ fieldset .add_constant ("RK45_tol" , rtol )
432+ fieldset .add_constant ("RK45_min_dt" , 5 * 60 )
433+ SampleParticle = SampleParticle .add_variable (Variable ("next_dt" , dtype = "timedelta64[s]" , initial = dt ))
434+
423435 def UpdateP (particles , fieldset ): # pragma: no cover
424436 particles .p = fieldset .P [particles .time , particles .z , particles .lat , particles .lon ]
425437 particles .p_start = np .where (particles .time == 0 , particles .p , particles .p_start )
0 commit comments