|
12 | 12 | ParticleSet, |
13 | 13 | StatusCode, |
14 | 14 | UXPiecewiseConstantFace, |
| 15 | + Variable, |
15 | 16 | VectorField, |
16 | 17 | ) |
17 | 18 | from parcels._datasets.structured.generated import simple_UV_dataset |
@@ -150,6 +151,20 @@ def test_particleset_endtime_type(fieldset, endtime, expectation): |
150 | 151 | pset.execute(endtime=endtime, dt=np.timedelta64(10, "m"), pyfunc=DoNothing) |
151 | 152 |
|
152 | 153 |
|
| 154 | +@pytest.mark.parametrize( |
| 155 | + "dt", [np.timedelta64(1, "s"), np.timedelta64(1, "ms"), np.timedelta64(10, "ms"), np.timedelta64(1, "ns")] |
| 156 | +) |
| 157 | +def test_pset_execute_subsecond_dt(fieldset, dt): |
| 158 | + def AddDt(particles, fieldset): # pragma: no cover |
| 159 | + dt = particles.dt / np.timedelta64(1, "s") |
| 160 | + particles.added_dt += dt |
| 161 | + |
| 162 | + pclass = Particle.add_variable(Variable("added_dt", dtype=np.float32, initial=0)) |
| 163 | + pset = ParticleSet(fieldset, pclass=pclass, lon=0, lat=0) |
| 164 | + pset.execute(AddDt, runtime=dt * 10, dt=dt) |
| 165 | + np.testing.assert_allclose(pset[0].added_dt, 10.0 * dt / np.timedelta64(1, "s"), atol=1e-5) |
| 166 | + |
| 167 | + |
153 | 168 | def test_pset_remove_particle_in_kernel(fieldset): |
154 | 169 | npart = 100 |
155 | 170 | pset = ParticleSet(fieldset, lon=np.linspace(0, 1, npart), lat=np.linspace(1, 0, npart)) |
|
0 commit comments