# Modeling and Rendering Viscous Liquids

**ABSTRACT** We present a particle-based algorithm for modeling highly viscous liquids. Using a numerical time-integration of particle acceleration and velocity, we apply external forces to particles and use a convenient organization, the adhesion matrix, to represent forces between different types of liquids and objects. Viscosity is handled by performing a momentum exchange between particle pairs such that momentum is conserved. Volume is maintained by iteratively adjusting particle positions after each time step. We use a two-tiered approach to time stepping that allows particle positions to be updated many times per frame while expensive operations, such as calculating viscosity and adhesion, are done only a few times per frame. The liquid is rendered using an implicit surface polygonization algorithm, and we present an implicit function that convolves the liquid surface with a Gaussian function, yielding a smooth liquid skin.

**0**Bookmarks

**·**

**66**Views

- Chinese Journal of Computers 01/2010; 33(7):1286-1294.
- SourceAvailable from: ocean.kisti.re.kr[Show abstract] [Hide abstract]

**ABSTRACT:**This paper presents a multi-phase fluid simulation that realistically represents small scale details. We achieve this by creating escaped particles based on physical methods. Escaped particles are the remained particles after correcting levelset. Generation of escaped particles in this paper differs from previous works; this fluid simulation is extended by adding lift force and drag force to positive escaped particles. And negative escaped particles represent droplet or splash effect; when they are merged into the negative levelset value, they affect the nodes' velocity (two-way coupling). This simulation that uses positive and negative escaped particles deals with detailed fluid motions dynamically in small scale.Journal of Korea Multimedia Society. 01/2009; 12(3). - SourceAvailable from: onlinelibrary.wiley.com[Show abstract] [Hide abstract]

**ABSTRACT:**We present a new method to create realistic paint simulation, utilizing the characteristics of paint, such as fluidity, diffusion, and absorption. We treat the painting elements separately as pigment, binder, solvent, and paper. Adopting smoothed-particle hydrodynamics including a consideration of viscoelastic movement, we simulate the fluid motion of the paint and the solvent. To handle the diffusion of the pigment in the solvent, we utilize the mass transfer method. Following Fick's law, the concentration of pigment changes and each pigment particle is diffused to the neighborhood accordingly. As time elapses, the binder and the solvent are absorbed, and for the most part, the pigment remains on the paper. The Lucas–Washburn equation determines the distance of absorption. The examples show that our approach can effectively generate various types of painting. Copyright © 2013 John Wiley & Sons, Ltd.Computer Animation and Virtual Worlds 05/2013; 24(3-4). · 0.44 Impact Factor

Page 1

Modeling and Rendering Viscous Liquids

Kevin Steele, David Cline, Parris K. Egbert, and Jonathan Dinerstein

Brigham Young University

3366 TMCB, Provo, Utah 84602, USA

Tel. 1(801)422-4029Fax. 1(801)422-0169

email: steele@rivit.cs.byu.edu, cline@rivit.cs.byu.edu, egbert@cs.byu.edu

We present a particle-based algorithm for modeling highly viscous liquids. Using a numerical time-integration of particle

acceleration and velocity, we apply external forces to particles and use a convenient organization, the adhesion matrix, to

represent forces between different types of liquids and objects. Viscosity is handled by performing a momentum exchange

between particle pairs such that momentum is conserved. Volume is maintained by iteratively adjusting particle positions after

each time step. We use a two-tiered approach to time stepping that allows particle positions to be updated many times per

frame while expensive operations, such as calculating viscosity and adhesion, are done only a few times per frame. The liquid

is rendered using an implicit surface polygonization algorithm, and we present an implicit function that convolves the liquid

surface with a Gaussian function, yielding a smooth liquid skin.

Keywords: computer animation, physically-based animation, fluid modeling

Introduction

Many early attempts to animate fluids in computer graphics have used a Lagrangian description of motion [1, 2, 3]. Lagrangian motion

focuses on individual particles and their properties such as position, velocity, and acceleration, and the influence particles have on one

another [4]. In contrast, much of the recent fluid animation research has used an Eulerian description of motion [4] in which groups of

particles participate in flow fields, and the flow properties are observed or specified at fixed spatial points in a Cartesian grid [5, 6, 7, 8],

usually by employing the Navier-Stokes equations for incompressible fluids. The Eulerian model has the advantage of being able to

accurately model liquids of lower viscosity. However it has a bounded simulation space due to the discrete nature of the flow sampling. In

contrast, the Lagrangian model has an unbounded simulation space (the particles are free to go anywhere), and may more easily simulate

non-Newtonian effects such as the stringiness exhibited by honey or the bounciness of egg white.

The purpose of this paper is to show that modeling and animating highly viscous liquids such as oil, liquid soap or honey can be done

efficientlyusingaLagrangianmodel, andbyovercomingtheproblemsof numericalinstabilityandvolumelossitcanyieldvisuallyaccurate

results and convincing behavior (see figure 1). In this paper we model large collections of liquid molecules as single particles, and compute

the interaction between particles in such a way as to behaviorally simulate an amount of liquid that a human might realistically interact

with. We employ particle systems to directly model the body of the liquid; individual particles represent a fixed region of liquid and are

given initial locations and velocities. A time-stepped simulation is then run and each particle’s position and velocity are updated according

to an Euler-step solution to the set of differential equations governing Newtonian motion.

Though simple, explicit Euler step integration tends to exhibit numerical instability. Another method for accurately computing particle

movement that guarantees stability for large time steps is implicit integration [9, 10]. Unfortunately, standard solutions to implicit integra-

tion require solving large, sparce matrices, where the sparseness is related to the particle neighborhood. In our system a typical particle

neighborhood may include sixty or more particles. We therefore use an explicit numerical solution to compute particle movement, and we

employ dampening strategies to reduce numerical instability.

Theliquid’sviscosityismodeledusingavelocitysmoothingmethodthatconservesmomentum. Thislocalsmoothingalsohelpsmaintain

numerical stability of our explicit integration scheme. We model multiple liquids interacting in the same simulation simply by assigning

to each particle a material type and then varying its interaction behavior with other particles based on their types. Liquids of different

1

Page 2

Figure 1: A spherical drop of simulated honey falls onto a suspended ball.

viscosities not only exhibit differing flow rates, but also behave differently when in contact with objects in their environment. To efficiently

accommodate the varying properties of different liquids, we define an adhesion matrix, a matrix of functions that control liquid behavior.

The adhesion matrix contains a row and column entry for each type of liquid and solid object in the simulation environment. Each matrix

cell contains a function that determines how velocities are modified when the materials in that cell’s row and column come into contact.

When using particles to model fluids in a CFD simulation, volume preservation is a continuing problem. We present a method to preserve

volume in our liquid simulation, and we optimize both the velocity computation and the volume preservation using adaptive timesteps.

To render the particle system we use a traditional implicit surface rendering method to generate surface triangles that can then be

rasterized or raytraced, and we present an implicit function that utilizes particle locality to define a smooth skin around the system. The

function is convolved to effectively eliminate local surface features produced from individual particles while still maintaining the larger

surface features of the liquid.

Collisions with objects in the simulation environment are detected and handled by embedding object particles in the surfaces of environ-

ment objects. Liquid particles respond to forces originating from collisions with object particles, so the same framework used to modify

liquid particle velocities can be used to resolve collisions of the liquid with scene objects. Additionally, interactions and collisions with

moving objects happen automatically without the need for handling special cases.

Particles are stored in a 3D spatial partitioning grid, and grid cells are indexed by location and stored in a hash table, permitting an

unbounded partitioning, near constant-time lookup for grid cells and constant time lookup for individual particles. Since all operations on

particle locations and velocities depend only on local particle neighbors, each iteration of the simulation takes O(n) time for a system of n

particles.

Related Work

The goal of accurately describing the behavior of liquid is not new. In the early 1800’s, Navier and Stokes jointly developed a set of

equations using conservation of momentum and mass that accurately describe fluid flow (see, for example [11]). Over the past two decades,

several approaches have been devised to graphically simulate fluid flow. The work that has been done can coarsely be divided into three

approaches. The first is a strictly surface-based approach where a parametric surface is used to model the surface of a liquid. The second

is a Lagrangian description of motion in which particles are used to represent the fluid. The third is an Eulerian approach in which the

Navier-Stokes equations are approximated or simulated to produce fluid flow.

Some of the early attempts at simulating fluid flow used parametric functions to approximate fluid surfaces. Schachter [12] used this

approach to model cresting waves. Fournier and Reeves [13] and Peachey [14] expanded this technique into a more general method for

modeling waves and surf. Kass and Miller [15] computed a height field for a fluid surface using 2D shallow water equations. Chen and

Lobo [5] extended their approach to include a contribution from the Navier-Stokes equations to the elevation of the height field.

Reeves introduced the idea of particle systems for the simulation of fluid [16]. This system provided particles with positions and

velocities, and then tracked the movement of those particles through time. Miller and Pearce [1] extended the particle system idea by

adding viscosity. They did this by attaching viscous springs to the particles to provide for inter-particle relationships. Terzopoulos, Platt

and Fleischer [2] used particles in a molecular dynamics approach to simulate object melting. Desbrun and Gascuel [17] introduced a

system to simulate soft objects using a particle system to define large-scale motion. They employed an isosurface defined by the particles to

determine contact forces and local deformations. Later, drawing on formalisms from physics literature, Desbrun and Gascuel [17] extended

Smoothed Particle Hydrodynamics (SPH) to simulate deformable bodies. Stora, et. al., [18] simulated lava flow using smoothed particles

2

Page 3

with a temperature-based viscosity. More recently, Tasdizen, et al. [19] used SPH to simulate realistic liquid flow, and Muller, Charypar

and Gross [20] use SPH to achieve interactive flow for a few thousand fluid particles.

In an attempt to model fluid flow in a more physically accurate manner, researchers have developed techniques to approximate or simulate

the Navier-Stokes equations. These techniques often give more accurate physical results, but have other problems such as burdensome

computation times or mass dissipation. Foster and Metaxas [7] use a finite-difference approximation to the Navier-Stokes equations to

determine gross liquid transport, then use local velocities to simulate finer fluid detail. They later refined their technique to simulate hot

gases [21]. Stam produced a numerically stable version using a semi-Lagrangian method instead of finite differences [8]. This technique

guaranteed stable results at relatively large time steps, but did not accurately handle dissipation. Fedkiw, Stam, and Jensen [22] extend this

technique to accurately model vorticities and interactions between smoke and moving objects. Foster and Fedkiw [6] use a semi-Lagrangian

method derived from Stam’s technique to solve for liquid motion using the Navier-Stokes equations. To prevent the mass dissipation typical

of this method, they use a level-set surface in conjunction with inertialess particles. This level set allows liquid movement but preserves

visual continuity of the liquid’s mass. Enright, Marschner and Fedkiw [23] refined the surface tracking of Foster and Metaxis, allowing

finer liquid details to be modeled. Carlson et al. [24] use the incompressible Navier-Stokes equations to simulate effects such as melting of

wax and the flow of highly viscous fluids.

We approach the problem of liquid animation from a Lagrangian description of motion. Our method differs from earlier particle-based

models [1, 18, 2] by providing more flexibility in the inter-particle forces controlling the animation, allowing us to simulate a wider variety

of viscous liquids. We also utilize a more aggressive density preservation model, enhancing the visual continuity of the animation.

Viscous Liquid Model

We use a particle system to model and animate liquid motion throughout the simulation. Each particle of the system represents a globule,

or a finitely small volume of liquid. The particle data structure contains the necessary data to accurately track the liquid through time

and space; it stores the location of the globule, its velocity, size, mass, and other data to facilitate rendering, such as its color properties,

proximity to the liquid surface, and surface normal. The entire system is stored in an array of particle structures.

Within the constraints of the simulation, the liquid is free to occupy any position in space independent of its containing data structure.

This is less restrictive than the Eulerian motion model where the liquid must stay within the predefined bounds of the sampled flow fields.

To accomplish this, we subdivide Cartesian space into fixed-sized cells indexed by their corner location. Only cells containing particles are

allocated in memory, and once a cell no longer contains particles it is deallocated. Cells are stored in a hash table and keyed by hashing

their corner locations with an array mapping function as in [25]:

hash key = 541i + 79j + 31k mod table size.

Hashing cell locations permits very fast, near constant-time lookup. This is critical since many computations on individual particles

involve accessing a list of particle neighbors. Hence a single iteration through the array of particles is an O(n) operation even when a list

of particle neighbors is fetched for each particle.

Liquid Motion

We begin with a simple particle transport model and apply viscosity and friction. For any particle, the instantaneous force applied is the

sum of all forces from neighboring particles plus the gravitational force:

F(p) =

?

f(pi) + g.

We start the simulation at time t0and successively apply forces at regular intervals of δt, where δt is the duration of one frame divided

by the number of substeps per frame. New velocities are computed from the applied forces and particle locations are subsequently updated

from the new velocities.

When a particle is processed in the simulation, forces are applied to the particle’s velocity and the particle is moved. We separate these

forces into three types: adhesion forces that attract particles to each other and to other objects, viscosity forces that limit shear movement

of particles in the liquid, and friction forces that dampen movement of particles in contact with objects in the environment. Each force type

is derived separately and applied in succession.

3

Page 4

Figure 2: Examples of adhesion functions used in our system. The function domains are specified in particle radius units so that a simulation

can be run with larger or smaller numbers of particles by just changing the standard particle radius. Generally, we define adhesion

functions with a support of 4 particle radii.

The size of the timestep δt greatly influences the accuracy of the simulation. Unfortunately, increasing the number of substeps per frame

so that the simulation is stable and accurate can be inefficient. Stora et al. [18] found that some simulations needed as many as 64 substeps

per displayed frame to maintain stability. Our experiments showed similar results.

One approach that has been taken to alleviate this computational burden is to use adaptive time steps for each particle in the simulation.

We tried this, but were only able to achieve a two-fold speedup over the naive approach. We found that a better approach for simulations

of viscous fluids was to separate operations that had to be performed every time a particle moved from those that did not. Thus, instead of

dozens of substeps per frame, we only use a few, 2 to 8 typically, but within each substep the particle positions are updated iteratively and

a collision model is applied to keep the particles properly separated. This simple innovation increased the speed of our simulations by four

to ten times.

The Adhesion Matrix

The adhesion force is an inter-particle force that attracts or repels other particles or objects in the environment. Since a liquid will flow

differently when in contact with different materials and when mixed with other liquids, the inter-particle force function may be different

for each unique type of particle pair. To organize and represent these forces we define a matrix of functions, the adhesion matrix, whose

cells contain the functions governing the adhesion of particle pair types. For example, an oil particle in the vicinity of steel particle would

receive an adhesion force Fsteel−oil(distance from steel).

Entries in the adhesion matrix include liquid types as well as materials with which liquids will interact. The shapes of the adhesion

functions in the adhesion matrix in large part determine the behavior of a simulated liquid. The force functions are user-definable in

our system; we use piecewise-linear functions. We found that defining complex functions with many sample points did not work better

than using simple ones with only a few sample points; only the overall shapes of the functions mattered. In addition, the results of our

simulations were similar whether the adhesion functions tapered off to zero or not. Noting this fact, we were able to reduce the support of

the adhesion functions, decreasing computation.

Although we experimented with a number of different adhesion functions, our animations only use three function types. The first

function type mimics a Leonard-Jones potential (repulsion at close distance and attraction at a greater distance) with the repulsion force

capped at about 10 times the maximum attractive force to help prevent numerical instability. This function type was used as the adhesive

force between particles of the same or similar fluids. The other two types of functions were either purely attractive or purely repulsive.

Attractive functions were used to make liquids cling to solid objects, and repulsive functions were useful when we wanted different fluid

types to repel each other or not mix. Figure 2 shows some functions from a typical adhesion matrix.

Viscosity Forces

As the viscosity of a liquid increases, the momenta of a liquid’s constituent particles increasingly tend toward that of their neighborhood

average. We model the viscosity of the liquid in a similar way. The resistance to shear particle movement due to viscosity, which we call

4

Page 5

the viscous force, is applied to a particle indirectly through an algorithmic momentum exchange between particles. Given a particle p, and

a viscosity constant v, which we define to be the percentage of momentum that a particle will exchange with its neighbors in one second,

the momentum exchange can be calculated. The momentum exchange proceeds by scaling the difference in momentum between the two

particles by a normalizing factor and a weighting function k, then adding the result Pexchto p’s momentum Ppand subtracting it from pn’s

momentum Ppn. Note that since the same amount of momentum is being exchanged between any two particles, the total momentum of the

system is conserved.

Pexch=vk(dpn)(Pp− Ppn)δt

2?n

Pp = Pp+ Pexch,

i=0k(di)

,

Ppn = Ppn− Pexch.

The normalizing factor in the equation is half of the viscosity constant divided by the total weight of the weighting function k, and diis

the distance from the particle being processed. This weighting function gives the user more flexibility in deciding how much momentum is

exchanged between two particles based on their separation distance. Similar to the adhesion functions, we found that subtle differences in

the weighting function did not significantly affect fluid behavior, but increasing the support of the weighting function increased the stiffness

of the material being simulated. In our simulations, we used a piece-wise approximation of a gaussian function for k with a support of

between 4 and 6 particle radii.

Once the forces have been accumulated and applied to each particle’s velocity vector, the particles are translated in an Euler-step fashion

for a numerical time-integration of its acceleration and velocity. Two problems commonly encountered with this type of simulation are

that Euler step integration is often numerically unstable, and when particles represent piecewise masses of a larger substance, the volume

of the substance does not remain constant. In our system the first problem is avoided by application of the viscous force computation. By

averaging each particle’s neighborhood velocity, the numerical instability of the timestep-integration is mitigated.

Friction and Interpenetration Prevention

Friction is only applied to particles that are in contact with scene objects. Rather than use the standard friction model for solid objects

with separate coefficients for static and kinetic friction forces, we use a simplified model more suitable for liquids. Each particle that is on

the surface of the liquid and that is in contact with an object will have its velocity dampened by a factor specific to that object type. To

avoid confusion with conventional friction coefficients, we refer to this term as the friction factor. The friction factor f is defined to be

the percentage of velocity dampening a particle experiences per second. If the current simulation iteration has 1/δt substep intervals per

second, then the velocity vt+δtwill be dampened each substep by

ˆ vt+δt= fδtvt+δt.

In practice, defining the friction as the percentage of velocity dampening per second required inconveniently small numbers, so we

instead define it as the percentage of velocity dampening per 1/30 of a second.

Inter-penetration prevention is essential to maintaining stability in the simulation and to help in the final volume preservation process. To

correct for particle inter-penetration, the particle system is again iteratively traversed and particles that are inter-penetrating are separated

to their contact distance. Figure 3 summarizes our complete liquid dynamics algorithm.

Volume Preservation

Volume preservation is perhaps the most difficult problem to solve. We assume a constant volume, and we take an iterative approach to

maintain the correct density at each particle location. First, a desired density for single particles is established. Then the particle positions

are adjusted after each substep of the simulation to correct for differences between the current liquid density and the desired density. This

process is performed iteratively after each sub-timestep until the density is within a specified tolerance of the desired density. Correcting to

within 2% of the desired density can be done with less than three density corrections per sub-timestep on average, totaling approximately

15% of the total simulation time. Additional accuracy can be achieved at a higher computational cost, however, if the density error threshold

is set too stringently, some instability in the system can result. Also, we note here that the volume correction procedure only corrects our

measure of density, not the actual volume enclosed by a rendered isosurface.

5