@@ -285,13 +285,8 @@ 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
291288
292- pset = ParticleSet (
293- fieldset , pclass = MyParticle , lon = start_lon , lat = start_lat , z = start_z , time = np .timedelta64 (0 , "s" )
294- )
289+ pset = ParticleSet (fieldset , lon = start_lon , lat = start_lat , z = start_z , time = np .timedelta64 (0 , "s" ))
295290 pset .execute (kernel , dt = dt , endtime = np .timedelta64 (1 , "h" ))
296291
297292 def truth_moving (x_0 , y_0 , t ):
@@ -330,11 +325,8 @@ def test_decaying_moving_eddy(kernel, rtol):
330325 if kernel == AdvectionRK45 :
331326 fieldset .add_constant ("RK45_tol" , rtol )
332327 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
336328
337- pset = ParticleSet (fieldset , pclass = MyParticle , lon = start_lon , lat = start_lat , time = np .timedelta64 (0 , "s" ))
329+ pset = ParticleSet (fieldset , lon = start_lon , lat = start_lat , time = np .timedelta64 (0 , "s" ))
338330 pset .execute (kernel , dt = dt , endtime = np .timedelta64 (23 , "h" ))
339331
340332 def truth_moving (x_0 , y_0 , t ):
@@ -381,15 +373,13 @@ def test_stommelgyre_fieldset(kernel, rtol, grid_type):
381373 start_lon = np .linspace (10e3 , 100e3 , npart )
382374 start_lat = np .ones_like (start_lon ) * 5000e3
383375
376+ if kernel == AdvectionRK45 :
377+ fieldset .add_constant ("RK45_tol" , rtol )
378+
384379 SampleParticle = Particle .add_variable (
385380 [Variable ("p" , initial = 0.0 , dtype = np .float32 ), Variable ("p_start" , initial = 0.0 , dtype = np .float32 )]
386381 )
387382
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-
393383 def UpdateP (particles , fieldset ): # pragma: no cover
394384 particles .p = fieldset .P [particles .time , particles .z , particles .lat , particles .lon ]
395385 particles .p_start = np .where (particles .time == 0 , particles .p , particles .p_start )
@@ -404,7 +394,7 @@ def UpdateP(particles, fieldset): # pragma: no cover
404394 [
405395 (AdvectionRK2 , 2e-2 ),
406396 (AdvectionRK4 , 5e-3 ),
407- (AdvectionRK45 , 1e-3 ),
397+ (AdvectionRK45 , 1e-4 ),
408398 ],
409399)
410400@pytest .mark .parametrize ("grid_type" , ["A" ]) # TODO also implement C-grid once available
@@ -423,15 +413,13 @@ def test_peninsula_fieldset(kernel, rtol, grid_type):
423413 start_lat = np .linspace (3e3 , 47e3 , npart )
424414 start_lon = 3e3 * np .ones_like (start_lat )
425415
416+ if kernel == AdvectionRK45 :
417+ fieldset .add_constant ("RK45_tol" , rtol )
418+
426419 SampleParticle = Particle .add_variable (
427420 [Variable ("p" , initial = 0.0 , dtype = np .float32 ), Variable ("p_start" , initial = 0.0 , dtype = np .float32 )]
428421 )
429422
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-
435423 def UpdateP (particles , fieldset ): # pragma: no cover
436424 particles .p = fieldset .P [particles .time , particles .z , particles .lat , particles .lon ]
437425 particles .p_start = np .where (particles .time == 0 , particles .p , particles .p_start )
0 commit comments