Skip to content

Commit da04206

Browse files
committed
Particles seem to work with compressible
1 parent c45145f commit da04206

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

compressible/_defaults

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ grav = 0.0 ; gravitational acceleration (in y-direction)
2121

2222
riemann = HLLC ; HLLC or CGF
2323

24+
[particles]
25+
do_particles = 1
26+
particle_generator = grid

compressible/simulation.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import mesh.boundary as bnd
1313
from simulation_null import NullSimulation, grid_setup, bc_setup
1414
import util.plot_tools as plot_tools
15+
import particles.particles as particles
1516

1617

1718
class Variables(object):
@@ -141,6 +142,9 @@ def initialize(self, extra_vars=None, ng=4):
141142

142143
self.cc_data = my_data
143144

145+
if self.rp.get_param("particles.do_particles") == 1:
146+
self.particles = particles.Particles(self.cc_data, bc, self.rp)
147+
144148
# some auxillary data that we'll need to fill GC in, but isn't
145149
# really part of the main solution
146150
aux_data = self.data_class(my_grid)
@@ -221,6 +225,13 @@ def evolve(self):
221225
ymom[:, :] += 0.5*self.dt*(dens[:, :] + old_dens[:, :])*grav
222226
ener[:, :] += 0.5*self.dt*(ymom[:, :] + old_ymom[:, :])*grav
223227

228+
if self.particles is not None:
229+
limiter = self.rp.get_param("compressible.limiter")
230+
u, v = self.cc_data.get_var("velocity")
231+
232+
self.particles.update_particles(u, v, self.dt, limiter)
233+
self.particles.enforce_particle_boundaries()
234+
224235
# increment the time
225236
self.cc_data.t += self.dt
226237
self.n += 1
@@ -282,6 +293,18 @@ def dovis(self):
282293
else:
283294
ax.set_title(field_names[n])
284295

296+
if self.particles is not None:
297+
ax = axes[0]
298+
particle_positions = self.particles.get_positions()
299+
# dye particles
300+
colors = self.particles.get_init_positions()[:, 0]
301+
302+
# plot particles
303+
ax.scatter(particle_positions[:, 0],
304+
particle_positions[:, 1], s=5, c=colors, alpha=0.8, cmap="Greys")
305+
ax.set_xlim([myg.xmin, myg.xmax])
306+
ax.set_ylim([myg.ymin, myg.ymax])
307+
285308
plt.figtext(0.05, 0.0125, "t = {:10.5g}".format(self.cc_data.t))
286309

287310
plt.pause(0.001)

compressible/tests/test_compressible.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def setup_method(self):
2323

2424
self.rp.params["mesh.nx"] = 8
2525
self.rp.params["mesh.ny"] = 8
26+
self.rp.params["particles.do_particles"] = 0
2627

2728
self.rp.params["eos.gamma"] = 1.4
2829
self.rp.params["compressible.grav"] = 1.0

compressible_rk/tests/test_compressible_rk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def setup_method(self):
1919

2020
self.rp.params["mesh.nx"] = 8
2121
self.rp.params["mesh.ny"] = 8
22+
self.rp.params["particles.do_particles"] = 0
2223

2324
self.rp.params["eos.gamma"] = 1.4
2425
self.rp.params["compressible.grav"] = 1.0

0 commit comments

Comments
 (0)