@@ -14,6 +14,7 @@ def make_standard_simulation_settings():
1414 }
1515 return simulation_settings
1616
17+
1718def make_standard_plastictype_settings ():
1819 #Use tiny wind percentage because test data set is not large and wind speeds are quick!
1920 plastictype_settings = {'wind_coefficient' : 0.0001 , # Percentage of wind to apply to particles
@@ -22,6 +23,7 @@ def make_standard_plastictype_settings():
2223 }
2324 return plastictype_settings
2425
26+
2527def make_standard_particleset (fieldset , settings ):
2628 # Generate a particleset that has particles in the test domain
2729 settings ['release' ] = {'initialisation_type' : 'fisheries' , 'country' : 'Malta' }
@@ -30,9 +32,10 @@ def make_standard_particleset(fieldset, settings):
3032 # Only keep particles in the test domain
3133 keep_particles = (pset .lon > 17 ) & (pset .lon < 20 ) & (pset .lat < 36 ) & (pset .lat > 34 )
3234 pset .remove_booleanvector (~ keep_particles )
33-
35+
3436 return pset
3537
38+
3639@pytest .mark .parametrize ('use_3D' , [True , False ])
3740def test_advection_only (use_3D ):
3841 settings_file = 'tests/test_data/test_settings.json'
@@ -41,7 +44,7 @@ def test_advection_only(use_3D):
4144
4245 settings ['simulation' ] = make_standard_simulation_settings ()
4346 settings ['plastictype' ] = make_standard_plastictype_settings ()
44-
47+
4548 # Turn on/off 3D advection
4649 settings ['use_3D' ] = use_3D
4750
@@ -67,14 +70,15 @@ def test_advection_only(use_3D):
6770 # Assert that the particles move from their initial location
6871 assert (np .sum (np .abs (pset .lon - start_lons )) > 0. ) & (np .sum (np .abs (pset .lat - start_lats )) > 0. )
6972
73+
7074def test_settling_velocity ():
7175 settings_file = 'tests/test_data/test_settings.json'
7276 settings = pp .utils .load_settings (settings_file )
7377 settings = pp .utils .download_plasticparcels_dataset ('NEMO0083' , settings , 'input_data' )
7478
7579 settings ['simulation' ] = make_standard_simulation_settings ()
7680 settings ['plastictype' ] = make_standard_plastictype_settings ()
77-
81+
7882 # Turn on 3D advection
7983 settings ['use_3D' ] = True
8084
@@ -85,7 +89,7 @@ def test_settling_velocity():
8589 settings ['use_mixing' ] = False
8690
8791 fieldset = pp .constructors .create_fieldset (settings )
88-
92+
8993 kernels = pp .constructors .create_kernel (fieldset )
9094
9195 pset = make_standard_particleset (fieldset , settings )
@@ -99,14 +103,15 @@ def test_settling_velocity():
99103 # Assert that the particles move from their initial location
100104 assert (np .sum (np .abs (pset .lon - start_lons )) > 0. ) & (np .sum (np .abs (pset .lat - start_lats )) > 0. ) & (np .sum (np .abs (pset .depth - start_depths )) > 0. )
101105
106+
102107def test_biofouling ():
103108 settings_file = 'tests/test_data/test_settings.json'
104109 settings = pp .utils .load_settings (settings_file )
105110 settings = pp .utils .download_plasticparcels_dataset ('NEMO0083' , settings , 'input_data' )
106111
107112 settings ['simulation' ] = make_standard_simulation_settings ()
108113 settings ['plastictype' ] = make_standard_plastictype_settings ()
109-
114+
110115 # Turn on biofouling
111116 settings ['use_biofouling' ] = True
112117
@@ -117,7 +122,7 @@ def test_biofouling():
117122 settings ['use_mixing' ] = False
118123
119124 fieldset = pp .constructors .create_fieldset (settings )
120-
125+
121126 kernels = [pp .kernels .PolyTEOS10_bsq , pp .kernels .Biofouling ,
122127 pp .kernels .checkThroughBathymetry , pp .kernels .checkErrorThroughSurface ,
123128 pp .kernels .deleteParticle ]
@@ -131,25 +136,26 @@ def test_biofouling():
131136 # Assert that the particles move from their initial location
132137 assert (np .sum (np .abs (pset .depth - start_depths )) > 0. )
133138
139+
134140def test_Stokes ():
135141 settings_file = 'tests/test_data/test_settings.json'
136142 settings = pp .utils .load_settings (settings_file )
137143 settings = pp .utils .download_plasticparcels_dataset ('NEMO0083' , settings , 'input_data' )
138144
139145 settings ['simulation' ] = make_standard_simulation_settings ()
140146 settings ['plastictype' ] = make_standard_plastictype_settings ()
141-
147+
142148 # Turn on Stokes Drift
143149 settings ['use_stokes' ] = True
144-
150+
145151 # Turn off all other processes
146152 settings ['use_3D' ] = False
147153 settings ['use_biofouling' ] = False
148154 settings ['use_wind' ] = False
149155 settings ['use_mixing' ] = False
150156
151157 fieldset = pp .constructors .create_fieldset (settings )
152-
158+
153159 kernels = [pp .kernels .StokesDrift , pp .kernels .deleteParticle ]
154160
155161 pset = make_standard_particleset (fieldset , settings )
@@ -162,29 +168,30 @@ def test_Stokes():
162168 # Assert that the particles move from their initial location
163169 assert (np .sum (np .abs (pset .lon - start_lons )) > 0. ) & (np .sum (np .abs (pset .lat - start_lats )) > 0. )
164170
171+
165172def test_wind ():
166173 settings_file = 'tests/test_data/test_settings.json'
167174 settings = pp .utils .load_settings (settings_file )
168175 settings = pp .utils .download_plasticparcels_dataset ('NEMO0083' , settings , 'input_data' )
169176
170177 settings ['simulation' ] = make_standard_simulation_settings ()
171178 settings ['plastictype' ] = make_standard_plastictype_settings ()
172-
179+
173180 # Turn on Stokes Drift
174181 settings ['use_wind' ] = True
175-
182+
176183 # Turn off all other processes
177184 settings ['use_3D' ] = False
178185 settings ['use_biofouling' ] = False
179186 settings ['use_stokes' ] = False
180187 settings ['use_mixing' ] = False
181188
182189 fieldset = pp .constructors .create_fieldset (settings )
183-
190+
184191 kernels = [pp .kernels .WindageDrift , pp .kernels .unbeaching , pp .kernels .periodicBC , pp .kernels .deleteParticle ]
185192
186193 pset = make_standard_particleset (fieldset , settings )
187-
194+
188195 start_lons = pset .lon .copy ()
189196 start_lats = pset .lat .copy ()
190197
@@ -193,17 +200,18 @@ def test_wind():
193200 # Assert that the particles move from their initial location
194201 assert (np .sum (np .abs (pset .lon - start_lons )) > 0. ) & (np .sum (np .abs (pset .lat - start_lats )) > 0. )
195202
203+
196204def test_mixing ():
197205 settings_file = 'tests/test_data/test_settings.json'
198206 settings = pp .utils .load_settings (settings_file )
199207 settings = pp .utils .download_plasticparcels_dataset ('NEMO0083' , settings , 'input_data' )
200208
201209 settings ['simulation' ] = make_standard_simulation_settings ()
202210 settings ['plastictype' ] = make_standard_plastictype_settings ()
203-
211+
204212 settings ['use_3D' ] = True
205213 settings ['use_mixing' ] = True
206-
214+
207215 # Turn off all other processes
208216 settings ['use_wind' ] = False
209217 settings ['use_biofouling' ] = False
@@ -212,7 +220,7 @@ def test_mixing():
212220 fieldset = pp .constructors .create_fieldset (settings )
213221 kernels = [parcels .application_kernels .AdvectionRK4_3D , pp .kernels .checkThroughBathymetry ,
214222 pp .kernels .checkErrorThroughSurface , pp .kernels .deleteParticle ]
215-
223+
216224 kernels_mixing = [parcels .application_kernels .AdvectionRK4_3D , pp .kernels .VerticalMixing ,
217225 pp .kernels .checkThroughBathymetry , pp .kernels .checkErrorThroughSurface ,
218226 pp .kernels .deleteParticle ]
0 commit comments