@@ -19,7 +19,7 @@ def make_standard_plastictype_settings():
1919 # Use tiny wind percentage because test data set is not large and wind speeds are quick!
2020 plastictype_settings = {'wind_coefficient' : 0.0001 , # Percentage of wind to apply to particles
2121 'plastic_diameter' : 0.001 , # Plastic particle diameter (m)
22- 'plastic_density' : 1030. , # Plastic particle density (kg/m^3)
22+ 'plastic_density' : 1027.67 , # Plastic particle density (kg/m^3)
2323 }
2424 return plastictype_settings
2525
@@ -32,6 +32,14 @@ def make_standard_particleset(fieldset, settings):
3232
3333 return pset
3434
35+ def checkBelowDataDepth (particle , fieldset , time ):
36+ # The vertical mixing kernel can push particles below the test dataset depth, throwing an
37+ # out of bounds error. This kernel will keep particles above the max depth.
38+ if particle .depth + particle_ddepth >= fieldset .max_depth : # noqa
39+ # move a meter above the max depth
40+ particle_ddepth = fieldset .max_depth - particle .depth - 1.0 # noqa
41+ particle .state = parcels .StatusCode .Success
42+
3543
3644@pytest .mark .parametrize ('use_3D' , [True , False ])
3745def test_advection_only (use_3D ):
@@ -159,7 +167,6 @@ def test_Stokes():
159167
160168 start_lons = pset .lon .copy ()
161169 start_lats = pset .lat .copy ()
162- print (pset [0 ].dt )
163170 pset .execute (kernels , runtime = settings ['simulation' ]['runtime' ], dt = settings ['simulation' ]['dt' ])
164171
165172 # Assert that the particles move from their initial location
@@ -216,18 +223,23 @@ def test_mixing():
216223 settings ['use_stokes' ] = False
217224
218225 fieldset = pp .constructors .create_fieldset (settings )
226+ fieldset .add_constant ('max_depth' , fieldset .U .depth [- 1 ])
227+
228+ # Set the simulation runtime to just 1 day so particles aren't kicked around significantly
229+ settings ['simulation' ]['runtime' ] = timedelta (days = 1 )
230+
219231 kernels = [parcels .application_kernels .AdvectionRK4_3D , pp .kernels .checkThroughBathymetry ,
220232 pp .kernels .checkErrorThroughSurface , pp .kernels .deleteParticle ]
221233
222234 kernels_mixing = [parcels .application_kernels .AdvectionRK4_3D , pp .kernels .VerticalMixing ,
223- pp . kernels . checkThroughBathymetry , pp .kernels .checkErrorThroughSurface ,
224- pp .kernels .deleteParticle ]
235+ checkBelowDataDepth , pp .kernels .checkThroughBathymetry ,
236+ pp .kernels .checkErrorThroughSurface , pp . kernels . deleteParticle ]
225237
226238 pset = make_standard_particleset (fieldset , settings )
227239 pset_mixing = make_standard_particleset (fieldset , settings )
228240
229241 pset .execute (kernels , runtime = settings ['simulation' ]['runtime' ], dt = settings ['simulation' ]['dt' ])
230- pset .execute (kernels_mixing , runtime = settings ['simulation' ]['runtime' ], dt = settings ['simulation' ]['dt' ])
242+ pset_mixing .execute (kernels_mixing , runtime = settings ['simulation' ]['runtime' ], dt = settings ['simulation' ]['dt' ])
231243
232244 # Assert that the particles move from their initial location
233245 assert (np .sum (np .abs (pset .lon - pset_mixing .lon )) > 0. ) & (np .sum (np .abs (pset .lat - pset_mixing .lat )) > 0. )
0 commit comments