Skip to content

Commit 181ad07

Browse files
committed
Plausible results for incompressible
1 parent 1f1a09f commit 181ad07

5 files changed

Lines changed: 27 additions & 7 deletions

File tree

advection/simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def evolve(self):
8989
self.particles.update_particles(u2d, v2d, self.dt,
9090
self.rp.get_param("advection.limiter"))
9191

92+
self.particles.enforce_particle_boundaries()
93+
9294
# increment the time
9395
self.cc_data.t += self.dt
9496
self.n += 1

incompressible/_defaults

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ proj_type = 2 ; what are we projecting? 1 includes -Gp term in U*
44

55
[driver]
66
cfl = 0.8
7+
8+
[particles]
9+
do_particles = 1
10+
particle_generator = grid

incompressible/simulation.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from simulation_null import NullSimulation, grid_setup, bc_setup
1414
import multigrid.MG as MG
15+
import particles.particles as particles
1516

1617

1718
class Simulation(NullSimulation):
@@ -43,6 +44,9 @@ def initialize(self):
4344

4445
self.cc_data = my_data
4546

47+
if self.rp.get_param("particles.do_particles") == 1:
48+
self.particles = particles.Particles(self.cc_data, bc, self.rp)
49+
4650
# now set the initial conditions for the problem
4751
problem = importlib.import_module("incompressible.problems.{}".format(self.problem_name))
4852
problem.init_data(self.cc_data, self.rp)
@@ -388,6 +392,10 @@ def evolve(self):
388392
self.cc_data.fill_BC("x-velocity")
389393
self.cc_data.fill_BC("y-velocity")
390394

395+
if self.particles is not None:
396+
self.particles.update_particles(u, v, self.dt, limiter)
397+
self.particles.enforce_particle_boundaries()
398+
391399
# increment the time
392400
if not self.in_preevolve:
393401
self.cc_data.t += self.dt
@@ -437,6 +445,15 @@ def dovis(self):
437445

438446
plt.colorbar(img, ax=ax)
439447

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+
440457
plt.figtext(0.05, 0.0125, "t = {:10.5f}".format(self.cc_data.t))
441458

442459
plt.pause(0.001)

particles/particles.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ def update_particles(self, u, v, dt, limiter=0):
185185
v_vel -= y_frac*(1.0 + cy)*ldelta_vy.v()[x_idx, y_idx]
186186
else:
187187
v_vel += y_frac*(1.0 - cy)*ldelta_vy.v()[x_idx, y_idx]
188-
189-
# transverse velocity
190-
u_vel += y_frac / myg.dy * ldelta_uy.v()[x_idx, y_idx]
191-
v_vel += x_frac / myg.dx * ldelta_vx.v()[x_idx, y_idx]
188+
#
189+
# # transverse velocity
190+
u_vel += y_frac * ldelta_uy.v()[x_idx, y_idx]
191+
v_vel += x_frac * ldelta_vx.v()[x_idx, y_idx]
192192

193193
p.advect(u_vel, v_vel, dt)
194194

pyro.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ def doit(solver_name, problem_name, param_file,
9696
# evolve for a single timestep
9797
sim.evolve()
9898

99-
if sim.particles is not None:
100-
sim.particles.enforce_particle_boundaries()
101-
10299
if verbose > 0:
103100
print("%5d %10.5f %10.5f" % (sim.n, sim.cc_data.t, sim.dt))
104101

0 commit comments

Comments
 (0)