|
12 | 12 |
|
13 | 13 | from simulation_null import NullSimulation, grid_setup, bc_setup |
14 | 14 | import multigrid.MG as MG |
| 15 | +import particles.particles as particles |
15 | 16 |
|
16 | 17 |
|
17 | 18 | class Simulation(NullSimulation): |
@@ -43,6 +44,9 @@ def initialize(self): |
43 | 44 |
|
44 | 45 | self.cc_data = my_data |
45 | 46 |
|
| 47 | + if self.rp.get_param("particles.do_particles") == 1: |
| 48 | + self.particles = particles.Particles(self.cc_data, bc, self.rp) |
| 49 | + |
46 | 50 | # now set the initial conditions for the problem |
47 | 51 | problem = importlib.import_module("incompressible.problems.{}".format(self.problem_name)) |
48 | 52 | problem.init_data(self.cc_data, self.rp) |
@@ -388,6 +392,10 @@ def evolve(self): |
388 | 392 | self.cc_data.fill_BC("x-velocity") |
389 | 393 | self.cc_data.fill_BC("y-velocity") |
390 | 394 |
|
| 395 | + if self.particles is not None: |
| 396 | + self.particles.update_particles(u, v, self.dt, limiter) |
| 397 | + self.particles.enforce_particle_boundaries() |
| 398 | + |
391 | 399 | # increment the time |
392 | 400 | if not self.in_preevolve: |
393 | 401 | self.cc_data.t += self.dt |
@@ -437,6 +445,15 @@ def dovis(self): |
437 | 445 |
|
438 | 446 | plt.colorbar(img, ax=ax) |
439 | 447 |
|
| 448 | + ax = axes.flat[0] |
| 449 | + if self.particles is not None: |
| 450 | + particle_positions = self.particles.get_positions() |
| 451 | + |
| 452 | + # plot particles |
| 453 | + ax.scatter(particle_positions[:, 0], particle_positions[:, 1], s=5) |
| 454 | + ax.set_xlim([myg.xmin, myg.xmax]) |
| 455 | + ax.set_ylim([myg.ymin, myg.ymax]) |
| 456 | + |
440 | 457 | plt.figtext(0.05, 0.0125, "t = {:10.5f}".format(self.cc_data.t)) |
441 | 458 |
|
442 | 459 | plt.pause(0.001) |
|
0 commit comments