|
12 | 12 | import mesh.boundary as bnd |
13 | 13 | from simulation_null import NullSimulation, grid_setup, bc_setup |
14 | 14 | import util.plot_tools as plot_tools |
| 15 | +import particles.particles as particles |
15 | 16 |
|
16 | 17 |
|
17 | 18 | class Variables(object): |
@@ -141,6 +142,9 @@ def initialize(self, extra_vars=None, ng=4): |
141 | 142 |
|
142 | 143 | self.cc_data = my_data |
143 | 144 |
|
| 145 | + if self.rp.get_param("particles.do_particles") == 1: |
| 146 | + self.particles = particles.Particles(self.cc_data, bc, self.rp) |
| 147 | + |
144 | 148 | # some auxillary data that we'll need to fill GC in, but isn't |
145 | 149 | # really part of the main solution |
146 | 150 | aux_data = self.data_class(my_grid) |
@@ -221,6 +225,13 @@ def evolve(self): |
221 | 225 | ymom[:, :] += 0.5*self.dt*(dens[:, :] + old_dens[:, :])*grav |
222 | 226 | ener[:, :] += 0.5*self.dt*(ymom[:, :] + old_ymom[:, :])*grav |
223 | 227 |
|
| 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 | + |
224 | 235 | # increment the time |
225 | 236 | self.cc_data.t += self.dt |
226 | 237 | self.n += 1 |
@@ -282,6 +293,18 @@ def dovis(self): |
282 | 293 | else: |
283 | 294 | ax.set_title(field_names[n]) |
284 | 295 |
|
| 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 | + |
285 | 308 | plt.figtext(0.05, 0.0125, "t = {:10.5g}".format(self.cc_data.t)) |
286 | 309 |
|
287 | 310 | plt.pause(0.001) |
|
0 commit comments