All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: To review the literature about ODE and to write the python program to substantiate our results. Theory: …
GAURAV KHARWADE
updated on 20 Oct 2020
Objective: To review the literature about ODE and to write the python program to substantiate our results.
Theory:
Ordinary Differential Equations (ODE)
An ordinary differential equation (ODE) is an equation that involves some ordinary derivatives (as opposed to partial derivative) of a function. Often, our goal is to solve an ODE, i.e., determine what function or functions satisfy the equation. It is also an equation that determines the relationship between function and one or more derivative of that function.
For example, this is a differential equation that relates the function y(t) with its first and second derivatives:
d2dt2y(t)+14ddty(t)+y(t)=sin(t)
The above example is the Ordinary Differential Equation (ODE) because the unknown function y(t), is a function of a single variable, in this case, it is 't'. Because we are dealing with the function of a single variable, the only ordinary derivative of the function will appear in the equation.
If we are dealing with the function of two or more variables, the partial derivatives of the function would appear in the equation, and we would call this differential equation a Partial Differential Equation (PDE).
For example, the PDE is:
d2udx2+d2vdy2+d2wdz2=c2d2udt2
Why do we required to study differential equatioins?
The reason is the differential equation arises is the mathematical model that describes the most physical process for example, convection, turbulence, combustion, spray transfer, other physical phenomenons.
To solve the differential equation means to find a function that satisfies the equation.
Stability of ODE:
Stability of a particular solution of interest (eg a traveling wave or another type of coherent structure or pattern) means, roughly speaking, that if the system starts with an initial condition near that particular solution, then the system will stay near it for all time.
All these ODE's, PDE's we are going to solve numerically with the aid of numerical schemes in computers. Numerical solution schemes are often referred to as being explicit or implicit. When a direct computation of the dependent variables can be made in terms of known quantities, the computation is said to be explicit. In contrast, when the dependent variables are defined by coupled sets of equations, and either a matrix or iterative technique is needed to obtain the solution, the numerical method is said to be implicit.
The general form of ODE is:
Let us consider any function which varies along with time 't'.
dydt=f(t)
ynew−yoldΔt=f(t)
ynew=Δt⋅f(t)+yold
Rewritting above equation as:
ynew=yold+Δt⋅f(t)
yn+1=yn+dtâ‹…f(t)
For example,
dydt=−1000y−e−t
Explicite Formulation:
yn+1=yn−dt⋅(1000yn+e−t)
Implicite Formulation:
yn=yn-1−dt⋅(1000yn+e−t)
Analytical expression:
y(t)=e−1000t(1−e−999t)999
Python Code:
In this we are going to look at the effect of time step on solution. Time step we are going to cinsider is 1e-4, 5e-4, 10e-4, 15e-4, 20e-4.
"""
Program for explicite, implicite, and analytical solution of ODE
By- Gaurav V. Kharwade || Skill-lync-2020
"""
import numpy as np
import matplotlib.pyplot as plt
dt= 1e-4; # To define the time step.
t_end= 0.1;
def explicit_euler(t_end, dt):
t = np.arange(0,t_end,dt)
y= np.zeros(len(t))
for i in range (1,len(t)):
y[i] = y[i-1] + dt * (-1000 * y[i-1] - np.exp(-t[i-1]));
return [t,y]
def implicite_euler(t_end, dt):
t = np.arange(0,t_end,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+1000*dt);
return [t,y]
def analytical_solution(t_end, dt):
t = np.arange(0,t_end,dt)
y= np.zeros(len(t))
for i in range (1,len(t)):
y[i] = (np.exp(-1000*t[i-1])*(1-np.exp(999*t[i-1])))/999
return [t,y]
t,y_e = explicit_euler(t_end,dt)
t,y_i = implicite_euler(t_end,dt)
t,y_ana = analytical_solution(t_end,dt)
plt.plot(t,y_e)
plt.plot(t,y_i)
plt.plot(t,y_ana,'--',color='black')
plt.legend(['explicit','implicite','analytical'])
plt.show()
Results:
The below graphs are showing a comparison of the stability of the solution for different time steps.
The graph clearly inferred that increase in timestep would cause instability in the final solution.
When does an ODE become unstable?
When we writing code for explicit form solution goes unstable because if the time step is really large, nos. of grid points really large, convective velocity really large.
Numerical stability has to do with the behavior of 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
Y-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 yn+1, indicating that there must be some limit on the size of the time step for there to be a solution.
How does stability affect engineering simulations?
It is always bad to have an unstable solution for any kind of engineering simulation because it gives us un-physical results.
e.g. If we are running the simulation of aerofoil and we got the unstable solution then the drag coefficient and lift coefficient we are calculating will be unphysical and we can not trust this simulation.
Can stability conditions be derived for all types of problems?
There are two ways to determine or derive the stability of problems-
1. Eigen Value analysis- Real eigenvalues less than or equal to Zero
2. Von-Neumann stability analysis- This can be applied when solution domain is periodic.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 9 - Senstivity Analysis Assignment
Objective: To write the code which will take entire reactions of GRI mechanism 3.0 and take out the most sensitive top 10 reactions. The main parameters are as follows: Write code to list out the top 10 most sensitive reactions from a list of all reactions from the GRI mechanism. The sensitivity parameters should be with…
04 Jan 2021 05:51 PM IST
Auto ignition analysis of combustible mixture methane under different conditions using Cantera and Python
Objective: To study auto-ignition using Cantera. Following are the tasks to perform using Cantera: Plot the variation of Auto Ignition time of Methane with a constant temperature of 1250K and pressure varying from 1 to 5 atm. Plot the variation of Auto Ignition time…
06 Dec 2020 04:55 AM IST
Week 6 - Multivariate Newton Rhapson Solver
Objective: To solve a given set of Ordinary Differential equations using the Multi-Variate Newton Raphson Method. Given: The set of ODE's are given below: dy1dt=−0.04⋅y1+104⋅y2⋅y3 dy2dt=0.04⋅y1−104⋅y2⋅y3−3⋅107⋅y22 dy3dt=3⋅107⋅y22 The jacobian should be estimated numerically and not analytically.…
01 Nov 2020 03:50 AM IST
Week 5 - Literature review: ODE Stability
Objective: To review the literature about ODE and to write the python program to substantiate our results. Theory: …
20 Oct 2020 03:52 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.