Presentation is loading. Please wait.

Presentation is loading. Please wait.

ME451 Kinematics and Dynamics of Machine Systems Numerical Integration. Stiffness: Implicit Methods. October 30, 2013 Radu Serban University of Wisconsin-Madison.

Similar presentations


Presentation on theme: "ME451 Kinematics and Dynamics of Machine Systems Numerical Integration. Stiffness: Implicit Methods. October 30, 2013 Radu Serban University of Wisconsin-Madison."— Presentation transcript:

1 ME451 Kinematics and Dynamics of Machine Systems Numerical Integration. Stiffness: Implicit Methods. October 30, 2013 Radu Serban University of Wisconsin-Madison

2 2 Before we get started… Last Time: Recovering constraint reaction forces Started discussion on numerical integration Today Stiff differential equations Implicit numerical integration formulas Assignments: Homework 9 – 6.3.3, 6.4.1 – due November 4 (12:00pm) Matlab 7 – due tonight, October 30, Learn@UW (11:59pm) Project 1 – due Wednesday, November 6, Learn@UW (11:59pm) Your simEngine2D can now perform complete Kinematic analysis! Test the provided visualization function (available on the SBEL course webpage) Miscellaneous Draft proposals for the Final Project due on Friday, November 1 Midterm 2 – Wednesday, November 6, 12:00pm in ME 1143 Review session – Monday, November 4, 6:30pm in ME 1143

3 Numerical Integration

4 4 Basic Concept IVP In general, all we can hope for is approximating the solution at a sequence of discrete points in time Uniform grid (constant step integration) Adaptive grid (variable step integration) The numerical solution is then the sequence of approximations Basic idea: somehow turn the differential problem into an algebraic problem (approximate the derivatives)

5 5 Simplest method: Forward Euler Starting from the IVP Use the simplest approximation to the derivative Rewrite the above as and use ODE to obtain

6 6 FE: Geometrical Interpretation IVP Forward Euler integration formula

7 7 FE: Example

8 8 Forward Euler: Effect of Step-Size % IVP (RHS + IC) f = @(t,y) -0.1*y + sin(t); y0 = 0; tend = 50; % Analytical solution y_an = @(t) (0.1*sin(t) - cos(t) + exp(-0.1*t)) / (1+0.1^2); % Loop over the various step-size values and plot errors colors = [[0, 0.4, 0]; [1, 0.5, 0]; [0.6, 0, 0]]; Figure, hold on, box on h = [0.001 0.01 0.1]; for ih = 1:length(h) tspan = 0:h(ih):tend; y = zeros(size(tspan)); err = zeros(size(tspan)); y(1) = y0; err(1) = 0; for i = 2:length(tspan) y(i) = y(i-1) + h(ih) * f(tspan(i-1), y(i-1)); err(i) = y(i) - y_an(tspan(i)); end plot(tspan, err, 'color', colors(ih,:)); end legend('h = 0.001', 'h = 0.01', 'h = 0.1');

9 9 FE: Effect of Step-Size % IVP (RHS + IC) f = @(t,y) -0.1*y + sin(t); y0 = 0; tend = 50; % Loop over the various step-size values and plot errors colors = [[0, 0.4, 0]; [1, 0.5, 0]; [0.6, 0, 0]]; Figure, hold on, box on h = [0.1 1.0 5.0]; for ih = 1:length(h) tspan = 0:h(ih):tend; y = zeros(size(tspan)); y(1) = y0; for i = 2:length(tspan) y(i) = y(i-1) + h(ih) * f(tspan(i-1), y(i-1)); end plot(tspan,y, 'color', colors(ih,:)) end legend('h = 0.1', 'h = 1', 'h = 5');

10 Stiff Differential Equations

11 11 A Simple IVP Example

12 12 A Simple IVP Example Analytical Solution

13 13 Stiff Differential Equations Problems for which explicit integration methods (such as Forward Euler) do not work well Other explicit formulas: Runge-Kutta (RK4), DOPRI5, Adams- Bashforth, etc. Stiff problems require a different class of integration methods: implicit formulas The simplest implicit integration formula: Backward Euler (BE)

14 14 BE: Geometrical Interpretation IVP Forward Euler integration formula Backward Euler integration formula

15 15 A Simple IVP Example

16 16 Forward Euler vs. Backward Euler

17 17 IVP Also known as Gear method (DIFSUB – 1971) Family of implicit linear multi-step formulas BDF of 1 st order: BDF of 2 nd order: BDF of 3 rd order: BDF of 4 th order: BDF of 5 th order: Backward-Difference Formulas (BDF) C.W. (Bill) Gear b. 1935

18 18 Curtiss & Hirschfelder Example C.F. Curtiss and J.O. Hirschfelder – “Integration of Stiff Equations” Proc. Nat. Acad. Sci, USA (1952)

19 Stability and Accuracy of Numerical Integrators

20 20 Two Key Properties of a Numerical Integrator Two properties are relevant when considering a numerical integrator for finding an approximation of the solution of an IVP Stability Accuracy

21 21 Stability of a Numerical Integrator

22 22 Accuracy of a Numerical Integrator

23 Implicit Integration of Stiff ODEs

24 24 Implicit Integration and Nonlinear Systems [Examples]

25 25 Implicit Integration and Nonlinear Systems [Example 1]

26 26 Implicit Integration and Nonlinear Systems [Example 2]

27 27 Implicit Integration and Nonlinear Systems [Example 3]

28 28 Implicit Integration and Nonlinear Systems [Examples]

29 29 Implicit Integration: Conclusions

30 Solution of IVPs in Matlab

31 31 General Call to a Matlab ODE Solver IVP: Example of using Matlab’s ode45 : Use odeset to create an ODE options structure to change default values for various solver parameters [t,y] = ode45(odefun,tspan,y0,options) function dydt = odefun(t,y) [t0 tend] y0 options = odeset(…)

32 32 Example of IVP Solution with Matlab >> [t,y]=ode45(‘rhs’,[0 20],[2;0]); >> plot(t, y); function yd = rhs(t, y) yd = [y(2); (1-y(1)^2)*y(2)-y(1)]; Convert to 1 st order ODE Convert to vector form

33 33 ODE Solvers in MATLAB Solver Problem Type Order of Accuracy When to use ode45NonstiffMediumMost of the time. This should be the first solver tried ode23NonstiffLow For problems with crude error tolerances or for solving moderately stiff problems. ode113NonstiffLow to high For problems with stringent error tolerances or for solving computationally intensive problems ode15sStiff Low to medium If ods45 is slow because the problem is stiff ode23sStiffLow If using crude error tolerances to solve stiff systems and the mass matrix is constant ode23t Moderately stiff Low For moderately stiff problems is you need a solution without numerical damping ode23tbStiffLowIf using crude error tolerances to solve stiff systems Use ode45 for non-stiff problems and ode15s for stiff problems

34 34 A Stiff Problem % specify RHS function rhs = @(t,y) [-1,-1;1,-5000]*y; % specify accuracy and turn on stats option options = odeset('RelTol',1e-6,'Stats','on'); % call the ode45 solver fprintf('\n---- ode45 solver statistics ----\n') tic, [~,~] = ode45(rhs, [0, 5], [1; 1], options); toc % call the ode15s solver fprintf('\n---- ode15s solver statistics ----\n') tic, [~,~] = ode15s(rhs, [0, 5], [1; 1], options); toc ---- ode45 solver statistics ---- 7557 successful steps 504 failed attempts 48367 function evaluations Elapsed time is 0.564820 seconds. ---- ode15s solver statistics ---- 139 successful steps 3 failed attempts 288 function evaluations 1 partial derivatives 27 LU decompositions 284 solutions of linear systems Elapsed time is 0.188120 seconds. On a stiff problem, an explicit solver is forced to take small steps to ensure stability an implicit solver can take much larger steps, which reduces overall time to solution; but it must solve algebraic equations at each time step


Download ppt "ME451 Kinematics and Dynamics of Machine Systems Numerical Integration. Stiffness: Implicit Methods. October 30, 2013 Radu Serban University of Wisconsin-Madison."

Similar presentations


Ads by Google