Skip to content

Commit

Permalink
Merged in arpitragarwal/pysph/TVF_no_slip (pull request #138)
Browse files Browse the repository at this point in the history
BUG: Correcting the velocity extrapolation for the no-slip BC
  • Loading branch information
prabhuramachandran committed Jan 30, 2015
2 parents 04a0a9c + 444a52f commit 5c841be
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 107 deletions.
25 changes: 16 additions & 9 deletions examples/SPHERIC/moving_square.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from pysph.sph.wc.transport_velocity import SummationDensity,\
StateEquation, MomentumEquationPressureGradient, MomentumEquationViscosity,\
MomentumEquationArtificialStress, SolidWallPressureBC, SolidWallNoSlipBC,\
ShepardFilteredVelocity
SetWallVelocity

# domain and reference values
Lx = 10.0; Ly = 5.0
Umax = 1.0
Expand Down Expand Up @@ -83,9 +83,16 @@ def _setup_particle_properties(particles, volume):
solid.add_property('V' )
obstacle.add_property('V' )

# Shepard filtered velocities for the fluid
# extrapolated velocities for the fluid
for name in ['uf', 'vf', 'wf']:
fluid.add_property(name)
solid.add_property(name)
obstacle.add_property(name)

# dummy velocities for the solid and obstacle
# required for the no-slip BC
for name in ['ug', 'vg', 'wg']:
solid.add_property(name)
obstacle.add_property(name)

# advection velocities and accelerations for fluid
for name in ('uhat', 'vhat', 'what', 'auhat', 'avhat', 'awhat', 'au', 'av', 'aw'):
Expand Down Expand Up @@ -238,7 +245,7 @@ def loop(self, d_idx, d_ax, t=0.0):
equations = [

# set the acceleration for the obstacle using the special function
# mimicing the accelerations provided in the test.
# mimicking the accelerations provided in the test.
Group(
equations=[
SPHERICBenchmarkAcceleration(dest='obstacle', sources=None),
Expand All @@ -254,14 +261,14 @@ def loop(self, d_idx, d_ax, t=0.0):
SummationDensity(dest='fluid', sources=['fluid','solid','obstacle']),
], real=False),


# Once the fluid density is computed, we can use the EOS to set
# the fluid pressure. Additionally, the shepard filtered velocity
# for the fluid phase is determined.
# the fluid pressure. Additionally, the dummy velocity for the
# channel is set, which is later used in the no-slip wall BC.
Group(
equations=[
StateEquation(dest='fluid', sources=None, p0=p0, rho0=rho0, b=1.0),
ShepardFilteredVelocity(dest='fluid', sources=['fluid']),
SetWallVelocity(dest='solid', sources=['fluid']),
SetWallVelocity(dest='obstacle', sources=['fluid']),
], real=False),

# Once the pressure for the fluid phase has been updated, we can
Expand Down
2 changes: 1 addition & 1 deletion examples/surface_tension/circular_droplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pysph.sph.wc.viscosity import ClearyArtificialViscosity

from pysph.sph.wc.transport_velocity import SummationDensity, MomentumEquationPressureGradient,\
SolidWallPressureBC, SolidWallNoSlipBC, ShepardFilteredVelocity, \
SolidWallPressureBC, SolidWallNoSlipBC, \
StateEquation, MomentumEquationArtificialStress, MomentumEquationViscosity

from pysph.sph.surface_tension import ColorGradientUsingNumberDensity, \
Expand Down
22 changes: 14 additions & 8 deletions examples/surface_tension/khi_tvf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pysph.sph.wc.viscosity import ClearyArtificialViscosity

from pysph.sph.wc.transport_velocity import SummationDensity, MomentumEquationPressureGradient,\
SolidWallPressureBC, SolidWallNoSlipBC, ShepardFilteredVelocity, \
SolidWallPressureBC, SolidWallNoSlipBC, SetWallVelocity, \
StateEquation, MomentumEquationArtificialStress, MomentumEquationViscosity

from pysph.sph.surface_tension import ColorGradientUsingNumberDensity, \
Expand Down Expand Up @@ -95,10 +95,7 @@ def create_particles(**kwargs):

# interface curvature
'kappa',

# filtered velocities
'uf', 'vf', 'wf',


# transport velocities
'uhat', 'vhat', 'what', 'auhat', 'avhat', 'awhat',

Expand Down Expand Up @@ -153,7 +150,16 @@ def create_particles(**kwargs):
# set additional output arrays for the fluid
fluid.add_output_arrays(['V', 'color', 'cx', 'cy', 'nx', 'ny', 'ddelta',
'kappa', 'N', 'p', 'rho'])

# extrapolated velocities for the wall
for name in ['uf', 'vf', 'wf']:
wall.add_property(name)

# dummy velocities for the wall
# required for the no-slip BC
for name in ['ug','vg','wg']:
wall.add_property(name)

print "2D KHI with %d fluid particles and %d wall particles"%(
fluid.get_number_of_particles(), wall.get_number_of_particles())

Expand Down Expand Up @@ -186,13 +192,13 @@ def create_particles(**kwargs):
] ),

# Given the updated number density for the fluid, we can update
# the fluid pressure. Additionally, we can compute the Shepard
# Filtered velocity required for the no-penetration boundary
# the fluid pressure. Additionally, we can extrapolate the fluid
# velocity to the wall for the no-slip boundary
# condition. Also compute the smoothed color based on the color
# index for a particle.
Group(equations=[
StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
ShepardFilteredVelocity(dest='fluid', sources=['fluid']),
SetWallVelocity(dest='wall', sources=['fluid']),
SmoothedColor( dest='fluid', sources=['fluid'] ),
] ),

Expand Down
9 changes: 3 additions & 6 deletions examples/surface_tension/square_droplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
from pysph.sph.wc.viscosity import ClearyArtificialViscosity

from pysph.sph.wc.transport_velocity import SummationDensity, MomentumEquationPressureGradient,\
SolidWallPressureBC, SolidWallNoSlipBC, ShepardFilteredVelocity, \
StateEquation, MomentumEquationArtificialStress, MomentumEquationViscosity
SolidWallPressureBC, SolidWallNoSlipBC, StateEquation,\
MomentumEquationArtificialStress, MomentumEquationViscosity

from pysph.sph.surface_tension import InterfaceCurvatureFromNumberDensity, \
ShadlooYildizSurfaceTensionForce, CSFSurfaceTensionForce, \
Expand Down Expand Up @@ -133,10 +133,7 @@ def create_particles(**kwargs):

# interface curvature
'kappa',

# filtered velocities
'uf', 'vf', 'wf',


# transport velocities
'uhat', 'vhat', 'what', 'auhat', 'avhat', 'awhat',

Expand Down
17 changes: 11 additions & 6 deletions examples/transport_velocity/cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pysph.sph.wc.transport_velocity import SummationDensity,\
StateEquation, MomentumEquationPressureGradient, MomentumEquationViscosity,\
MomentumEquationArtificialStress, SolidWallPressureBC, SolidWallNoSlipBC,\
ShepardFilteredVelocity
SetWallVelocity

# numpy
import numpy as np
Expand Down Expand Up @@ -72,9 +72,14 @@ def create_particles(**kwargs):
fluid.add_property('V')
solid.add_property('V' )

# Shepard filtered velocities for the fluid
# extrapolated velocities for the solid
for name in ['uf', 'vf', 'wf']:
fluid.add_property(name)
solid.add_property(name)

# dummy velocities for the solid wall
# required for the no-slip BC
for name in ['ug', 'vg', 'wg']:
solid.add_property(name)

# advection velocities and accelerations
for name in ('uhat', 'vhat', 'what', 'auhat', 'avhat', 'awhat', 'au', 'av', 'aw'):
Expand Down Expand Up @@ -148,12 +153,12 @@ def create_particles(**kwargs):


# Once the fluid density is computed, we can use the EOS to set
# the fluid pressure. Additionally, the shepard filtered velocity
# for the fluid phase is determined.
# the fluid pressure. Additionally, the dummy velocity for the
# channel is set, which is later used in the no-slip wall BC.
Group(
equations=[
StateEquation(dest='fluid', sources=None, p0=p0, rho0=rho0, b=1.0),
ShepardFilteredVelocity(dest='fluid', sources=['fluid']),
SetWallVelocity(dest='solid', sources=['fluid']),
], real=False),

# Once the pressure for the fluid phase has been updated, we can
Expand Down
24 changes: 14 additions & 10 deletions examples/transport_velocity/couette.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# the eqations
from pysph.sph.equation import Group
from pysph.sph.wc.transport_velocity import (SummationDensity,
ShepardFilteredVelocity, StateEquation,
SetWallVelocity, StateEquation,
MomentumEquationPressureGradient, MomentumEquationViscosity,
MomentumEquationArtificialStress,
SolidWallPressureBC, SolidWallNoSlipBC)
Expand All @@ -26,7 +26,7 @@
# domain and reference values
Re = 0.0125
d = 0.5; Ly = 2*d; Lx = 0.4*Ly
rho0 = 1.0; nu = 1.0
rho0 = 1.0; nu = 0.01

# upper wall velocity based on the Reynolds number and channel width
Vmax = nu*Re/(2*d)
Expand All @@ -43,7 +43,7 @@
dt_viscous = 0.125 * h0**2/nu
dt_force = 1.0

tf = 2.0
tf = 100.0
dt = 0.5 * min(dt_cfl, dt_viscous, dt_force)

def create_particles(**kwargs):
Expand Down Expand Up @@ -77,7 +77,7 @@ def create_particles(**kwargs):
# add requisite properties to the arrays:
# particle volume
fluid.add_property('V')
channel.add_property('V' )
channel.add_property('V')

# advection velocities and accelerations
for name in ('uhat', 'vhat', 'what', 'auhat', 'avhat', 'awhat', 'au', 'av', 'aw'):
Expand All @@ -86,14 +86,18 @@ def create_particles(**kwargs):
# kernel summation correction for the channel
channel.add_property('wij')


channel.add_property('ax')
channel.add_property('ay')
channel.add_property('az')

# Shepard filtered velocities for the fluid
# extrapolated velocities for the channel
for name in ['uf', 'vf', 'wf']:
fluid.add_property(name)
channel.add_property(name)

# dummy velocities for the channel
# required for the no-slip BC
for name in ['ug','vg','wg']:
channel.add_property(name)

# magnitude of velocity
fluid.add_property('vmag2')
Expand Down Expand Up @@ -157,12 +161,12 @@ def create_particles(**kwargs):
], real=False),

# Once the fluid density is computed, we can use the EOS to set
# the fluid pressure. Additionally, the shepard filtered velocity
# for the fluid phase is determined.
# the fluid pressure. Additionally, the dummy velocity for the
# channel is set, which is later used in the no-slip wall BC.
Group(
equations=[
StateEquation(dest='fluid', sources=None, p0=p0, rho0=rho0, b=1.0),
ShepardFilteredVelocity(dest='fluid', sources=['fluid']),
SetWallVelocity(dest='channel', sources=['fluid']),
], real=False),

# Once the pressure for the fluid phase has been updated, we can
Expand Down
19 changes: 12 additions & 7 deletions examples/transport_velocity/lattice_cylinders.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# the eqations
from pysph.sph.equation import Group
from pysph.sph.wc.transport_velocity import (SummationDensity,
ShepardFilteredVelocity, StateEquation,
SetWallVelocity, StateEquation,
MomentumEquationPressureGradient, MomentumEquationViscosity,
MomentumEquationArtificialStress,
SolidWallPressureBC, SolidWallNoSlipBC)
Expand Down Expand Up @@ -90,12 +90,17 @@ def create_particles(**kwargs):
solid.add_property('ay')
solid.add_property('az')

# Shepard filtered velocities for the fluid
# extrapolated velocities for the solid
for name in ['uf', 'vf', 'wf']:
fluid.add_property(name)
solid.add_property(name)

# dummy velocities for the solid wall
# required for the no-slip BC
for name in ['ug', 'vg', 'wg']:
solid.add_property(name)

# magnitude of velocity
fluid.add_property('vmag')
fluid.add_property('vmag2')

# density acceleration
fluid.add_property('arho')
Expand Down Expand Up @@ -152,12 +157,12 @@ def create_particles(**kwargs):


# Once the fluid density is computed, we can use the EOS to set
# the fluid pressure. Additionally, the shepard filtered velocity
# for the fluid phase is determined.
# the fluid pressure. Additionally, the dummy velocity for the
# channel is set, which is later used in the no-slip wall BC.
Group(
equations=[
StateEquation(dest='fluid', sources=None, p0=p0, rho0=rho0, b=1.0),
ShepardFilteredVelocity(dest='fluid', sources=['fluid']),
SetWallVelocity(dest='solid', sources=['fluid']),
], real=False),

# Once the pressure for the fluid phase has been updated, we can
Expand Down
17 changes: 11 additions & 6 deletions examples/transport_velocity/periodic_cylinders.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# the eqations
from pysph.sph.equation import Group
from pysph.sph.wc.transport_velocity import (SummationDensity,
ShepardFilteredVelocity, StateEquation,
SetWallVelocity, StateEquation,
MomentumEquationPressureGradient, MomentumEquationViscosity,
MomentumEquationArtificialStress,
SolidWallPressureBC, SolidWallNoSlipBC)
Expand Down Expand Up @@ -79,9 +79,9 @@ def create_particles(**kwargs):
fluid.add_property('V')
solid.add_property('V' )

# Shepard filtered velocities for the fluid
# extrapolated velocities for the solid
for name in ['uf', 'vf', 'wf']:
fluid.add_property(name)
solid.add_property(name)

# advection velocities and accelerations for the fluid
for name in ('uhat', 'vhat', 'what', 'auhat', 'avhat', 'awhat'):
Expand All @@ -90,6 +90,11 @@ def create_particles(**kwargs):
# kernel summation correction for the solid
solid.add_property('wij')

# dummy velocities for the solid walls
# required for the no-slip BC
for name in ['ug', 'vg', 'wg']:
solid.add_property(name)

# imposed accelerations on the solid
solid.add_property('ax')
solid.add_property('ay')
Expand Down Expand Up @@ -156,12 +161,12 @@ def create_particles(**kwargs):
], real=False),

# Once the fluid density is computed, we can use the EOS to set
# the fluid pressure. Additionally, the shepard filtered velocity
# for the fluid phase is determined.
# the fluid pressure. Additionally, the dummy velocity for the
# channel is set, which is later used in the no-slip wall BC.
Group(
equations=[
StateEquation(dest='fluid', sources=None, p0=p0, rho0=rho0, b=1.0),
ShepardFilteredVelocity(dest='fluid', sources=['fluid']),
SetWallVelocity(dest='solid', sources=['fluid']),
], real=False),

# Once the pressure for the fluid phase has been updated, we can
Expand Down
17 changes: 11 additions & 6 deletions examples/transport_velocity/poiseuille.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# the eqations
from pysph.sph.equation import Group
from pysph.sph.wc.transport_velocity import (SummationDensity,
ShepardFilteredVelocity, StateEquation,
SetWallVelocity, StateEquation,
MomentumEquationPressureGradient, MomentumEquationViscosity,
MomentumEquationArtificialStress,
SolidWallPressureBC, SolidWallNoSlipBC)
Expand Down Expand Up @@ -94,9 +94,14 @@ def create_particles(**kwargs):
channel.add_property('ay')
channel.add_property('az')

# Shepard filtered velocities for the fluid
# extrapolated velocities for the channel
for name in ['uf', 'vf', 'wf']:
fluid.add_property(name)
channel.add_property(name)

# dummy velocities for the channel
# required for the no-slip BC
for name in ['ug', 'vg', 'wg']:
channel.add_property(name)

# magnitude of velocity
fluid.add_property('vmag2')
Expand Down Expand Up @@ -154,12 +159,12 @@ def create_particles(**kwargs):
], real=False),

# Once the fluid density is computed, we can use the EOS to set
# the fluid pressure. Additionally, the shepard filtered velocity
# for the fluid phase is determined.
# the fluid pressure. Additionally, the dummy velocity for the
# channel is set, which is later used in the no-slip wall BC.
Group(
equations=[
StateEquation(dest='fluid', sources=None, p0=p0, rho0=rho0, b=1.0),
ShepardFilteredVelocity(dest='fluid', sources=['fluid']),
SetWallVelocity(dest='channel', sources=['fluid']),
], real=False),

# Once the pressure for the fluid phase has been updated, we can
Expand Down

0 comments on commit 5c841be

Please sign in to comment.