@@ -243,3 +243,50 @@ def test_mixing():
243243
244244 # Assert that the particles move from their initial location
245245 assert (np .sum (np .abs (pset .lon - pset_mixing .lon )) > 0. ) & (np .sum (np .abs (pset .lat - pset_mixing .lat )) > 0. )
246+
247+ @pytest .mark .parametrize ("mode" , ["scipy" , "jit" ])
248+ def test_TEOSdensity_kernels (mode ):
249+ """ Adapted test from Parcels v3 codebase.
250+ """
251+ settings_file = 'tests/test_data/test_settings.json'
252+ settings = pp .utils .load_settings (settings_file )
253+
254+ settings ['simulation' ] = make_standard_simulation_settings ()
255+ settings ['plastictype' ] = make_standard_plastictype_settings ()
256+
257+ # Turn off all other processes
258+ settings ['use_3D' ] = False
259+ settings ['use_biofouling' ] = False
260+ settings ['use_stokes' ] = False
261+ settings ['use_wind' ] = False
262+ settings ['use_mixing' ] = False
263+
264+ def generate_fieldset (xdim = 2 , ydim = 2 , zdim = 2 , tdim = 1 ):
265+ lon = np .linspace (0.0 , 10.0 , xdim , dtype = np .float32 )
266+ lat = np .linspace (0.0 , 10.0 , ydim , dtype = np .float32 )
267+ depth = np .linspace (0 , 2000 , zdim , dtype = np .float32 )
268+ time = np .zeros (tdim , dtype = np .float64 )
269+ U = np .ones ((tdim , zdim , ydim , xdim ))
270+ V = np .ones ((tdim , zdim , ydim , xdim ))
271+ abs_salinity = 30 * np .ones ((tdim , zdim , ydim , xdim ))
272+ cons_temperature = 10 * np .ones ((tdim , zdim , ydim , xdim ))
273+ dimensions = {"lat" : lat , "lon" : lon , "depth" : depth , "time" : time }
274+ data = {
275+ "U" : np .array (U , dtype = np .float32 ),
276+ "V" : np .array (V , dtype = np .float32 ),
277+ "absolute_salinity" : np .array (abs_salinity , dtype = np .float32 ),
278+ "conservative_temperature" : np .array (cons_temperature , dtype = np .float32 ),
279+ }
280+ return (data , dimensions )
281+
282+ data , dimensions = generate_fieldset ()
283+ fieldset = parcels .FieldSet .from_data (data , dimensions )
284+
285+ release_locations = {'lons' : [5 ], 'lats' : [5 ], 'depths' : [1000 ],
286+ 'plastic_amount' : [1 ]}
287+
288+ pset = pp .constructors .create_particleset (fieldset , settings , release_locations )
289+
290+ pset .execute (pp .kernels .PolyTEOS10_bsq , runtime = 1 )
291+
292+ assert np .allclose (pset [0 ].seawater_density , 1027.45140 )
0 commit comments