s Vector Moving s and Coputer Science Departent The University of Texas at Austin October 28, 2014
s Vector Moving s Siple classical dynaics - point asses oved by forces Point asses can odel particles They can be grouped to odel acroscopic objects Forces can ove particles Forces can constrain point asses to be part of larger objects Used in particle systes, cloth, rigid bodies, etc.
s At tie t, a particle has s Vector Moving s A position A velocity x(t) = v(t) = ẋ(t) = An acceleration [ ] x(t) y(t) a(t) = ẍ(t) = d v(t) dt [ dx(t) ] dt dy(t) dt = d2 x(t) dt 2 = d 2 x(t) dt 2 d 2 y(t) dt 2 y x And a ass
Vector s Vector Moving s Ignore acceleration and ass for now and let the velocity be dictated by a function g of position and tie, so ẋ(t) = g( x(t), t). At any tie t, the function g defines a vector field over x. This vector field specifies the velocity of a particle located at position x(t) at tie t. y x
s Vector Moving s The equation ẋ(t) = g( x(t), t) is a first-order ordinary differential equation (ODE). We need to use it to copute the path that a particle takes through the vector field if it starts at a given initial position. This path is called an integral curve. The proble is called an initial value proble, a special case of a boundary value proble. y x
Moving s s Vector Moving s Given ẋ(t) = g( x(t), t), we want to solve for x(t), the particle s trajectory. We can do this nuerically. Euler s Method Choose a discrete tiestep t. Iterate, taking linear steps in the direction of the velocity at the beginning of each step. x(t + t) = x(t) + ẋ(t) t = x(t) + g( x(t), t) t In sipler tiestep iteration notation x i+1 = x i + v i t This is the siplest (but not the best) way to nuerically integrate a first-order ODE.
s Vector Moving s Proble: discrete steps in instantaneously valid directions Bigger steps, bigger errors Tiestep error O( t 2 ), global error O( t) Need to take pretty sall steps, so aybe not efficient Step size needed depends on rate of velocity change ethods allow bigger tiesteps, we ll see soe later y x
s Vector Moving s For particle dynaics, we won t have a g( x(t), t) to specify velocities directly, rather we ll copute velocities fro the forces acting on particles Since particles obey Newton s Law: f = a = ẍ And since in general force (and thus acceleration) can depend on the position and velocity of a particle We have a(t) = ẍ(t) = f( x(t), ẋ(t), t)
s Vector Moving s Equations with a second derivative in the (like ẍ) are called second-order ODEs. Euler s Method and related techniques handle first-order ODEs. Turning higher-order ODEs into first-order ODEs We have ẍ(t) = f( x(t), ẋ(t), t) If we introduce the velocity variable v(t), we can rewrite this as a pair of coupled first-order ODEs [ ] ẋ(t) = v(t) v(t) = f( x(t), v(t),t) We can treat this as a first-order ODE in phase space [ẋ(t) ] [ ] = v(t) v(t) f( x(t), v(t),t)
s Vector Moving s We can concatenate vectors to for vectors in higher-diensional space, called phase space. If x and v are each 3-diensional, we get a 6-diensional phase space. [ ] x(t) v(t)
s Vector Moving s We can concatenate vectors to for vectors in higher-diensional space, called phase space. If x and v are each 3-diensional, we get a 6-diensional phase space. We can take tie derivatives in phase space. [ ] x(t) v(t) [ẋ(t) ] v(t)
s Vector Moving s We can concatenate vectors to for vectors in higher-diensional space, called phase space. If x and v are each 3-diensional, we get a 6-diensional phase space. We can take tie derivatives in phase space. We can have vector fields in phase space, like our force field. (Yes, I know it sounds like Star Trek.) [ ] x(t) v(t) [ẋ(t) ] v(t) f( x(t), v(t), t)
s Vector Moving s We can concatenate vectors to for vectors in higher-diensional space, called phase space. If x and v are each 3-diensional, we get a 6-diensional phase space. We can take tie derivatives in phase space. We can have vector fields in phase space, like our force field. (Yes, I know it sounds like Star Trek.) We can have ODEs in phase space too. [ ] x(t) v(t) [ẋ(t) ] v(t) f( x(t), v(t), t) [ẋ(t) ] [ = v(t) v(t) f( x(t), v(t),t) ]
s Vector Moving s [ẋ(t) ] [ We can solve = v(t) v(t) f( x(t), v(t),t) Euler s Method in ] using Euler s Method. Choose a discrete tiestep t and iterate, as before. With tiestep indices x(t + t) = x(t) + v(t) t v(t + t) = v(t) + f( x(t), v(t), t) x i+1 = x i + v i t v i+1 = v i + f i( x i, v i) t t This is just what we did before except we re updating v iteratively along with x.
s Vector Moving s Euler s Method is first-order, so The error per tiestep (local error) is proportional to t 2. The cuulative (global) error is proportional to t. This isn t very good, sall tiesteps are often needed to keep the coputation fro diverging. This is a particular proble for stiff systes. For our purposes, these are roughly systes with really stiff springs in the, or soething exerting very strong forces that can change rapidly. That s not a definition, which is uch harder. A related proble is that Euler s Method is not syplectic. It does not conserve energy (or coe close to doing so) as the siulation proceeds.
s Vector Moving s We said Euler s Method is local order O( t 2 ) and global order O( t). What do we ean? We siulate fro t 0 to T by taking n tiesteps of size t. The total error at tie T, e( t, T ) = x(t ) x n, the difference between the correct position at T and the siulated position after the nth tiestep. e( t, T ) is a function of both the tiestep size t and the total siulation tie T. The order of an integration ethod describes how e( t, T ) changes as a function of t, holding T constant.
s Vector Moving s Local order O( t 2 ) eans changing t changes the worst-case truncation error proportionally to t 2. Global order O( t) eans a change in t changes the worst case cuulative truncation error of the entire siulation proportionally to t. This doesn t tell you uch about how the siulation error grows as the overall siulation tie T grows. This depends on any factors, what ODEs you re integrating, the initial conditions, etc. A ethod with a higher global order is better than a lower-order ethod because it gets worse ore slowly as you increase the tiestep size, not because you have any idea how far off the right answer it will get in the actual siulation.
s Vector Moving s Assue that f is only a function of position and not of velocity, i.e. it is f( x(t), t). We don t odel wind resistance, for exaple, but we can still handle a lot of interesting forces. Now we can easily fix Euler s Method to ake it syplectic. Sei-iplicit Euler Integration We can use v i+1 instead of v i to copute x i+1 v i+1 = v i + f i( x i) t x i+1 = x i + v i+1 t Alternatively, we can use x i+1 instead of x i to copute v i+1 x i+1 = x i + v i t v i+1 = v i + f i( x i+1) t
s Vector Moving s Euler s Method can be obtained fro the Taylor series for x(t + t) and v(t + t). x(t + t) = x(t) + ẋ(t) t + O( t 2 ) v(t + t) = v(t) + v(t) t + O( t 2 ) We just throw away the quadratic and higher order ters, which is why the local error is proportional to t 2. We can use siilar derivations to get better ethods. For instance, the techniques we ve seen so far aren t tie-reversible, which proper physics should be. Let s try for that property.
s Vector Moving s We can do Taylor series in both tie directions x(t + t) = x(t) + ẋ(t) t + 1/2ẍ(t) t 2 + 1/6... x(t) t 3 + O( t 4 ) x(t t) = x(t) ẋ(t) t + 1/2ẍ(t) t 2 1/6... x(t) t 3 + O( t 4 ) Integration Add the and apply soe algebra to get x(t + t) = 2 x(t) x(t t) + ẍ(t) t 2 + O( t 4 ) Throw away the O( t 4 ) local error ter, write as an iteration, put in the forcing function for the acceleration, and we have x i+1 = 2 x i x i 1 + f i( x i) t2 We re given initial x 0 and v 0, but we also need x 1, so x 1 = x 0 + v 0 t + 1 2 fi( x 0) t2
s Vector Moving s advantages It is tie-reversible, syplectic, local O(t 4 ) and global O(t 2 ), or second-order. Easy to use for constraints between particles (e.g. infinitely stiff springs), especially for rigid bodies, cloth, etc. See Jakobsen s faous GaaSutra article http://www.gaasutra.co/resource guide/20030121/jacobson pfv.ht disadvantages Multistep ethod, needs adjustent for non-constant t. x i+1 = x i + ( x i x i 1 ) t i + f i ( x i ) t i 1 t i + t i 1 t i 2 Doesn t calculate velocities.
s Vector Moving s If we need velocities, we can just calculate the fro the point positions. v i = xi+1 xi 1 + O( t 2 xi+1 xi ) or v i+1 = + O( t) t i + t i 1 t i More coonly, they are incorporated into the iteration as the Method Expand x(t + t) = x(t) + v(t) t + 1 2 a t2 + O( t 3 ) Expand forward v(t + t) = v(t) + a(t) t + O( t 2 ) and reverse v(t) = v(t + t) a(t + t) t + O( t 2 ) Add the latter two to get v(t + t) = v(t) + 1 ( a(t) + a(t + t)) t 2 So we have x i+1 = x i + v i t + 1 2 fi( x i) t2 v i+1 = v i + f i( x i) + f i+1( x i+1) t 2