Smoothed Particle Hydrodynamics (SPH)

Download Report

Transcript Smoothed Particle Hydrodynamics (SPH)

Smoothed Particle Hydrodynamics (SPH)
Some particle properties
are determined by
taking an average over
neighboring particles
The fluid is
represented by a
particle system
Fluid dynamics
1. Only neighbors contribute to the average
2. Close particles should contribute more than
distant particles
In the average: Use a weight function
Before we consider the details…
How do we describe our particle system?
Each particle is specified by a state list:
mass, velocity, position, force,
density, pressure, color
Particle i
(mi , v i , ri , Fi , i , pi , Ci )
The Goal
The acceleration of a particle is
dvi
pressure
viscosity
interactive
gravity
 ai
 ai
 ai
 ai
dt
Let us now learn how to set up the particle list…
Particle mass
In our simulation we choose to have the same mass for
all particles, mi = m
The mass m is calculated by

Density of
m
fluid   Total volume
Total number of particles
Note! Do not change the mass during the simulation
Let us now go back to the weighted averages…
How do we determine the density of a particle?
i   m jW (rij )
j
rij
Weight function or
Kernel function
0.35
0.3
•The density calculation is done every
time step
0.25
W
0.2
0.15
•The neighbor list must be updated
every time step
0.1
0.05
0
0
10
20
30
40
50
60
70
80
90
100
Surface tracking
It is not trivial to know where the surface should be…


We can find the surface by monitoring the density
If the density at a particle deviates too much compared
to expected density we tag it as a surface particle
Pressure
We get the pressure from the relation:
pi  cs i  0 
2
where cs is the speed of sound and ρ0
is the fluid reference density
Let us take a look on the particle property
list again
(mi , v i , ri , Fi , i , pi , Ci )

The next property we focus on is the force

Velocities and positions are calculated from the forces in a
way similar to an ordinary particle system

But before we go into that we need to learn more about
taking averages…
In SPH we formally define averages in the following
way:
A(r )   A(r ' )W (r  r ' )dr '
V
In practice we use a discrete version of this:
A i 
j
mj
j
A i  
j
i
j
A jW (rij )
mj
j
 A 
2
Example
mj
j
 i 
j
A j W (rij )
mj
j
 jW (rij )
  m jW (rij )
j
A j  2W (rij )
Meshless method!!
Velocities and Forces
Motion equation in elasticity:
We also had:
Now we instead use:
dv 1
1
     Fext
dt 

  C
   p  
All this together produces the following fluid
equation called Navier-Stokes equation
dv
1

1
  p    v  Fext  g
dt




Our task is now to convert each term on the
RHS in Navier-Stokes to SPH-averages

First term (pressure) becomes:

where
1

  PijW (rij )
p
i
j
m j  pi
pj 


Pij  

 j  i 2  j 2 
 The
second term (viscosity):

   v   Vij 2W (rij )

j
i
where
m j  vi
vj 


Vij   

 j  i 2  j 2 
Summary
The acceleration of a particle can now be written:
dvi
pressure
viscosity
interactive
gravity
 ai
 ai
 ai
 ai
dt
ai
pressure
  PijW (rij )
j
ai
viscosity
 VijW (rij )
j
ai
interactive
ai
gravity

1
i
Fi
interactive
 (0,0, g )
For each time step:
 Find neighbors to each particle and store in a
list
 Calculate density for each particle
 Calculate pressure for each particle
 Calculate all type of accelerations for each
particle, and sum it up
 Find new velocities and positions by using the
same integration method as before…
The color property?
What is the use of this property?




We can use it to detect the position of the surface of
our fluid
We can also use it to find the normal vectors at the
surface (important for rendering!)
The normal vectors allow us to implement surface
tension
By adding several color fields we can for example
implement a simple model of flame propagation
The color field

The color parameter is a quantity that is zero everywhere
except at the particle where it has a finite value

Similar to how we calculated density we now calculate
the average color at particle i as
C i 
j

mj
j
C jW (rij )
Deviations of the color field show us where the surface is,
and this case we choose to study the derivative of color
field
 The
gradient of a color field is
C i  
j
 When
mj
j
C j W (rij )
the magnitude of the gradient is
larger than a certain value, we tag the
particle as a surface particle
Surface tension
The force that tends to make surfaces
smooth (like a drop of liquid) can be
modeled in the following way:
ai
tension
where ni  C
i
  s  C
ni
ni
2
and
i
 C 
2
i
j
mj
j
C j  2W (rij )
Note: If the magnitude of ni is small we can get numerical problem in the
division above. To avoid this we only calculate ni / ni if the magnitude of
ni exceeds a certain threshold.