Skip to content

Commit 2e5badb

Browse files
[#2260] Add uxarray pset execute test for multiple particles
This test reproduces the bug reported in issue #2260
1 parent ee0de5f commit 2e5badb

1 file changed

Lines changed: 46 additions & 2 deletions

File tree

tests/test_particleset_execute.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
from parcels._datasets.structured.generated import simple_UV_dataset
2323
from parcels._datasets.structured.generic import datasets as datasets_structured
2424
from parcels._datasets.unstructured.generic import datasets as datasets_unstructured
25-
from parcels.interpolators import UXPiecewiseConstantFace
26-
from parcels.kernels import AdvectionEE
25+
from parcels.interpolators import UXPiecewiseConstantFace, UXPiecewiseLinearNode
26+
from parcels.kernels import AdvectionEE, AdvectionRK4_3D
2727
from tests import utils
2828
from tests.common_kernels import DoNothing
2929

@@ -483,6 +483,50 @@ def test_uxstommelgyre_pset_execute():
483483
assert utils.round_and_hash_float_array([p.lat for p in pset]) == 1142124776
484484

485485

486+
def test_uxstommelgyre_multiparticle_pset_execute():
487+
ds = datasets_unstructured["stommel_gyre_delaunay"]
488+
grid = UxGrid(grid=ds.uxgrid, z=ds.coords["nz"], mesh="spherical")
489+
U = Field(
490+
name="U",
491+
data=ds.U,
492+
grid=grid,
493+
interp_method=UXPiecewiseConstantFace,
494+
)
495+
V = Field(
496+
name="V",
497+
data=ds.V,
498+
grid=grid,
499+
interp_method=UXPiecewiseConstantFace,
500+
)
501+
W = Field(
502+
name="W",
503+
data=ds.W,
504+
grid=grid,
505+
interp_method=UXPiecewiseLinearNode,
506+
)
507+
P = Field(
508+
name="P",
509+
data=ds.p,
510+
grid=grid,
511+
interp_method=UXPiecewiseConstantFace,
512+
)
513+
UVW = VectorField(name="UVW", U=U, V=V, W=W)
514+
fieldset = FieldSet([UVW, UVW.U, UVW.V, UVW.W, P])
515+
pset = ParticleSet(
516+
fieldset,
517+
lon=[30.0, 32.0],
518+
lat=[5.0, 5.0],
519+
depth=[50.0, 50.0],
520+
time=[np.timedelta64(0, "s")],
521+
pclass=Particle,
522+
)
523+
pset.execute(
524+
runtime=np.timedelta64(10, "m"),
525+
dt=np.timedelta64(60, "s"),
526+
pyfunc=AdvectionRK4_3D,
527+
)
528+
529+
486530
@pytest.mark.xfail(reason="Output file not implemented yet")
487531
def test_uxstommelgyre_pset_execute_output():
488532
ds = datasets_unstructured["stommel_gyre_delaunay"]

0 commit comments

Comments
 (0)