Solution of Differential Equation by Finite Difference Method
Solution of Differential Equation by Finite Difference Method
Solution of Differential Equation by Finite Difference Method
An ordinary differential equation is that in which all the derivatives are with respect to a single
independent variable. Examples of ordinary differential equations include
Ordinary differential equations are classified in terms of order and degree. Order of an ordinary
differential equation is the same as the highest derivative and the degree of an ordinary
differential equation is the power of highest derivative.
In the coefficients A, B, C, D, E and F are either constants or functions of only (x, y) (do not
contain φ or its derivatives), it is said to be a linear equation, otherwise it is a non-linear
equation. If G = 0, the aforesaid equation is homogeneous, otherwise it is non-homogeneous.
2
Again for the above mentioned equation
Example:
Classify the following linear second order partial differential equations (PDEs) with solution
u(x,y)in the xy-plane.
3
Example: Consider the one-dimensional damped wave equation 9uxx= utt+ 6ut
Where l is the length of the rod and h1(t) the temperature at the first end and h2(t) the
temperature at the second end.
The initial conditions specify an arbitrary initial temperature distribution inside the rod:
4
Solve the differential equations subject to the boundary conditions and/or initial
conditions.
df ( x0 ) f ( x0 x) f ( x0 )
(1) Forward Difference Formula
dx x
df ( x0 ) f ( x0 ) f ( x0 x)
(2) Backword Difference Formula
dx x
df ( x0 ) f ( x0 x) f ( x0 x)
(3) Central Difference Formula
dx 2x
Example:
Solve
2 f
4 f 0 , 0 x 1.0
x 2
Subject to the boundary conditions:
f (0) 0
f (1) 1
Assume x=0.5
5
f (1) f (0) f (2)
f (1) 1
If x=0.25
f (2) 2 f (1) f (0)
4 f (1) 0
(0.25) 2
f (3) 2 f (2) f (1)
4 f (2) 0
(0.25) 2
f (4) 2 f (3) f (2)
4 f (3) 0
(0.25) 2
f(1), f(2) and f(3) are unknowns. Therefore, three equations are written to find three unknowns.
Example:
Consider the diffusion equation:
2
k 2
t x
Where k is a constant. Discretized equation:
t
r
k (x)2
We can write:
(i, j 1) r(i 1, j ) (1 2r )(i, j ) r(i 1, j ) `
Example:
The deflection in a simply supported beam with a uniform load q and a tensile axial load T is
given by
where
x:Location along the beam (in)
T:Tension applied (lbs)
E:Young’s modulus of elasticity of the beam (psi)
6
I:Second moment of area (in4)
q:Uniform loading intensity (lb/in)
L:Length of beam (in)
Given,
Find the deflection of the beam at x=50". Use a step size of Δx=25” and approximate the
derivatives by central divided difference approximation.
Solution:
Substituting the given values,
𝜕2 𝑦
Approximating the derivative at node i by the central divided difference approximation
𝜕𝑥 2
7
Equations above are 4 simultaneous equations with 4 unknowns and can be written in matrix
form as
Example
Take the case of a pressure vessel that is being tested in the laboratory to check its ability to
withstand pressure. For a thick pressure vessel of inner radius a and outer radius b , the
differential equation for the radial displacement u of a point along the thickness is given by
The inner radius a= 5′′ , and the outer radius b= 8’’ , and the material of the pressure vessel is
ASTM A36 steel
Divide the radial thickness of the pressure vessel into 6 equidistant nodes, and find the radial
displacement profile
8
Let us break the thickness, b-a , of the pressure vessel into n+1 nodes, that is is node and is
node . That r=a is nodes i=0 and r=b is node i=n . That means we have n+1 unknowns. We can
write the above equation for nodes 1,…., n-1. This will give us n-1 equations. At the edge
nodes, i=0 and i=n , we use the boundary conditions of
We have been asked to do the calculations for n=5, that is a total of 6 nodes. This gives
9
Writing the above Equations in matrix form gives
After solving
In explicit finite difference schemes, the temperature at time n+1 depends explicitly on the
temperature at time n. The explicit finite difference discretization of above equation is
This can rearranged in the following manner (with all quantities at time n+1 on the left-hand-
side and quantities at time n on the right-hand-side)
𝑛
Since we know𝑇𝑖+1 , 𝑇𝑖𝑛 and 𝑇𝑖−1
𝑛
, we can compute 𝑇𝑖𝑛 . The major advantage of explicit finite
difference methods is that they are relatively simple and computationally fast. However, the
main drawback is that stable solutions are obtained only when
𝜕2 𝑇
In implicit finite difference schemes, the spatial derivatives 2 are evaluated (at least partially)
𝜕𝑥
at the new time step. The simplest implicit discretization of heat equation in 1D is
This can be rearranged so that unknown terms are on the left and known terms are on the right
𝐾∆𝑡
Where 𝑠 = . The main advantage of implicit finite difference methods is that there are
∆𝑥 2
10
no restrictions on the time step, which is good news if we want to simulate geological processes
at high spatial resolution. Taking large time steps, however, may result in an inaccurate solution.
As usual, the first step is to discretize the spatial domain with nx finite difference points. The
implicit finite difference discretization of the temperature equation is
11