Professional Documents
Culture Documents
Fluid dynamics
1. Only particles inside circle contribute to the average 2. Close particles should contribute more than distant particles
Particle i
(mi , v i , ri , Fi , i , pi , Ci )
The Goal
The acceleration of a particle is
dvi pressure viscosity interactiv e gravity = ai + ai + ai + ai dt
Remember that ai =
Fi mi
Particle mass
In our simulation we choose to have the same mass for all particles, mi = m The mass m is calculated by
m=
(Density of
Let us now go back to the weighted averages How do we determine the density of a particle?
i = m jW (rij )
j
The sum include particle i Weight function or Kernel function
0.35 0.3
rij
What happens if particle i has no neighbours? The density calculation is done every time step
0 10 20 30 40 50 60 70 80 90 100
0.25
0.05
Surface tracking
It is not trivial to know where the surface is
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
6
Pressure
We get the pressure from the relation:
pi = cs ( i 0 )
2
(mi , v i , ri , Fi , i , pi , Ci )
Note that velocities and positions are calculated from the forces in a way similar to an ordinary particle system The next property we focus on is thus the force But before we go into that we need to learn more about taking averages
A i
j
mj
Example
j
mj
i
j j
mj
A i
j 2
jW (rij )
j
mj
m jW (rij )
A
i j
Meshless method!!
9
ij = Cijkl kl & ij = p ij + ij
All this together produces the following fluid equation called Navier-Stokes equation
f ext 1 dv = p + v + +g dt m
Note: fext could for example be an interactive force
10
Our task is now to convert each term on the RHS in Navier-Stokes to SPH-averages First term (pressure) becomes:
1 p
i
Pij W (rij )
j
where
pi pj Pij = m j 2 + 2 j i
11
where
i j
Note:
v = v
2
12
Summary
The acceleration of a particle can now be written:
Pij W (rij )
j
Remember that
viscosity
Vij W (rij )
2 j
Fi = mi ai
NOTE! Sometimes one uses different kernels for each term in RHS
interactive
1 interactive fi mi
ai
gravity
(0,0, g )
13
Simulation loop For each time step: 1. Find neighbors to each particle and store in a list 2. Calculate density for each particle 3. Calculate pressure for each particle 4. Calculate all type of accelerations for each particle, and sum it up 5. Find new velocities and positions by using the same integration method as before
14
Parameter values
Consider a container filled with 10 litre of water. We will use SI-units for all parameters. Number of SPH-particles: Mass: Density:
N = 1000
(water)
m = 0.01 kg
kg 0 = 1000 3 m
Interaction radius: h is chosen such that 15-20 particles are interacting on average Dynamical viscosity: Speed of sound:
Speed of sound:
m cs = 1500 (water) => Time step: dt = 0.0001 s s m cs = 1 10 => Time step: dt = 0.01 0.03s s
15
kg = 0.001 ms
Implementation of color field method for finding surface particles Use Powray to raytrace images or animations Implementation of flame propagation Implementation of surface tension
16
17
C i
j
mj
C jW (rij )
Deviations of the color field show us where the surface is, and in this case we choose to study the derivative of color field
18
mj
C j W (rij )
When the magnitude of the gradient is larger than a certain value, we tag the particle as a surface particle
19
Flame propagation
It is easy to introduce a simplified fire model by using the color field technique
1. Add three new particle properties i. Burnable ii. Burn (on/off) iii. Burning time 2. For all surface particles that are burning i. Calculate an average color field gradient using the variable Burnable as particle color
ii. Find all surface particles with average color field gradient higher than a certain value and flag them as burning (Burn on) iii. Decrease Burning time and check if Burn should be off 3. Visualize burning particles
20
Surface tension
The force that tends to make surfaces smooth (like a drop of liquid) can be modeled in the following way: ni s 2 tension ai = C i n i i where n i = C
i
and
C
2 i j
mj
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 n i / n i if the magnitude of ni exceeds a certain threshold.
21