Skip to content

Commit

Permalink
Setup properties in the end & correct exact sol
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavmuta authored and prabhuramachandran committed Apr 16, 2020
1 parent 8f29c29 commit 0589377
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 8 additions & 7 deletions pysph/examples/cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ def create_particles(self):

print("Lid driven cavity :: Re = %d, dt = %g" % (self.re, self.dt))

# add requisite properties to the arrays:
self.scheme.setup_properties([fluid, solid])

# setup the particle properties
volume = dx * dx

Expand All @@ -115,21 +112,25 @@ def create_particles(self):
fluid.rho[:] = rho0
solid.rho[:] = rho0

# volume is set as dx^2
fluid.V[:] = 1. / volume
solid.V[:] = 1. / volume

# smoothing lengths
fluid.h[:] = hdx * dx
solid.h[:] = hdx * dx

# imposed horizontal velocity on the lid
solid.u[:] = 0.0
solid.v[:] = 0.0

for i in range(solid.get_number_of_particles()):
if solid.y[i] > L:
solid.u[i] = Umax

# add requisite properties to the arrays:
self.scheme.setup_properties([fluid, solid])

# volume is set as dx^2
fluid.V[:] = 1. / volume
solid.V[:] = 1. / volume

return [fluid, solid]

def post_process(self, info_fname):
Expand Down
11 changes: 6 additions & 5 deletions pysph/examples/poiseuille.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ def _plot_ke_history(self):
t, ke = get_ke_history(self.output_files, 'fluid')
plt.clf()
plt.plot(t, ke)
plt.xlabel('t'); plt.ylabel('Kinetic energy')
plt.xlabel('t')
plt.ylabel('Kinetic energy')
fig = os.path.join(self.output_dir, "ke_history.png")
plt.savefig(fig, dpi=300)
return t, ke
Expand All @@ -181,14 +182,14 @@ def _plot_u_vs_y(self):
fx = self.fx
nu = self.nu

ye = np.arange(-d, d+1e-3, 0.01)
ue = -0.5 * fx/nu * (ye**2 - d*d)
ye += d
ye = np.linspace(0, self.Ly, 100)
ue = 0.5 * fx/nu * ye*(self.Ly - ye)
from matplotlib import pyplot as plt
plt.clf()
plt.plot(ye, ue, label="exact")
plt.plot(y, u, 'ko', fillstyle='none', label="computed")
plt.xlabel('y'); plt.ylabel('u')
plt.xlabel('y')
plt.ylabel('u')
plt.legend()
plt.title('Velocity profile at %s'%tf)
fig = os.path.join(self.output_dir, "comparison.png")
Expand Down

0 comments on commit 0589377

Please sign in to comment.