Week 5 - Literature review: ODE Stability
Aim
To know about the ODE stability
Explicit Method
The Explicit method calculates the state of the system at a later time from the state of the system at the current time.
Implicit Method
The Implicit method find a solution solving the equation both the current state of the system and the later one.
ODE Stability
Numerical stability deals with the solution as the time-step dt is increased. If the solution remains well behaved for arbitrarily large values of the time step, the method is said to be unconditionally stable. This situation never occurs with explicit methods, which are always conditionally stable. It is easy to see that this is so by dividing the Q-equation by dt and then letting dt approach infinity. In this limit there are no n+1 terms remaining in the equation so no solution exists for Qn+1, indicating that there must be some limit on the size of the time step for there to be a solution.
Stability Effect Illustration
The propagation of a pressure wave can be used to illustrate the differences between implicit and explicit methods. If a step increase in pressure is applied at one end of an organ pipe that is closed at the opposite end. We know that a pressure wave will move down the pipe and be reflected at the closed end. Given enough time, pressure waves will travel back and forth in the pipe many times before the pressure distribution settles down to the constant value applied at the open end.If only steady-state results are wanted, then an implicit solution scheme with lots of damping of the pressure waves should be used so that steady conditions will be reached as quickly as possible. In this case the damping incorporated in the implicit iteration method i.e. the under-relaxation is highly desirable.
If the transient pressure waves are to be investigated, then we want the least amount of numerical damping so that many wave reflections can be accurately followed. This situation is best treated with an explicit solution method.
Explicit methods require a time-step size that limits the advance of the pressure step to less than one computational cell per time step. However, this restriction is related to accuracy because most difference equations involve quantities from neighboring cells only. A pressure wave that propagates further than one cell in one time step would then be moving into regions that have no defined influence on the pressure. Not only is this physically unrealistic, it also leads to numerical instability.
Implicit methods, couple all the cells together through an iterative solution that allows pressure signals to be transmitted through a grid. The price for this communication between distantly located cells is a damping or smoothing of the pressure waves introduced by the under-relaxation needed to solve the coupled equations.
When time accuracy is important, explicit methods produce greater accuracy with less computational effort than implicit methods
import numpy as np
import matplotlib.pyplot as plt
def explicit(t_total,dt):
t = np.arange(0,t_total,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-1]))
return [t,y]
def implicit(t_total,dt):
t = np.arange(0,t_total,dt)
y = np.zeros(len(t))
for i in range(1,len(t)):
y[i] = (y[i-1] - np.exp(-t[i-1])*dt)/(1+10000*dt)
return[t,y]
def analytical(t_total,dt):
t = np.arange(0,t_total,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(y)
t_total = 0.1
dt = 1e-4
t,y_explicit =explicit(t_total,dt)
t,y_implicit =implicit(t_total,dt)
y_analytical =analytical(t_total,dt)
plt.plot(t,y_explicit,color = 'blue')
plt.plot(t,y_implicit,color = 'red')
plt.plot(t,y_analytical,color = 'orange')
plt.xlabel('Time')
plt.ylabel('dt')
plt.legend(['Explicit',' Implicit','Analytical'])
plt.show()