Upload
others
View
19
Download
0
Embed Size (px)
Citation preview
Simulacao FısicaDinamica de Fluidos
Waldemar [email protected]
Tecgraf, DI/PUC-Rio
27 de Setembro de 2016
W. Celes, DI/PUC-Rio Dinamica de Fluidos 1
Sumario
Bibliografia:
I Physics Based AnimationErleben et al. (2005)
I Fast Fluid Dynamics Simulation on the GPUHarris (2004)
I Stable FluidsStam (1999)
I Particle-based fluid simulation for interactive applicationsMuller et al. (2003)
I Smoothed particle hydrodynamics: a meshfree particle methodLiu and Liu (2003)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 2
Dinamica de fluidosUm fluido e descrito por campos de valores
I velocidade: u
I pressao: p
I temperatura: T
I massa especıfica (density): ρ
I etc.
Simular um fluido significadeterminar a evolucao doscampos de valores no tempo
I Em especial, o campo develocidade
W. Celes, DI/PUC-Rio Dinamica de Fluidos 3
Equacao do movimentoMudanca de temperatura de um volume do fluido em movimento
I Uma partıcula do contınuo deste volumetem coordenadas: [x(t), y(t), z(t)]
I A mudanca no tempo do campotemperatura e dada por: T : <4 → <
A derivada total em relacao ao tempo e dada por:
dT
dt=
∂T
∂t+∂T
∂x
dx
dt+∂T
∂y
dy
dt+∂T
∂z
dz
dt
Com u = [ u v w ]T , tem-se:
dT
dt=
∂T
∂t+∂T
∂xu +
∂T
∂yv +
∂T
∂zw
I que descreve a mudanca de temperatura do fluido, seguindo o fluido(derivada material ou substancial)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 4
Equacao do movimentoMudanca de temperatura de um volume do fluido em movimento
I Uma partıcula do contınuo deste volumetem coordenadas: [x(t), y(t), z(t)]
I A mudanca no tempo do campotemperatura e dada por: T : <4 → <
A derivada total em relacao ao tempo e dada por:
dT
dt=
∂T
∂t+∂T
∂x
dx
dt+∂T
∂y
dy
dt+∂T
∂z
dz
dt
Com u = [ u v w ]T , tem-se:
dT
dt=
∂T
∂t+∂T
∂xu +
∂T
∂yv +
∂T
∂zw
I que descreve a mudanca de temperatura do fluido, seguindo o fluido(derivada material ou substancial)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 4
Equacao do movimentoMudanca de temperatura de um volume do fluido em movimento
I Uma partıcula do contınuo deste volumetem coordenadas: [x(t), y(t), z(t)]
I A mudanca no tempo do campotemperatura e dada por: T : <4 → <
A derivada total em relacao ao tempo e dada por:
dT
dt=
∂T
∂t+∂T
∂x
dx
dt+∂T
∂y
dy
dt+∂T
∂z
dz
dt
Com u = [ u v w ]T , tem-se:
dT
dt=
∂T
∂t+∂T
∂xu +
∂T
∂yv +
∂T
∂zw
I que descreve a mudanca de temperatura do fluido, seguindo o fluido(derivada material ou substancial)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 4
Operador substancial
O operador substancial de um fluxo u:
d
dt=
∂
∂t+ u.∇
I Aplicado a um valor escalar ou a um valor vetorialcomponente a componente
Assim, a segunda Lei de Newton em termos de derivadasubstancial por unidade de volume e:
ρd
dtu = f
ρ
(∂
∂t+ u.∇
)u = f
W. Celes, DI/PUC-Rio Dinamica de Fluidos 5
Operador substancial
O operador substancial de um fluxo u:
d
dt=
∂
∂t+ u.∇
I Aplicado a um valor escalar ou a um valor vetorialcomponente a componente
Assim, a segunda Lei de Newton em termos de derivadasubstancial por unidade de volume e:
ρd
dtu = f
ρ
(∂
∂t+ u.∇
)u = f
W. Celes, DI/PUC-Rio Dinamica de Fluidos 5
Equacao de Euler para fluidosConsiderando o gradiente de pressao como forca interna:
ρ
(∂
∂t+ u.∇
)u = −∇p
Acrescido da equacao para conservacao da massa (fluidosincompressıveis):
∇ .u = 0
diz-se que velocidade e um campo vetorial com divergencia livre
I Operador gradiente (aplicado a um valor escalar)
∇p =[
∂p∂x
∂p∂y
∂p∂z
]T
I Operador divergente (aplicado a um valor vetorial)
∇ .u =∂u
∂x+∂v
∂y+∂w
∂z
W. Celes, DI/PUC-Rio Dinamica de Fluidos 6
Equacao de Euler para fluidosConsiderando o gradiente de pressao como forca interna:
ρ
(∂
∂t+ u.∇
)u = −∇p
Acrescido da equacao para conservacao da massa (fluidosincompressıveis):
∇ .u = 0
diz-se que velocidade e um campo vetorial com divergencia livre
I Operador gradiente (aplicado a um valor escalar)
∇p =[
∂p∂x
∂p∂y
∂p∂z
]T
I Operador divergente (aplicado a um valor vetorial)
∇ .u =∂u
∂x+∂v
∂y+∂w
∂z
W. Celes, DI/PUC-Rio Dinamica de Fluidos 6
Equacao de Navier-StokesConsidera a viscosidade do fluido (e forca externa)
ρ
(∂
∂t+ u.∇
)u = −∇p + µ∇2u + f
I ρ: massa especıfica (density)I µ: viscosidade dinamica
I Viscosidade cinematica: ν = µ/ρ
I Operador Laplaciano (aplicado a um valor escalar):
∇2u =∂2u
∂x2+∂2u
∂y2+∂2u
∂z2
I Equacoes de Poisson:
∇2x = b
W. Celes, DI/PUC-Rio Dinamica de Fluidos 7
Formulacao EulerianaGrade regular 2D
Gradiente:
∇p =[
pi+1,j−pi−1,j
2δpi,j+1−pi,j−1
2δ
]
Divergente:
∇ .u =ui+1,j − ui−1,j
2δ+
vi ,j+1 − vi ,j−1
2δ
Laplaciano:
∇2u =ui+1,j − 2ui ,j + ui−1,j
δ2+
ui ,j+1 − 2ui ,j + ui ,j−1
δ2
=ui+1,j + ui−1,j + ui ,j+1 + ui ,j−1 − 4ui ,j
δ2
W. Celes, DI/PUC-Rio Dinamica de Fluidos 8
Solucao da equacao de Navier-StokesEquacao de Navier-Stokes
ρ
(∂
∂t+ u.∇
)u = −∇p + µ∇2u + f
∂u
∂t= −(u.∇) u− 1
ρ∇p + ν∇2u +
1
ρf
Decomposicao de Helmholtz-HodgeI Considerando um domınio D, sendo seu contorno (∂D) suave
e diferenciavel com normal n, um campo vetorial qualquer, w,pode ser decomposto na soma de dois campos vetoriais:
I Um campo vetorial divergente livre, vI Sendo v . n = 0 em ∂D
I O gradiente de um campo escalar, p
w = v +∇p
W. Celes, DI/PUC-Rio Dinamica de Fluidos 9
Solucao da equacao de Navier-StokesEquacao de Navier-Stokes
ρ
(∂
∂t+ u.∇
)u = −∇p + µ∇2u + f
∂u
∂t= −(u.∇) u− 1
ρ∇p + ν∇2u +
1
ρf
Decomposicao de Helmholtz-HodgeI Considerando um domınio D, sendo seu contorno (∂D) suave
e diferenciavel com normal n, um campo vetorial qualquer, w,pode ser decomposto na soma de dois campos vetoriais:
I Um campo vetorial divergente livre, vI Sendo v . n = 0 em ∂D
I O gradiente de um campo escalar, p
w = v +∇p
W. Celes, DI/PUC-Rio Dinamica de Fluidos 9
Solucao da equacao de Navier-Stokes
Procedimento:
I Dado o estado inicial, u e p, calcula velocidade divergente: w
I Calcula campo de pressao
w = u +∇pAplicando o operador divergente nos dois lados:
∇ .w = ∇ . (u +∇p) = ∇ .u +∇2p
∇2p = ∇ .w
I Converte a velocidade resultante numa divergente livreI Para atender a equacao de conservacao de massa
u = w −∇p
W. Celes, DI/PUC-Rio Dinamica de Fluidos 10
Solucao da equacao de Navier-StokesComo calcular w
Operador de projecao PI Projeta vetor divergente w no seu divergente livre v
Pw = Pu + P(∇p)
como Pw = Pu = u, tem-se: P(∇p) = 0Aplicando o operador de projecao na equacao de Navier-Stokes:
P∂u
∂t= P
(−(u.∇) u− 1
ρ∇p + ν∇2u + f
)
∂u
∂t= P
(−(u.∇) u + ν∇2u + f
)
I Adveccao, difusao (dissipacao) e aplicacao da forca
S(u) = P F D A(u)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 11
Solucao da equacao de Navier-Stokes
Termo de adveccao
I Como as partıculas do fluidos sao transportadas pelo campode velocidade do proprio fluido
Transporte de cada partıcula do fluidoI Metodo de Euler explıcito: r(t + h) = r(t) + u(t) h
I Instavel!
I Metodo de Euler implıcito: r(t + h) = r(t) + u(t + h) h
Inversao do problema
I Qual quantidade passara a ocupar uma determinada posicaodo grid?
q(x, t + h) = q(x− u(x, t) h, t)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 12
Solucao da equacao de Navier-Stokes
Termo de adveccao
I Como as partıculas do fluidos sao transportadas pelo campode velocidade do proprio fluido
Transporte de cada partıcula do fluidoI Metodo de Euler explıcito: r(t + h) = r(t) + u(t) h
I Instavel!
I Metodo de Euler implıcito: r(t + h) = r(t) + u(t + h) h
Inversao do problema
I Qual quantidade passara a ocupar uma determinada posicaodo grid?
q(x, t + h) = q(x− u(x, t) h, t)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 12
Solucao da equacao de Navier-Stokes
Termo de difusao
∂u
∂t= ν∇2u
I Metodo explıcito
u(x, t + h) = u(x, t) + ν h∇2u(x, t)
I Metodo implıcito
(I− ν h∇2) u(x, t + h) = u(x, t)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 13
Solucao das equacoes de Poisson
Equacoes de Poisson:
∇2p = ∇ .w(I− ν h∇2) u(x, t + h) = u(x, t)
Metodo de relaxacao
I Iteracao de Jacobi
A x = b, onde A representa o Laplaciano
x(k+1)i ,j =
xki−1,j+xki+1,j+xki,j−1+xki,j+1+α bi,jβ
I Para pressao: x → p, b → ∇ .w, α = −δ2 e β = 4
I Para difusao: x , b → u, α = δ2/νh e β = 4 + α
W. Celes, DI/PUC-Rio Dinamica de Fluidos 14
Solucao da equacao de Navier-Stokes
Termo de forca externa
I Pode-se usar Euler simples:
v(t + h) = v + h f(x, t)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 15
Solucao da equacao de Navier-Stokes
Condicoes de contorno
I Velocidade: deve satisfazer u .n = 0Ao longo de uma borda vertical:
u0,j + u1,j
2= 0 ∀ j ∈ [0,N]
I Para pressao: variacao deve ser nula
p1,j − p0,j
δ= 0
W. Celes, DI/PUC-Rio Dinamica de Fluidos 16
Condicoes de contorno
Exemplos (Foster and Metaxas, 1997)
Tipo de objeto un ut T Descricao
Concreto 0 0 T0 Pequena turbulencia
Parede rugosa 0 −ut T0 Grande turbulencia
Plastico liso 0 ut T0 Escoamento laminar
Radiador 0 0 Tuser Conveccao de calor
Janela aberta vuser 0 Tuser Entrada de “vento” quente
W. Celes, DI/PUC-Rio Dinamica de Fluidos 17
Aplicacoes
Injecao de tinta
I Valor escalar passivo: apenas carregado pelo fluido
I Concentracao de tinta (d) sofre adveccao
∂d
∂t= −(u .∇) d
I Adveccao com difusao
∂d
∂t= −(u .∇) d + γ∇2d + S
onde: γ indica coeficiente de difusao e S representa uma fonte
W. Celes, DI/PUC-Rio Dinamica de Fluidos 18
Aplicacoes
Empuxo termico
I Forca devido a variacao da temperatura:
fbuoy = σ (T − T0) j
onde:
I σ: valor escalar constante
I T : campo escalar de temperatura
I T0: temperatura ambiente
I j: direcao vertical
W. Celes, DI/PUC-Rio Dinamica de Fluidos 19
Formulacao LagrangianaSmoothed Particle Hydrodynamics (SPH)
Representacao integral de uma funcaoSeja f (x) uma funcao de campo:
f (x) =
∫
Ωf (x) δ(x− x) dx
onde Ω e o volume da integral e δ e a funcao Delta de Dirac:
δ(x− x) =
1, se x = x
0, se x 6= x
W. Celes, DI/PUC-Rio Dinamica de Fluidos 20
Funcao suavizadora
Substituindo δ por uma “funcao suavizadora” W (x− x, h), tem-se:
< f (x) >=
∫
Ωf (x)W (x− x, h) dx
onde h representa o comprimento caracterıstico
I Define a area de influencia da funcao W
Propriedades de W :
I Par: W (x) = W (−x)
I Normalizada:∫
Ω W (x− x, h) dx = 1
I Convergente: limh→0 W (x− x, h) = δ(x− x)I Compacta: W (x− x, h) = 0, ∀ |x− x| > k h
I A area efetiva da funcao suavizadora e dita domınio de suporte
W. Celes, DI/PUC-Rio Dinamica de Fluidos 21
Representacao integral da derivada de uma funcao
A aproximacao de ∇ . f (x) e dada por:
< ∇ f (x) >=
∫
Ω[∇ f (x)] W (x− x, h) dx
Sabendo-se que: [∇ f ]W = ∇ [f W ]− f ∇W , tem-se:
< ∇ f (x) >=
∫
Ω∇ [f (x)W (x− x, h)] dx−
∫
Ωf (x) ∇W (x− x, h) dx
W. Celes, DI/PUC-Rio Dinamica de Fluidos 22
Representacao integral da derivada de uma funcao
Teorema da Divergencia
∫
Ω∇ f dΩ =
∫
Sf .n dS Ω
S
n
Logo:
< ∇ f (x) >=
∫
S[f (x)W (x− x, h)] .n dS −
∫
Ωf (x) ∇W (x− x, h) dx
W. Celes, DI/PUC-Rio Dinamica de Fluidos 23
Representacao integral da derivada de uma funcao
Como W tem suporte compacto, se este nao sobrepor a fronteirado domınio, a integral na superfıcie se anula, ficando com:
< ∇ f (x) >= −∫
Ωf (x)∇W (x− x, h) dx
I A derivada da funcao e “transferida” para a da funcao W
Representacao integral do Laplaciano de uma funcao
I Analogamente:
< ∇2 f (x) >=
∫
Ωf (x) ∇2 W (x− x, h) dx
W. Celes, DI/PUC-Rio Dinamica de Fluidos 24
Aproximacao por partıculasSeja mj a massa da partıcula j :
mj = ∆Vj ρj
A representacao integral pode ser aproximada por:
< f (x) > =
∫
Ωf (x)W (x− x, h) dx
≈N∑
j=1
f (xj)W (x− xj , h) ∆Vj
=N∑
j=1
f (xj)W (x− xj , h)1
ρj(ρj ∆Vj)
=N∑
j=1
mj
ρjf (xj)W (x− xj , h)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 25
SPH: metodo de interpolacao
Valor do campo contınuo e aproximado por media ponderada deamostras na vizinhanca
W. Celes, DI/PUC-Rio Dinamica de Fluidos 26
Aproximacao por partıculasAvaliacao da funcao na posicao da partıcula i :
< f (xi ) >=N∑
j=1
mj
ρjf (xj)W (xi − xj , h)
Gradiente
I Tomado em relacao a partıcula i
< ∇ f (xi ) >=N∑
j=1
mj
ρjf (xj)∇W (xi − xj , h)
Laplaciano
< ∇2 f (xi ) >=N∑
j=1
mj
ρjf (xj)∇2 W (xi − xj , h)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 27
Simulacao de fluido com SPHMuller et al. (2003)
Conservacao de massa
I Considerando o numero de partıcula e a massa de cadapartıculas valores constantes, a equacao de conservacao demassa e naturalmente satisfeita
Conservacao de momento
I Como as partıculas se movem com o fluido, nao e necessario otermo de adveccao da Equacao de Navier-Stokes
ρ∂u
∂t= −∇p + µ∇2u + f
W. Celes, DI/PUC-Rio Dinamica de Fluidos 28
Metodo numerico
Equacao diferencial:
a =du
dt=−∇p + µ∇2u + f
ρ
Integracao Leap-Frog:
vt+h/2i = v
t−h/2i + h ai
xt+hi = xti + h v
t+h/2i
W. Celes, DI/PUC-Rio Dinamica de Fluidos 29
Massa especıfica
Aplicando SPH:
ρi =∑
j
mjρjρj
W (xi − xj , h)
=∑
j
mj W (xi − xj , h)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 30
Forca de pressao
fpressurei = −∇p
Aplicando SPH:
fpressurei = −∑
j
mjpjρj∇W (xi − xj , h)
Para tornar simetrica, pode-se somar as pressoes:
fpressurei = −∑
j
mjpi + pj
2ρj∇W (xi − xj , h)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 31
Forca de pressao
Pressao em cada partıcula
I Lei ideal do gas (usada em Muller et al.)
p = k(ρ− ρ0)
I k: constante do gas (varia com temperatura)I ρ0: massa especıfica em repouso
I Equacao de TaitI Tende a ser mais estavel numericamente
p = B
(ρ
ρ0
γ− 1
), γ = 7
I Monaghan et al.: B = 200gHργ
I Becker et al.: B =ρ0 c2
sγ
W. Celes, DI/PUC-Rio Dinamica de Fluidos 32
Forca de viscosidade
fviscosityi = µ∇2u
Aplicando SPH:
fviscosityi = µ∑
j
mjvjρj∇2W (xi − xj , h)
Para tornar simetrica, pode-se usar a diferenca de velocidade:
fviscosityi = µ∑
j
mjvj − viρj
∇2W (xi − xj , h)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 33
Forca externa
Gravidade:
fexternali = ρ g
I Forcas externas (gravidade, impulso de colisao, etc.) podemser aplicadas diretamente nas partıculas, sem o uso de SPH
W. Celes, DI/PUC-Rio Dinamica de Fluidos 34
Tensao superficialModeladas explicitamente
I Representam as forcas intermoleculares
I Se anulam no interior do domınioI Existem na superfıcie livre
I Na direcao da normal, voltada para o interior do fluido
I Tendem a minimizar a curvatura da superfıcie livre
Proposta de Muller et al.:Campo escalar adicional: “campo de cor”
I Vale 1 nas partıculas e 0 no resto do domınio
cs =∑
j
mjcjρj
W (xi − xj , h)
=∑
j
mj1
ρjW (xi − xj , h)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 35
Tensao superficialA normal da superfıcie e dada pelo gradiente do campo:
n = ∇cs , na direcao do fluido
Curvatura:
κ =−∇2cs|n|
Tensao superficial:
tsurface = σ κn
|n|onde: σ= coeficiente de tensao da interface
Forca de superfıcieI Multiplica tensao por um campo escalar normalizado δs = |n|:
fsurface = σ κn = −σ∇2csn
|n|
W. Celes, DI/PUC-Rio Dinamica de Fluidos 36
Tensao superficial
Proposta de Becker:Modelada como forca de coesao entre as partıculas
dvidt
= − κ
mi
∑
j
mj(xi − xj) W (xi − xj)
W. Celes, DI/PUC-Rio Dinamica de Fluidos 37
Funcoes suavizadoresFuncao de uso geral
I Tem a vantagem de so usar r 2
Wpoly6(r, h) =315
64πh9
(h2 − r2)3, 0 ≤ r ≤ h
0
Funcao para avaliacao da pressaoI Evita agrupamento de partıculas com derivada positiva
para r pequenos
Wspiky (r, h) =15
πh6
(h − r)3, 0 ≤ r ≤ h
0
Funcao para avaliacao da viscosidadeI Evita Laplaciano com valor negativo
Wvisco(r, h) =15
2πh3
− r3
2h3 + r2
h2 + h2r − 1, 0 ≤ r ≤ h
0
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
W. Celes, DI/PUC-Rio Dinamica de Fluidos 38
Funcoes suavizadoresFuncao de uso geral
I Tem a vantagem de so usar r 2
Wpoly6(r, h) =315
64πh9
(h2 − r2)3, 0 ≤ r ≤ h
0
Funcao para avaliacao da pressaoI Evita agrupamento de partıculas com derivada positiva
para r pequenos
Wspiky (r, h) =15
πh6
(h − r)3, 0 ≤ r ≤ h
0
Funcao para avaliacao da viscosidadeI Evita Laplaciano com valor negativo
Wvisco(r, h) =15
2πh3
− r3
2h3 + r2
h2 + h2r − 1, 0 ≤ r ≤ h
0
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
W. Celes, DI/PUC-Rio Dinamica de Fluidos 38
Funcoes suavizadoresFuncao de uso geral
I Tem a vantagem de so usar r 2
Wpoly6(r, h) =315
64πh9
(h2 − r2)3, 0 ≤ r ≤ h
0
Funcao para avaliacao da pressaoI Evita agrupamento de partıculas com derivada positiva
para r pequenos
Wspiky (r, h) =15
πh6
(h − r)3, 0 ≤ r ≤ h
0
Funcao para avaliacao da viscosidadeI Evita Laplaciano com valor negativo
Wvisco(r, h) =15
2πh3
− r3
2h3 + r2
h2 + h2r − 1, 0 ≤ r ≤ h
0
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
Müller et al / Particle-Based Fluid Simulation for Interactive Applications
everywhere else. This field is called color field in the litera-
ture. For the smoothed color field we get:
cS(r) = ∑j
m j1
ρ jW (r− r j,h). (15)
The gradient field of the smoothed color field
n= ∇cs (16)
yields the surface normal field pointing into the fluid and the
divergence of n measures the curvature of the surface
κ =−∇2cs
|n| . (17)
The minus is necessary to get positive curvature for con-
vex fluid volumes. Putting it all together, we get for the sur-
face traction:
tsurface = σκ n|n| (18)
To distribute the surface traction among particles near the
surface and to get a force density we multiply by a normal-
ized scalar field δs = |n| which is non-zero only near thesurface. For the force density acting near the surface we get
fsurface = σκn= −σ∇2
cSn
|n| (19)
Evaluating n/|n| at locations where |n| is small causes nu-merical problems. We only evaluate the force if |n| exceedsa certain threshold.
3.4. External Forces
Our simulator supports external forces such as gravity, col-
lision forces and forces caused by user interaction. These
forces are applied directly to the particles without the use of
SPH. When particles collide with solid objects such as the
glass in our examples, we simply push them out of the ob-
ject and reflect the velocity component that is perpendicular
to the object’s surface.
3.5. Smoothing Kernels
Stability, accuracy and speed of the SPH method highly de-
pend on the choice of the smoothing kernels. The kernels
we use have second order interpolation errors because they
are all even and normalized (see Fig. 2). In addition, kernels
that are zero with vanishing derivatives at the boundary are
conducive to stability. Apart from those constraints, one is
free to design kernels for special purposes. We designed the
following kernel
Wpoly6(r,h) =315
64πh9
(h2− r2)3 0≤ r ≤ h
0 otherwise(20)
and use it in all but two cases. An important feature of this
simple kernel is that r only appears squared which means
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
0
2
4
6
8
10
12
14
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
–2
–1
0
1
2
–1 –0.8 –0.6 –0.4 –0.2 0.2 0.4 0.6 0.8 1
Figure 2: The three smoothing kernels Wpoly6, Wspiky and
Wviscosity (from left to right) we use in our simulations. The
thick lines show the kernels, the thin lines their gradients
in the direction towards the center and the dashed lines the
Laplacian. Note that the diagrams are differently scaled. The
curves show 3-d kernels along one axis through the center
for smoothing length h= 1.
that is can be evaluated without computing square roots in
distance computations. However, if this kernel is used for the
computation of the pressure forces, particles tend to build
clusters under high pressure. As particles get very close to
each other, the repulsion force vanishes because the gradient
of the kernel approaches zero at the center. Desbrun2 solves
this problem by using a spiky kernel with a non vanishing
gradient near the center. For pressure computations we use
Debrun’s spiky kernel
Wspiky(r,h) =15
πh6
(h− r)3 0≤ r ≤ h
0 otherwise,(21)
that generates the necessary repulsion forces. At the bound-
ary where it vanishes it also has zero first and second deriva-
tives.
Viscosity is a phenomenon that is caused by friction and,
thus, decreases the fluid’s kinetic energy by converting it into
heat. Therefore, viscosity should only have a smoothing ef-
fect on the velocity field. However, if a standard kernel is
used for viscosity, the resulting viscosity forces do not al-
ways have this property. For two particles that get close to
each other, the Laplacian of the smoothed velocity field (on
which viscosity forces depend) can get negative resulting in
forces that increase their relative velocity. The artifact ap-
pears in coarsely sampled velocity fields. In real-time appli-
cations where the number of particles is relatively low, this
effect can cause stability problems. For the computation of
viscosity forces we, thus, designed a third kernel:
Wviscosity(r,h) =15
2πh3
− r3
2h3+ r2
h2+ h2r −1 0≤ r ≤ h
0 otherwise.(22)
whose Laplacian is positive everywhere with the following
c© The Eurographics Association 2003.
W. Celes, DI/PUC-Rio Dinamica de Fluidos 38
Condicoes de contorno
Tratamento de colisao
I Muller et al.: Projeta e aplica impulso
I Monaghan et al.: Uso de partıculas de fronteira
W. Celes, DI/PUC-Rio Dinamica de Fluidos 39
Multiplos fluidosMuller et al. (2005)
Forca de viscosidade
pviscosityi =
∑
j
µi + µj2
mjvj − viρj
∇2W (xi − xj , h)
Lıquidos imiscıveisI Adiciona “campo de cor” para caracterizar interfaces
I Exemplo: c iwater = -0.5 , c ioil = 0.5
f interface = −σi ∇2c in
|n|Difusao de calor
∂T
∂t= k ∇2T
∂T
∂t= k
∑
j
mjTj − Ti
ρj∇2W (rij , h)
Ti ← Ti + ∆t∂T
∂t
ρ0 =α
T, sendo α cte
W. Celes, DI/PUC-Rio Dinamica de Fluidos 40
Referencia
Erleben, K., Sporring, J., Henriksen, K., and Dohlmann, H. (2005). Physics BasedAnimation. Charles River Media.
Foster, N. and Metaxas, D. (1997). Modeling the motion of a hot, turbulent gas. InSIGGRAPH ’97: Proceedings of the 24th annual conference on Computer graphicsand interactive techniques, pages 181–188, New York, NY, USA. ACMPress/Addison-Wesley Publishing Co.
Harris, M. (2004). Fast fluid dynamics simulation on the GPU, chapter 38.Addison-Wesley, Boston, USA.
Liu, G. R. and Liu, M. B. (2003). Smoothed particle hydrodynamics: a meshfreeparticle method. World Scientific Publishing Co.
Muller, M., Charypar, D., and Gross, M. (2003). Particle-based fluid simulation forinteractive applications. In SCA ’03: Proceedings of the 2003 ACMSIGGRAPH/Eurographics symposium on Computer animation, pages 154–159,Aire-la-Ville, Switzerland, Switzerland. Eurographics Association.
Muller, M., Solenthaler, B., Keiser, R., and Gross, M. (2005). Particle-based fluid-fluidinteraction. In SCA ’05: Proceedings of the 2005 ACM SIGGRAPH/Eurographicssymposium on Computer animation, pages 237–244, New York, NY, USA. ACM.
Stam, J. (1999). Stable fluids. In SIGGRAPH ’99: Proceedings of the 26th annualconference on Computer graphics and interactive techniques, pages 121–128, NewYork, NY, USA. ACM Press/Addison-Wesley Publishing Co.
W. Celes, DI/PUC-Rio Dinamica de Fluidos 41