|
25 | 25 | AdvectionRK4_3D, |
26 | 26 | AdvectionRK45, |
27 | 27 | ) |
28 | | -from tests.utils import round_and_hash_float_array |
| 28 | +from tests.utils import DEFAULT_PARTICLES, round_and_hash_float_array |
29 | 29 |
|
30 | 30 |
|
31 | 31 | @pytest.mark.parametrize("mesh", ["spherical", "flat"]) |
@@ -287,12 +287,9 @@ def test_moving_eddy(kernel, rtol): |
287 | 287 |
|
288 | 288 | if kernel == AdvectionRK45: |
289 | 289 | fieldset.add_constant("RK45_tol", rtol) |
290 | | - MyParticle = Particle.add_variable(Variable("next_dt")) |
291 | | - else: |
292 | | - MyParticle = Particle |
293 | 290 |
|
294 | 291 | pset = ParticleSet( |
295 | | - fieldset, pclass=MyParticle, lon=start_lon, lat=start_lat, z=start_z, time=np.timedelta64(0, "s") |
| 292 | + fieldset, pclass=DEFAULT_PARTICLES[kernel], lon=start_lon, lat=start_lat, z=start_z, time=np.timedelta64(0, "s") |
296 | 293 | ) |
297 | 294 | pset.execute(kernel, dt=dt, endtime=endtime) |
298 | 295 |
|
@@ -333,11 +330,10 @@ def test_decaying_moving_eddy(kernel, rtol): |
333 | 330 | if kernel == AdvectionRK45: |
334 | 331 | fieldset.add_constant("RK45_tol", rtol) |
335 | 332 | fieldset.add_constant("RK45_min_dt", 10 * 60) |
336 | | - MyParticle = Particle.add_variable(Variable("next_dt")) |
337 | | - else: |
338 | | - MyParticle = Particle |
339 | 333 |
|
340 | | - pset = ParticleSet(fieldset, pclass=MyParticle, lon=start_lon, lat=start_lat, time=np.timedelta64(0, "s")) |
| 334 | + pset = ParticleSet( |
| 335 | + fieldset, pclass=DEFAULT_PARTICLES[kernel], lon=start_lon, lat=start_lat, time=np.timedelta64(0, "s") |
| 336 | + ) |
341 | 337 | pset.execute(kernel, dt=dt, endtime=endtime) |
342 | 338 |
|
343 | 339 | def truth_moving(x_0, y_0, t): |
@@ -384,13 +380,12 @@ def test_stommelgyre_fieldset(kernel, rtol, grid_type): |
384 | 380 | start_lon = np.linspace(10e3, 100e3, npart) |
385 | 381 | start_lat = np.ones_like(start_lon) * 5000e3 |
386 | 382 |
|
387 | | - SampleParticle = Particle.add_variable( |
| 383 | + SampleParticle = DEFAULT_PARTICLES[kernel].add_variable( |
388 | 384 | [Variable("p", initial=0.0, dtype=np.float32), Variable("p_start", initial=0.0, dtype=np.float32)] |
389 | 385 | ) |
390 | 386 |
|
391 | 387 | if kernel == AdvectionRK45: |
392 | 388 | fieldset.add_constant("RK45_tol", rtol) |
393 | | - SampleParticle = SampleParticle.add_variable(Variable("next_dt")) |
394 | 389 |
|
395 | 390 | def UpdateP(particles, fieldset): # pragma: no cover |
396 | 391 | particles.p = fieldset.P[particles.time, particles.z, particles.lat, particles.lon] |
@@ -425,13 +420,12 @@ def test_peninsula_fieldset(kernel, rtol, grid_type): |
425 | 420 | start_lat = np.linspace(3e3, 47e3, npart) |
426 | 421 | start_lon = 3e3 * np.ones_like(start_lat) |
427 | 422 |
|
428 | | - SampleParticle = Particle.add_variable( |
| 423 | + SampleParticle = DEFAULT_PARTICLES[kernel].add_variable( |
429 | 424 | [Variable("p", initial=0.0, dtype=np.float32), Variable("p_start", initial=0.0, dtype=np.float32)] |
430 | 425 | ) |
431 | 426 |
|
432 | 427 | if kernel == AdvectionRK45: |
433 | 428 | fieldset.add_constant("RK45_tol", rtol) |
434 | | - SampleParticle = SampleParticle.add_variable(Variable("next_dt")) |
435 | 429 |
|
436 | 430 | def UpdateP(particles, fieldset): # pragma: no cover |
437 | 431 | particles.p = fieldset.P[particles.time, particles.z, particles.lat, particles.lon] |
|
0 commit comments