Week 5 - Literature review: ODE Stability
ODE are the ordinary differential equation (ODE) is a differential equation containing one or more functions of one independent variable and the derivatives of those functions.They are applied to solve the complex engineering problem and using with the utilization of the computer we can reduce the time it takes to solve. For these different numerical schemes are implemented to find the solution of the system of equation and each numerical schemes have their own degree of accuracy and stability
There are manly two numerical schemes
1)Explicit Scheme:
Here the value of the variable is calculated using known values from the previous time step
2)Implicit Scheme
The Value of variable is computed using a set equation from the previous and also present value.
When does ODE becomes unstable
Stability is achieved when the difference between different solution approaches to zero and that is called convergence. When considering numerical schemes, Implicit schemes are stable as they use the iterative technique for a given time step, whereas in case of Explicit there the stability depends on the value of time step. Their critical value determine the stability above which the convergence is cannot be achieved and oscillation are formed and below it give a stable solution but takes a lot of time
To Exemplify the effect we use a sample ODE
`(dy)/(dt)=-1000y-e^-t`
Discretization
`(dy)/(dt)=(y^(n-1)-y^n)/(trianglet)`
Explicit Scheme:
`y^n=(1-1000trianglet)y^(n-1)-e^(-t^(n))trianglet`
Implicit Scheme
`y^n=(y^(n-1)-e^-(t^n)trianglet)/(1+1000trianglet)`
Analytical
`y=((e^-1000t)/999)-((e^-t)/999)`
Python Code and Result
import numpy as np
import math
import matplotlib.pyplot as plt
def explicit_method(total_t,dt):
t=np.arange(0,total_t,dt)
y=np.zeros(len(t))
for i in range(1,len(t)):
y[i]=y[i-1]+dt*(-10000*y[i-1]-np.exp(-t[i]))
return[t,y]
def implicit_method(total_t,dt):
t=np.arange(0,total_t,dt)
y=np.zeros(len(t))
for i in range(1,len(t)):
y[i]=(y[i-1]-np.exp(-t[i])*dt)/(1+10000*dt)
return[t,y]
def analytic_method(total_t,dt):
t=np.arange(0,total_t,dt)
y=np.zeros(len(t))
for i in range(1,len(t)):
y[i]=np.exp(-10000*t[i])*(1-np.exp(9999*t[i]))/9999
return [t,y]
total_t=0.1
dt=1e-4
t,y_explicit = explicit_method(total_t,dt)
t,y_implicit = implicit_method(total_t,dt)
t,y_analytical = analytic_method(total_t,dt)
plt.plot(t,y_explicit,'--',color='red')
plt.plot(t,y_implicit,color='black')
plt.plot(t,y_analytical,color='green')
plt.legend(['Explicit Solution','Implicit Solution','Analytical Solution'])
plt.show()
time step 1e-4
Time Step=1.5e-4
Time step 1.8e-4
The above figures show that if the time step values increase the explicit method pattern just blownup and showing an irregular one
How does stability affect engineering problem simulation?
The stability is the important property of simulation that is required to produce the solution and therefore proper numerical scheme variable must be selected in order to have stability. At times unstable schemes also give a solution but comes with a lot of inaccuracies and thereby results in instability.in addition, sometimes value of a variable that gives stability but it these are costly and takes more computation time and are thus very less effective.
Can stability condition be derived for all types of problems?
Yes but that really depends on the how the ODE function. For first-order stability can be achieved by good conditioning the value of expression as in the above example the time step size a proper value to get stable solution.however for second-order ODE whose stability depends on eigenvalues of a particular matrix.
So the stability totally depends on the nature of the given problem function