@@ -41,6 +41,10 @@ def setup_test(n_particles=50, extra_rp_params=None):
4141
4242 rp .params ["mesh.nx" ] = 8
4343 rp .params ["mesh.ny" ] = 8
44+ rp .params ["mesh.xmin" ] = 0
45+ rp .params ["mesh.xmax" ] = 1
46+ rp .params ["mesh.ymin" ] = 0
47+ rp .params ["mesh.ymax" ] = 1
4448 rp .params ["particles.do_particles" ] = 1
4549 n_particles = n_particles
4650
@@ -134,11 +138,7 @@ def test_particles_advect():
134138 extra_rp_params = {"mesh.xlboundary" : "periodic" ,
135139 "mesh.xrboundary" : "periodic" ,
136140 "mesh.ylboundary" : "periodic" ,
137- "mesh.yrboundary" : "periodic" ,
138- "mesh.xmin" : 0 ,
139- "mesh.xmax" : 1 ,
140- "mesh.ymin" : 0 ,
141- "mesh.ymax" : 1 }
141+ "mesh.yrboundary" : "periodic" }
142142
143143 myd , bc , n_particles = setup_test (extra_rp_params = extra_rp_params )
144144
@@ -164,11 +164,11 @@ def test_particles_advect():
164164 # now move constant speed to the right
165165 u [:, :] = 1
166166
167- ps .update_particles (1 , u , v )
167+ ps .update_particles (0. 1 , u , v )
168168
169169 positions = set ([(p .x , p .y ) for p in ps .particles .values ()])
170170
171- correct_positions = set ([((x + 1 ) % 1 , y ) for x in xs for y in xs ])
171+ correct_positions = set ([((x + 0. 1 ) % 1 , y ) for x in xs for y in xs ])
172172
173173 assert positions == correct_positions , "sets are not the same"
174174
@@ -177,23 +177,23 @@ def test_particles_advect():
177177 v [:, :] = 1
178178
179179 ps = particles .Particles (myd , bc , n_particles , "grid" )
180- ps .update_particles (1 , u , v )
180+ ps .update_particles (0. 1 , u , v )
181181
182182 positions = set ([(p .x , p .y ) for p in ps .particles .values ()])
183183
184- correct_positions = set ([(x , (y + 1 ) % 1 ) for x in xs for y in xs ])
184+ correct_positions = set ([(x , (y + 0. 1 ) % 1 ) for x in xs for y in xs ])
185185
186186 assert positions == correct_positions , "sets are not the same"
187187
188188 # constant speed right + up
189189 u [:, :] = 1
190190
191191 ps = particles .Particles (myd , bc , n_particles , "grid" )
192- ps .update_particles (1 , u , v )
192+ ps .update_particles (0. 1 , u , v )
193193
194194 positions = set ([(p .x , p .y ) for p in ps .particles .values ()])
195195
196- correct_positions = set ([((x + 1 ) % 1 , (y + 1 ) % 1 ) for x in xs for y in xs ])
196+ correct_positions = set ([((x + 0. 1 ) % 1 , (y + 0. 1 ) % 1 ) for x in xs for y in xs ])
197197
198198 assert positions == correct_positions , "sets are not the same"
199199
@@ -206,17 +206,13 @@ def test_reflect_bcs():
206206 extra_rp_params = {"mesh.xlboundary" : "reflect-even" ,
207207 "mesh.xrboundary" : "reflect-even" ,
208208 "mesh.ylboundary" : "reflect-even" ,
209- "mesh.yrboundary" : "reflect-even" ,
210- "mesh.xmin" : 0 ,
211- "mesh.xmax" : 1 ,
212- "mesh.ymin" : 0 ,
213- "mesh.ymax" : 1 }
209+ "mesh.yrboundary" : "reflect-even" }
214210
215211 myd , bc , _ = setup_test (extra_rp_params = extra_rp_params )
216212
217213 # create an array of particles at the edge of the domain.
218- init_particle_positions = [[0.5 , 0.2 ], [0.5 , 0.8 ],
219- [0.2 , 0.5 ], [0.8 , 0.5 ]]
214+ init_particle_positions = [[0.5 , 0.03 ], [0.5 , 0.96 ],
215+ [0.04 , 0.5 ], [0.97 , 0.5 ]]
220216
221217 ps = particles .Particles (myd , bc , 4 , "array" , init_particle_positions )
222218
@@ -232,15 +228,15 @@ def test_reflect_bcs():
232228 u [(x > y ) & (x > (1 - y ))] = 1
233229 v [(x > y ) & (x < (1 - y ))] = - 1
234230
235- ps .update_particles (0.3 , u , v )
231+ ps .update_particles (0.1 , u , v )
236232
237233 # extract positions by their initial positions so they're in the right order
238234 # (as particles are stored in a dictionary they may not be returned in the
239235 # same order as we first inserted them.)
240236 positions = [ps .particles [(x , y )].pos () for (x , y ) in init_particle_positions ]
241237
242- correct_positions = [[0.5 , 0.1 ], [0.5 , 0.9 ],
243- [0.1 , 0.5 ], [0.9 , 0.5 ]]
238+ correct_positions = [[0.5 , 0.07 ], [0.5 , 0.94 ],
239+ [0.06 , 0.5 ], [0.93 , 0.5 ]]
244240
245241 np .testing .assert_array_almost_equal (positions , correct_positions )
246242
@@ -254,20 +250,14 @@ def test_outflow_bcs():
254250 extra_rp_params = {"mesh.xlboundary" : "outflow" ,
255251 "mesh.xrboundary" : "outflow" ,
256252 "mesh.ylboundary" : "outflow" ,
257- "mesh.yrboundary" : "outflow" ,
258- "mesh.xmin" : 0 ,
259- "mesh.xmax" : 1 ,
260- "mesh.ymin" : 0 ,
261- "mesh.ymax" : 1 ,
262- "mesh.nx" : 100 ,
263- "mesh.ny" : 100 }
253+ "mesh.yrboundary" : "outflow" }
264254
265255 myd , bc , _ = setup_test (extra_rp_params = extra_rp_params )
266256
267257 # create an array of particles with some at the edge of the domain.
268- init_particle_positions = [[0.5 , 0.2 ], [0.5 , 0.8 ],
269- [0.2 , 0.5 ], [0.8 , 0.5 ],
270- [0.5 , 0.4 ], [0.6 , 0.5 ]]
258+ init_particle_positions = [[0.5 , 0.03 ], [0.5 , 0.96 ],
259+ [0.04 , 0.5 ], [0.97 , 0.5 ],
260+ [0.5 , 0.2 ], [0.8 , 0.5 ]]
271261
272262 ps = particles .Particles (myd , bc , 4 , "array" , init_particle_positions )
273263
@@ -283,7 +273,7 @@ def test_outflow_bcs():
283273 u [(x > y ) & (x > (1 - y ))] = 1
284274 v [(x > y ) & (x < (1 - y ))] = - 1
285275
286- ps .update_particles (0.3 , u , v )
276+ ps .update_particles (0.1 , u , v )
287277
288278 assert len (ps .particles ) == 2 , "All but two of the particles should have flowed out of the domain"
289279
0 commit comments