• No results found

Partial Differential Equations for Computer Animation

N/A
N/A
Protected

Academic year: 2021

Share "Partial Differential Equations for Computer Animation"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Partial Differential Equations

for Computer Animation

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Acknowledgement

• A major part of this slide set and all accompanying demos are courtesy of Matthias Müller, ETH Zurich, NovodeX AG.

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Motivation

• Most dynamic effects and physical processes can be described by partial differential equations PDEs • We give a short overviewof

a large research fieldin mathematics and physics

applied to the fields of animationand computer graphics • Goals

• You know what a PDE is

• You know PDEs for specific effects

• You know how to solve these PDEs numerically • You can use your knowledge to implement

your own effects and animations

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Introductory Example

• Simulate temperature evolution • One space dimension + time

T

x c T(x,0)

• Given the temperature distributionT(x,0)at time t=0 and wind speedc.

(2)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Advection

• How does the temperature change in one time step?

• PDE forT(x,t)is 1-d advection(transport) equation. x T T(x,t) T(x,t+∆t) c∆t ∆T x x T t c T ∂ ∂ ≈ ∆ ∆ − x T c t T ∂ ∂ − = ∂ ∂ x t cT T=− or 0 → ∆t

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Analytical Solution

• AnyT(x,t)of the form ) ( ) , (xt f x ct T = − solves

• AnyT(x,t)of the form

) ( ) 0 , (x T0 x T =

• The physical solution also needs to satisfy theinitial condition

• Thus, the solution is ) ( ) , (xt T0x ct T = − x t cT T=−

Tis obtained by shifting T0through a distance ctwithout

any change of shape of T0 .

• Only simple PDEs can be solved analytically.

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Numerical Solution – Finite Differences

..) 2 , 1 , 0 ( ), ,.., 1 ( ), , ( ] [i =Tiht⋅∆t in tTt • Sample T(x,t):

• Discretize the derivatives (e.g. first-order backward scheme) x t cT T=− h i T i T c t i T i Tt t t t ] 1 [ ] [ ] [ ] [ 1 − = ∆ − + h i T i T c t i T i T t t t t [] [ 1] ] [ ] [ 1 = − − +

• Solving forTt+1[i]yields the explicit update rule

• Before starting the simulation, initializeT0[i]

• Possible boundary conditions areperiodic boundaries ] 1 [ ] 1 [ ], [ ] 0 [ t t t t T n T n T T = + =

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Outline

Mathematical Background What is a PDE? Types of PDEs Boundary Conditions Solution Techniques Analytical Methods Numerical Methods Examples Advection Diffusion

(3)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Mathematical Definition of a PDE

• A Partial Differential Equation (PDE) is an equation that

determines the behavior of u in terms of

• partial derivatives of u, e.g. uxy, utt, • uitself and

• the independent variables, e.g. x,y,z,t x uu utt= xy+ • Example: ,..), , ( ,..), ( 2 2 2 y x u y x u t u t utt xy ∂ ∂ ∂ = ∂ ∂ = • Notation:

• Given a functionuof twoor more independent variables, e.g. u(x,y,z,t)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

PDEs in Physics

• Independent variables are

• Static Problem: x(1D),x,y(2D), x,y,z(3D)

• Dynamic Problem: x,t(1D+1)x,y,t(2D+1) x,y,z,t(3D+1) • Unknown functionucan be

u(x,..)a scalar,

e.g. temperatureT, densityρ

u(x,..)= [u(x,..), v(x,..), w(x,..)]Ta vector, e.g. displacementu, velocityv

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

PDE Classification

• Order

• Order of PDE = Order of highest partial derivative

0 ) , ( ) , ( ) , ( ) , ( ) , ( ) , ( ) , ( 7 6 5 4 3 2 1 = + + + + + + y x f u y x f u y x f u y x f u y x f u y x f u y x f y x yy xy xx

• 2ndorder linear PDE of 2 independent variables:

u u uxxxy= • Non-linear example • Linear

• u and its partial derivatives only occur linearly • coefficients may be functions of independent variables

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

PDE Classification

• Classification of 2ndorder linear PDEs

) , , , , ( ) , ( ) , ( 2 ) , (x yuxx B x yuxy Cx yuyy F xyuux uy A + + = • Hyperbolic B2-AC > 0 • Parabolic B2-AC = 0 • Elliptic B2-AC < 0 • Geometric motivation

• Different mathematical and physical behavior • Determines type of boundary conditions needed • For more than 2 independent variables use generalized

(4)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

PDE Classification

Hyperbolic

• time-dependent processes

• not evolving to a steady state, reversible

• propagate behavior undiminished, e. g. wave motion

Parabolic

• time-dependent processes

• evolving to a steady state, irreversible • dissipative, e. g. heat diffusion

Elliptic

• time-independent • already in steady state

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Boundary Conditions

• Generally, there aremanyuwhich solve the PDE • In physical applications onlyone solution is expected

x

t D

x0 x1

• Typically u is only defined in a regionD

• The physical solution is required to satisfy certain

conditions on the boundaryδDof D

Initialcondition ) ( ) 0 , (x u x u = o ) ( ) , (x1t f1t u = Value prescribed Dirichletcondition ) ( ) , (x0t f0t ux = Derivative prescribed Neumanncondition

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Outline

Mathematical Background What is a PDE? Types of PDEs Boundary Conditions Solution Techniques Analytical Methods Numerical Methods Examples Advection Diffusion

The Wave Equation

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Analytical Solution Techniques

• Analytical solutions only exist for small and simple problems

• linear equations, simple geometry, initial and boundary conditions

• Examples for analytical solution techniques (see textbooks): • Method of separation of variables

• Theory of characteristics • Green function method • Laplace transform

(5)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Numerical Solution - Overview

Governing Equations IC / BC Discretization System of Algebraic Equations Equation (Matrix) Solver Approx. Solution Continuous Solution Finite Difference Finite Volume Finite Element Spectral Boundary Element Discrete Nodal Values Explicit solution CG

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Discretization

Spatial derivatives

• Finite-difference method FDM • Finite-element method FEM • Finite-volume method FVM • Spectral methods

• Boundary element methods • …

Time derivatives

• Finite-difference methods

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

The Finite Difference Method

• Simplest method to understand and implement

) , , ( ] , , [i jt ui h j ht t u = ⋅ ⋅ ⋅∆

• Sample functionuon a regular grid, e.g.

,...) 2 , 1 , 0 ( ), ,.., 1 ( ), ,.., 1 ( ∈ ∈ ∈ n j m t i

• withgrid spacinghand time step∆t u[i,j,t]

h h

x y

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

The Finite Difference Method

• Approximation of the temporal derivative

• Approximation of spatial derivatives (three possibilities)

) ( ] , , [ ] 1 , , [ ] , , [ O t t t j i u t j i u t j i ut + ∆ − + = ) ( ] , , [ ] , , 1 [ ] , , [ Oh h t j i u t j i u t j i ux + − + = forwardscheme ) ( ] , , 1 [ ] , , [ ] , , [ Oh h t j i u t j i u t j i ux + − − = backwardscheme ) ( 2 ] , , 1 [ ] , , 1 [ ] , , [ 2 h O h t j i u t j i u t j i ux + − − + = centralscheme

• If information moves from left to right (as in ut= -cux) backward isupwind(upwind is best choice)

(6)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

The Finite Difference Method

• Approximation of higher derivatives

) ( ] , , 1 [ ] , , [ 2 ] , , 1 [ ] , , 1 [ ] , , [ ] , , [ 2 2 Oh h t j i u t j i u t j i u h t j i u t j i u t j i u x x xx + − + − + = − − = • Higher-order approximations ) ( 12 ] , , 2 [ ] , , 1 [ 8 ] , , 1 [ 8 ] , , 2 [ ] , , [ 4 h O h t j i u t j i u t j i u t j i u t j i ux + + − + + − − − = ) ( 12 ] , , 2 [ ] , , 1 [ 16 ] , , [ 30 ] , , 1 [ 16 ] , , 2 [ ] , , [ 4 2 Oh h t j i u t j i u t j i u t j i u t j i u t j i uxx + + − + + − − + − − =

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

The Finite Difference Method

• PDE becomessystem of algebraic equations for the grid valuesu[i,j,t]

• LinearPDE becomessystem of linear equations

for the grid valuesu[i,j,t]

• Simple stability rule: Information must not travel more than one grid cell in one time step

c h t< / ∆ → < ∆t h c

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Explicit Schemes – Linear Scalar

Advection

• upwind (c>0) 0 ] 1 , [ ] , [ ] , [ ] , 1 [ = ∆ − − + ∆ − + x i t u i t u c t i t u i t u ( ) ] 1 , [ ] , [ ] , [ ] , 1 [ − − ∆ ∆ − = + uti uti x t c i t u i t u • downwind (c>0) 0 ] , [ ] 1 , [ ] , [ ] , 1 [ = ∆ − + + ∆ − + x i t u i t u c t i t u i t u ( ) ] , [ ] 1 , [ ] , [ ] , 1 [ uti uti x t c i t u i t u + − ∆ ∆ − = +

• centered (Forward time centered space FTCS)

0 2 ] 1 , [ ] 1 , [ ] , [ ] , 1 [ = ∆ − − + + ∆ − + x i t u i t u c t i t u i t u ( ) ] 1 , [ ] 1 , [ 2 ] , [ ] , 1 [ + − − ∆ ∆ − = + uti uti x t c i t u i t u • Leap-frog 0 2 ] 1 , [ ] 1 , [ 2 ] , 1 [ ] , 1 [ = ∆ − − + + ∆ − − + x i t u i t u c t i t u i t u ( ) ] 1 , [ ] 1 , [ ] , 1 [ ] , 1 [ + − − ∆ ∆ − − = + uti uti x t c i t u i t u

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Explicit Schemes – Linear Scalar

Advection

• Lax-Wendroff ( ) ([, 1] 2[,] [, 1]) 2 1 ] 1 , [ ] 1 , [ 2 ] , [ ] , 1 [ 2 − + − +       ∆ ∆ + − − + ∆ ∆ − = + uti uti uti x t c i t u i t u x t c i t u i t u • Beam-Warming (c>0) • Lax-Friedrich

• CFL number (Courant-Friedrichs-Lewy), important in stability analysis

( ) ([,] 2[, 1] [, 2]) 2 1 ] 2 , [ ] 1 , [ 4 ] , [ 3 2 ] , [ ] , 1 [ 2 − + − −       ∆ ∆ + − + − − ∆ ∆ − = + uti uti uti x t c i t u i t u i t u x t c i t u i t u ( ) ([, 1] [, 1]) 2 ] 1 , [ ] 1 , [ 2 1 ] , 1 [ + − − ∆ ∆ − − − + = + uti uti x t c i t u i t u i t u x t c ∆ ∆ = σ

(7)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Outline

Mathematical Background What is a PDE? Types of PDEs Boundary Conditions Solution Techniques Analytical Methods Numerical Methods Examples Advection Diffusion

The Wave Equation

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Advection in 2D and 3D

• In 2D and 3D, speedcis a vector with directionnc and lengthc

x

t cT

T =− • For 1D advection we had

T Tt=−c⋅∇

• Sincec= cncthe general advection PDE reads • We have the spatial derivative of Tin directionnc

) ( T c Tt=− nc⋅∇ • Thus, we have , T T c c ∇ ⋅ = ∂ ∂ n n      ∂ ∂ ∂ ∂ = ∇       = ∇ y x T T T y x / / , : 2D in Nabla operator

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Finite Differences Solution

      − − + − − ∆ − = + h j i T j i T c h j i T j i T c t j i T j i Tt1[, ] t[, ] x [, ] [ 1, ] y [, ] [, 1] • The update rule in 2D

T y x Tt=−c( , )⋅∇

• Make the wind velocity a function of the location

Tis advected by a generalwind field

• Use velocity array, replacecxbycx[i,j]and cybycy[i,j] • PDE still first order and linear

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Diffusion in 1D

• Conduction law: Themass flowthrough an areaA(flux) isproportionalto thegradient of the densitynormal to A:

• The densityρ(x)describes the concentration of a substance in a tube with cross sectionA.

x x x+dx A m=ρ(x)Adx A x x dx x x k k dtA Adx x d dtA dm= ρ = ρ ρ + ) ( xx x x dx x x t k dx ρ ρ ρ = + − = xx t ρ = Conductivity

(8)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Diffusion in 3D

• The diffusion PDE in 3D

• Intuition forsecondspatial derivatives

• Constant concentration gradientρ(x)=a+bxhas no effect

Flux but no change Flux and positive change

ρ ρ ρ ρ ρ ρt=k xx+ yy+ zz =k∇ =k∆ 2 ) ( Laplace operator

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Finite Differences Solution

2 1 [ 1,] [ 1,] [, 1] [, 1] 4[,] ] , [ ] , [ h k t j i j i t i j i j ij ij ij t ρ ρ ρ ρ ρ ρ ρ+ = +∆ + + − + + + − −

• The update rule in 2D

• Intuition:

If the average concentration of the neighbor cells is larger than the concentration of the cell, its concentration increases and vice versa.

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

The 1D Wave Equation

• Function u(x)is displacement of the stringnormal to x-axis u

• Assuming small displacementsand constant stress σ

x u Au fσ • Component in u-direction x x dx x x tt Au Au u Adx σ σ ρ ) = + − ( ρutt=σuxx

• Newton’s 2ndlaw for an infinitesimal segment

• Force acting normal to cross section Ais f=σA x x x+dx A u Vibrating string fu f

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Analytical Solution

xx tt u u σ ρ = ) ( ) (x ct b f x ct f a⋅ + + ⋅ −

• with the analytical solution • For the string we have

xx tt c u u = 2 ? s c= • The standard form is where

(9)

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

2D Wave Equation

• The wave equation in 2D u c u c u u c utt= xx+ yy = ∇ = ∆ 2 2 2 2 ) (

• Waves propagate with velocityc • For the vibrating string we havec2=σ/ρ

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Finite Differences Solution

2 2 1 [ 1,] [ 1,] [, 1] [, 1] 4[,] ] , [ ] , [ h c t j i v j i vt+ = t + ui+ j+uij+uij+ +uij− −uij • The update rule in 2D

• Very simple to implement

• Yields cool water surface animation ] , [ ] , [ ] , [ 1 1 j i v t j i u j i ut+ = t + t+

• Boundary conditions assuming • Periodic: • Mirror: • Analog forj ] , 1 [ ] , 1 [ ], , [ ] , 0 [ j un j un j u j u = + = ] , [ ] , 1 [ ], , 1 [ ] , 0 [ j u j un j un j u = + = ) ,.., 1 ( n i

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Demo

t w t t u tc v v+1= + 22

• Combination of wave equation, diffusion, advection (1D) xx w tt cu u =− 2 xx d t cu u = x a t cu u =−

(

t

)

a t d t t t u c u c v t u u+1= +∆ +1+ ∇2 − ∇

• Explicit Leap-frog integration wave equation

advection diffusion

University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory

Literature

• Alan Jeffrey, „Applied Partial Differential Equations – An Introduction,“ Academic Press, Amsterdam,

ISBN 0-12-382252-1

• John D. Anderson, „Computational Fluid Dynamics – The Basics with Applications,“ McGraw-Hill Inc., New York, ISBN 0-07-001685-2

References

Related documents

In refractory epilepsy patients with OSA, we found significantly frequent sleep disturbance symptoms and younger age of seizure onset compared with patients with medically

Edward Mallett, “The Double Bell Euphonium: Design and Literature Past and Present” (DMA Dissertation, Michigan State

The rest of this work investigates whether: (i) the absorption capacity of firms, proxied by the level of expenditure made on R&amp;D 7 by the firms, (ii) human capital,

All have found significant harmful effects on children and youth (e.g., the 1954 Kefauver hearings; the 1969 National Commission on the Causes and Prevention of Violence; the

As you push the flush handle, the tank- stopper ball is lifted from its valve seat, allowing water to flow from the tank into the bowl.. When the tank is nearly empty, the tank

The consolidated financial statements of Volkswagen Financial Ser- vices AG Group in accordance with IFRS and the annual financial statements of Volkswagen Financial Services AG

Comparison of sequences and phylogenetic relationships among sequences of our isolates with published sequenc- es from Serbia and Montenegro and France showed that isolates

• Development Proposal Search Screen -- enter search criteria • List window -- view awards retrieved by your selection. The advantage of two separate windows is that your list