1 / 16

Modeling Basics: 4. Numerical ODE Solving In Excel 5. Solving ODEs in Mathematica

Modeling Basics: 4. Numerical ODE Solving In Excel 5. Solving ODEs in Mathematica By Peter Woolf University of Michigan Michigan Chemical Process Dynamics and Controls Open Textbook version 1.0. Creative commons. 12.1x10 10 m 3. 3.6x10 10 m 3. 29.1x10 10 m 3.

wiley
Télécharger la présentation

Modeling Basics: 4. Numerical ODE Solving In Excel 5. Solving ODEs in Mathematica

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Modeling Basics: 4. Numerical ODE Solving In Excel 5. Solving ODEs in Mathematica By Peter WoolfUniversity of MichiganMichigan Chemical Process Dynamics and Controls Open Textbookversion 1.0 Creative commons

  2. 12.1x1010 m3 3.6x1010 m3 29.1x1010 m3 Data from http://www.newton.dep.anl.gov/askasci/gen01/gen01629.htm Case study: water storage Water is vitally important for industry, agriculture, domestic consumption.

  3. 12.1x1010 m3 3.6x1010 m3 29.1x1010 m3 Data from http://www.newton.dep.anl.gov/askasci/gen01/gen01629.htm

  4. Key Question: Have you stored enough water? 12.1x1010 m3 3.6x1010 m3 29.1x1010 m3 Data from http://www.newton.dep.anl.gov/askasci/gen01/gen01629.htm

  5. P&ID Water storage Water tower Mathematical Description: Change=input-output

  6. Numerical solution Analytical solution How to solve this set of equations? • Integrate with software such as Excel or Mathematica (or many others) • Integration can be tricky • Need to know all parameters • Can be computationally demanding • Hand calculation • Software calculation using Mathematica for example • Often not possible for “real” systems • Even if possible, sometimes not useful

  7. Mathematica Syntax DSolve[ {eqn1, eqn2..},{y1,y2,..},t] Analytical solver NDSolve[{eqn1, eqn2..},{y1,y2,..},t] Numerical solver Plot[{f1,f2},{t,0,tmax}] Plotter See lecture7.mathematica.nb

  8. What if your feed varies in a non-functional way? Numerical integration!

  9. Numerical approx Slope: F-k1v1(10) Numerical ODE solving True solution Tank depth (h) Euler’s method! 10 0 0.1 time Time step=0.1

  10. Slope: F-k1v1(10) • Notes on Euler’s method: • Perfect fit for linear systems • Works well for nonlinear systems if the time step is small (everything is locally linear) • If time step is too large can explode • Small time steps mean slow calculations Numerical ODE solving Tank depth (h) 10 0 0.1 time Time step=0.1

  11. 6.0x103023 Numerical error! Time step=0.01 • Notes on Euler’s method: • Perfect fit for linear systems • Works well for nonlinear systems if the time step is small (everything is locally linear) • If time step is too large can explode • Small time steps mean slow calculations Numerical ODE solving Tank depth (h) 10 0 0.1 time Time step=0.1

  12. Solution: take some sort of weighted average of slopes at intermediate points to estimate the next value. Is there a way we could use a larger time step but retain accuracy? Numerical ODE solving Runge-Kutta methods! Tank depth (h) 10 0 0.1 time Time step=0.1

  13. Euler’s method Numerical ODE solving 4th order Runge-Kutta Where Tank depth (h) 10 0 0.1 time Time step=0.1

  14. Numerical ODE solving Why stop at 4th order? 5th order is similar but with different weightings Upsides: Larger step sizes possible Can be more stable Often more computationally efficient Downsides: Complex to implement Similar accuracy can often be achieved using Euler’s method which is easy to implement Tank depth (h) 10 0 0.1 time Time step=0.1

  15. Key Question: Have you stored enough water? See lecture7.excel.xls 12.1x1010 m3 3.6x1010 m3 29.1x1010 m3 Data from http://www.newton.dep.anl.gov/askasci/gen01/gen01629.htm

  16. Take home messages • Numerical simulation of differential equations can help you model very complex systems • Sometimes slower, simpler method are better as your time is often more valuable than a computers • Analytical results can be helpful in restricted cases.. Use Mathematica to handle the algebra

More Related