Lecture IV: Time Discretization

Similar documents
Lecture V: The game-engine loop & Time Integration

Ordinary Differential Equations II

Ordinary Differential Equations II

ECE257 Numerical Methods and Scientific Computing. Ordinary Differential Equations

Scientific Computing II

Ordinary Differential Equations

Differential Equations

MTH 452/552 Homework 3

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Review Higher Order methods Multistep methods Summary HIGHER ORDER METHODS. P.V. Johnson. School of Mathematics. Semester

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Numerical solution of ODEs

Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations

Fourth Order RK-Method

Numerical Methods for the Solution of Differential Equations

Module 4: Numerical Methods for ODE. Michael Bader. Winter 2007/2008

Consistency and Convergence

Math 660 Lecture 4: FDM for evolutionary equations: ODE solvers

CS520: numerical ODEs (Ch.2)

CS205b/CME306. Lecture 4. x v. + t

Chap. 20: Initial-Value Problems

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 9

Finite Difference and Finite Element Methods

Ordinary Differential Equations (ODEs)

Numerical Methods - Initial Value Problems for ODEs

ODE Runge-Kutta methods

Scientific Computing: An Introductory Survey

Chapter 5 Exercises. (a) Determine the best possible Lipschitz constant for this function over 2 u <. u (t) = log(u(t)), u(0) = 2.

Multistage Methods I: Runge-Kutta Methods

ON THE INTEGRATION OF EQUATIONS OF MOTION: FEM AND MOLECULAR DYNAMICS PROBLEMS

CS 450 Numerical Analysis. Chapter 9: Initial Value Problems for Ordinary Differential Equations

Ordinary Differential Equations

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 20

Physics 115/242 The leapfrog method and other symplectic algorithms for integrating Newton s laws of motion

Passive Dynamics and Particle Systems COS 426

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

MODELING OF CONCRETE MATERIALS AND STRUCTURES. Kaspar Willam. Class Meeting #5: Integration of Constitutive Equations

The Finite Element Method for the Analysis of Non-Linear and Dynamic Systems: Non-Linear Dynamics Part I

Applied Math for Engineers

Computational Techniques Prof. Dr. Niket Kaisare Department of Chemical Engineering Indian Institute of Technology, Madras

NUMERICAL SOLUTION OF ODE IVPs. Overview

GAME PHYSICS SECOND EDITION. дяййтаййг 1 *

Optimising the Computational Simulation of Mechanical Models: Designing a Real-Time Mass-Aggregate Physics Engine

Dynamics. Kinematics and Dynamics. Passive vs. Active Dynamics. Passive Dynamics. Passive Dynamics. Particle Systems

Bindel, Fall 2011 Intro to Scientific Computing (CS 3220) Week 12: Monday, Apr 18. HW 7 is posted, and will be due in class on 4/25.

Numerical Methods for Initial Value Problems; Harmonic Oscillators

Rotational & Rigid-Body Mechanics. Lectures 3+4

Mathematics for chemical engineers. Numerical solution of ordinary differential equations

Physics 115/242 The leapfrog method and other symplectic algorithms for integrating Newton s laws of motion

Game Physics. Game and Media Technology Master Program - Utrecht University. Dr. Nicolas Pronost

Astrodynamics (AERO0024)

Jim Lambers MAT 772 Fall Semester Lecture 21 Notes

Euler s Method, cont d

Numerical Methods for Differential Equations

Physical Simulation. October 19, 2005

2tdt 1 y = t2 + C y = which implies C = 1 and the solution is y = 1

Woods Hole Methods of Computational Neuroscience. Differential Equations and Linear Algebra. Lecture Notes

Ordinary differential equation II

Unit I (Testing of Hypothesis)

Computational Techniques Prof. Dr. Niket Kaisare Department of Chemical Engineering Indian Institute of Technology, Madras

Introduction to the Numerical Solution of IVP for ODE

Runga-Kutta Schemes. Exact evolution over a small time step: Expand both sides in a small time increment: d(δt) F (x(t + δt),t+ δt) Ft + FF x ( t)

Review. Numerical Methods Lecture 22. Prof. Jinbo Bi CSE, UConn

ECE 422/522 Power System Operations & Planning/Power Systems Analysis II : 7 - Transient Stability

Astrodynamics (AERO0024)

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Computer Animation. Animation Methods Keyframing Interpolation Kinematics Inverse Kinematics. Slides courtesy of Leonard McMillan and Jovan Popovic

Ordinary differential equations. Phys 420/580 Lecture 8

Day 5 Notes: The Fundamental Theorem of Calculus, Particle Motion, and Average Value

CS 257: Numerical Methods

Initial-Value Problems for ODEs. Introduction to Linear Multistep Methods

Ordinary differential equations - Initial value problems

Numerical Integration of Ordinary Differential Equations for Initial Value Problems

Chapter 3 Numerical Methods

Initial value problems for ordinary differential equations

Robotics. Dynamics. University of Stuttgart Winter 2018/19

Robotics. Dynamics. Marc Toussaint U Stuttgart

Math Numerical Analysis Homework #4 Due End of term. y = 2y t 3y2 t 3, 1 t 2, y(1) = 1. n=(b-a)/h+1; % the number of steps we need to take

The Finite Element method for nonlinear structural problems

Checking the Radioactive Decay Euler Algorithm

SME 3023 Applied Numerical Methods

CE 530 Molecular Simulation

Numerical Methods for Initial Value Problems; Harmonic Oscillators

2 Numerical Methods for Initial Value Problems

AM 205 Final Project The N-Body Problem

Linear Multistep Methods I: Adams and BDF Methods

Dynamics 12e. Copyright 2010 Pearson Education South Asia Pte Ltd. Chapter 20 3D Kinematics of a Rigid Body

Numerical Methods for Differential Equations

Lecture 4: Numerical solution of ordinary differential equations

Numerical Differential Equations: IVP

Ordinary Differential Equations

Math 128A Spring 2003 Week 12 Solutions

ODEs. PHY 688: Numerical Methods for (Astro)Physics

Solving scalar IVP s : Runge-Kutta Methods

9.6 Predictor-Corrector Methods

Chapter 8. Numerical Solution of Ordinary Differential Equations. Module No. 2. Predictor-Corrector Methods

13 Numerical Solution of ODE s

Multistep Methods for IVPs. t 0 < t < T

AM205: Assignment 3 (due 5 PM, October 20)

Modeling and Experimentation: Compound Pendulum

Transcription:

Lecture IV: Time Discretization

Motivation Kinematics: continuous motion in continuous time Computer simulation: Discrete time steps t Discrete Space (mesh particles)

Updating Position Force induces acceleration. When mass is constant: F p, t = m a(p, t) Derivatives: v - t = a(t) and p - t = v(t) Thus: F p, t = m p -- (t) This is a differential equation Often difficult to analytically solve in real-time applications. Often a = a v, t dependence. Discretization: stability and convergence issues. 3

Taylor Approximation A function at t + t can be approximated by the function at t with derivatives: p t + t = p t + t p - t + t0 2 p-- t + + t3 n! p 3 t We do not usually use (or have) more than second derivatives. 4

First-Order Approximation If t is small enough, we approximate linearly: p 6 t + t p 6 t + t p 6 - t Euler s Method: approximating forward both velocity and position within the same step: v t + t = v t + a t t = v t + F(t) m t p 6 (t + t) = p 6 (t) + v(t) t Unknown for next time step Known for this time step 5

Euler s Method 5.1 This is known as Euler s method v t + t = v t + a t t p 6 (t + t) = p 6 (t) + v(t) t t v(t t) a(t t) v(t) t + t v(t) v(t + t) a(t) 6

Euler s Method Note: we approximate the velocity as constant between frames. We compute the acceleration of the object from the net force applied on it: F t a t = m We compute the velocity from the acceleration: v t + t = v t + a t t We compute the position from the velocity: p 6 t + t = p 6 t + v(t) t 7

Issues with Linear Dynamics A mere sequence of instants. Without the precise instant of bouncing. Trajectories are piecewiselinear. Constant velocity and acceleration in-between frames. 8

Time Step? When t 0, we converge to p 6 s v t dt. @ Reducing t as much as possible? First-order method, piecewise-constant velocity: not very stable. 9

Time Step First-order assumption: the slope at t as a good estimate for the slope over the entire interval t. The approximation can drift off the function. Farther drifting ó tangent approximation worse. x 0 x B errors x @ 10

Midpoint Method Estimating tangent in Half step: v t + t t = v t + a t, v 2 2 Full step: v t + t = v t + a t + C 0, v t + C 0 t Second-order approximation. 11

Midpoint Method Approximating the tangent in mid-interval. Applying it to initial point across the entire interval. Error order: the square of the time step O t 0. Better than Euler s method (O( t)) when t < 1. Approximating with a quadratic curve instead of a line. x B x B/0 can still drift off the function. x B x @ 12

Improved Euler s Method Considers the tangent lines to the solution curve at both ends of the interval. Velocity to the first point (Euler s prediction): v B = v t + t a(t, v) Velocity to the second point (correction point): v 0 = v t + t a t + t, v B Improved Euler s velocity v t + t = v B + v 0 2 Compute position similarly with v B, v 0 instead of a. 13

Improved Euler s Method The order of the error is O( t 0 ). The final derivative is still inaccurate. v 0 v t + t = v B + v 0 2 v(t) v B t 14

Runge-Kutta Method There are methods that provide better than quadratic error. The Runge-Kutta order-four method (RK4) is O( t I ). A combination of the midpoint and modified Euler s methods, with higher weights to the midpoint tangents than to the endpoints tangents. 15

RK4 Computing the four following tangents (note dependence of acceleration on velocity): v B = t a(t, v(t)) v 0 = t a t + t 2, v t + 1 2 v B v J = t a t + t 2, v t + 1 2 v 0 v I = t a t + t, v t + v J Blend as follows: v t + t = v t + v B + 2v 0 + 2v J + v I 6 Compute position similarly with v values. 16

RK4 5.2 v B = t a(t, v(t)) v 0 = t a t + t 2, v t + 1 2 v B v J = t a t + t 2, v t + 1 2 v 0 v I = t a t + t, v t + v J v 0 v t + t v J v B + 2v 0 + 2v J + v I 6 v B v I v(t) t/2 t/2 17

Based on the Taylor expansion series of the previous time step and the next one: p 6 t + t + p 6 t t Verlet integration = p 6 t + t p 6 - t + t0 2 p 6 -- t + + p 6 t t p 6 - t + t0 2 p 6 -- t 18

Verlet integration Approximating without velocity: p 6 t + t = 2p 6 t p 6 t t + t 0 p 6 -- t +O( t I ) p 6 (t + t) p 6 (t t) p 6 (t) t 0 a t 2 p 6 (t) p 6 (t t) t t 19

An O( t 0 ) order of error. Verlet integration Very stable and fast without the need to estimate velocities. We need an estimation of the first p 6 (t t) Usually obtained from one step of Euler s or RK4 method. Difficult to manage velocity related forces such as drag or collision. 20

Implicit methods So far: computing current position p 6 (t) and velocity v(t) for the next position (forward). Those are denoted as explicit methods. In implicit methods, we make use of the quantities from the next time step! p 6 t = p 6 t + t t v(t + t) this particular one is called backward Euler. the goal: finding position p 6 t + t which produces p 6 if running the simulation backwards. 21

Implicit methods Not more accurate than explicit methods, but more stable. x @ x B Especially for a damping of the position (e.g. drag force or kinetic friction). x 0 22

Backward Euler How to compute the velocity at a position in the future? Given the forces applied, extracting from the formula: Example: a drag force F L = b v is applied: v t + t = v t t b v(t + t) And therefore v t + t = v(t) 1 + t b 23

Backward Euler Often not knowing the forces in advance (likely case in a game). Or that the backward equation is not easy to solve. We use a predictor-corrector method: one step of explicit Euler s method use the predicted position to calculate v(t + t) More accurate than explicit method but twice the amount of computation. 24

Semi-Implicit Method Combines the simplicity of explicit Euler and stability of implicit Euler. Runs an explicit Euler step for velocity and then an implicit Euler step for position: v t + t = v t + t a t = v t + t F(t)/m p t + t = p(t) + t v t = p(t) + t v(t + t) t v(t) a(t) v(t + t) t + t 25

Semi-Implicit Method The position update in the second step uses the next velocity in the implicit scheme. Good for position-dependent forces. Conserves energy over time, and thus stable. Not as accurate as RK4 (order of error is still O( t)), but cheaper and yet stable. Very popular choice for game physics engine. 26

First-order methods Implicit and Explicit Euler method, Semi-implicit Euler, Exponential Euler Second-order methods Verlet integration, Velocity Verlet, Trapezoidal rule, Beeman s algorithm, Midpoint method, Improved Euler s method, Heun s method, Newmark-beta method, Leapfrog integration. Higher-order methods Summary Runge-Kutta family methods, Linear multistep method. 27

Dimension Concluding remarks Integration methods shown for 1D variables. Generalization using vector based structures (e.g., Jacobians). Rotational motion The integration methods work exactly the same for angular displacement θ, velocity ω and acceleration α. Evaluation of all dimensions and variables should be done for the same simulation time t. 28