Numerical Solutions of ODEs in Engineering

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.
 
3
ODE – Initial value problem
 
First order ODE with initial condition
 
 
 
 
Several techniques are available to solve for the
function 
y(x)
 
 
4
ODE - Example
 
To solve an RL circuit, we apply KVL around the
loop and obtain a differential equation:
 
 
 
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
 
 
Taylor’s Series
 
Euler’s method of solving first order ODE
 
To solve the ODE:
 
 
 
We use the first two terms of the Euler series
 
 
      
h
 = 
x
i+1 
– x
i
 ,
is the step size
Solve for 
y 
using values of i=0,1,2….
 
7
Error in Euler’s method
 
8
Modified Euler’s method
 
Predictor-corrector algorithm
 
 
 
 
 
Reduces error in Euler’s method
Matlab/Python commands so solve ODEs
 
Matlab/Python have the command 
ode 
to
solve the first order ODE:
 
 
 
 
10
Solution of second order ODE
 
To solve the second order ODE:
 
 
 
Consider Taylor’s series (first 3 terms) for 
y
i+1
and 
y
i-1
 ; we obtain 
y
 as follows:
 
 
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])
 
 
 
Slide Note
Embed
Share

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.

  • ODEs
  • Engineering
  • Numerical Solutions
  • Differential Equations
  • MATLAB/Python

Uploaded on Mar 03, 2025 | 0 Views


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


  1. EEE 244-5: Numerical solution of Ordinary Differential Equations (ODEs)

  2. 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.

  3. 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

  4. 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

  5. Taylors Series

  6. 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 .

  7. Error in Eulers method 7

  8. 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

  9. 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()

  10. 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

  11. 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)

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#