Numerical Solutions of ODEs in Engineering
This content discusses the practical application of numerical methods for solving Ordinary Differential Equations (ODEs) in engineering problems. Starting from physical laws, it covers the generation of differential equations, numerical and analytical solutions, and techniques for solving initial value problems and higher-order ODEs. Various methods such as Euler's method and Taylor series are explained, along with MATLAB/Python commands for ODE solutions. The focus is on understanding and implementing numerical techniques for solving ODEs in practical scenarios.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
EEE 244-5: Numerical solution of Ordinary Differential Equations (ODEs)
Engineering Problem Solution Start with physical laws (Faraday s, Ohm s, KVL, KCL, Maxwell s equations) Generation of differential equation for the specific problem Numerical or analytical solution of differential equation to obtain the unknown variables, such as current, voltage, power.
ODE Initial value problem First order ODE with initial condition dy = ( , ) f x y dx with = initial condition ) 0 ( y IY Several techniques are available to solve for the function y(x) 3
ODE - Example To solve an RL circuit, we apply KVL around the loop and obtain a differential equation: di V R = i dt L L The aim is to solve for the unknown current i(t), given the initial condition i(t=0)= i(0) Numerical solution is practical to solve higher order ODEs 4
Eulers method of solving first order ODE To solve the ODE: dy = ( , ) f x y dx with = initial condition ) 0 ( y IY We use the first two terms of the Euler series h = xi+1 xi ,is the step size Solve for y using values of i=0,1,2 .
Modified Eulers method Predictor-corrector algorithm = + P i + Predictor : ( , ) y y f x y h 1 i i i ) 1 + h = + + C i + P i Corrector : ( , ) ( , y y f x y f x y + 1 1 i i i i 2 Reduces error in Euler s method 8
Matlab/Python commands so solve ODEs Matlab/Python have the command ode to solve the first order ODE: ?? ??= ?(?,?) Matlab Python for x=(x1,x2) , initial condition ? = ?0 clear f=@(x,y) f(x,y) x =[xl xu] import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint xspan=np.linspace(xmin,xmax,points) def f(y,x): return f(x,y) [x y] = ode45( f, x,y0) plot(x,y) y=odeint(f,y0,xspan) plt.plot(xspan,y) plt.show()
Solution of second order ODE To solve the second order ODE: 2 d y = ( , ) f x y 2 dx = = with initial condition ) 0 ( y ; ) 1 ( y y y 0 1 Consider Taylor s series (first 3 terms) for yi+1 and yi-1 ; we obtain y as follows: y x f h y , ( 1 = + + 2 ) 2 y y 1 i i i 10
Matlab/Python commands so solve ODEs Matlab/Python commands to solve the second order ODE: (for Python define the function f(x,y) as f(x,y[0]) Matlab Python syms y(x) dx= y0= y1= eqn = diff(y,x,2) == f(x,y); Dy = diff(y,x) dd=(y1-y0)/dx; cond = [y(0)==y0, Dy(0)==dd]; ysol(x)= dsolve(eqn,cond) x=0:dx:xlimit; y=subs(ysol); plot(x,y) import matplotlib.pyplot as plt from scipy.integrate import odeint import numpy as np def f(y,x): return(y[1],f(x,y)) y0= y1= dx= dd=(y1-y0)/dx y00=[y0,dd] xs=np.linspace(0,xlimit,no. of points)