Finite Deference Method by Dr. Samah Mohamed Mabrouk www.smmabrouk.faculty.zu.edu.eg
Finite-difference method
Different Difference formulas B C x f(x) f(x+x) i i+1 Different Difference formulas Taylor series expansion First forward difference approximation Solve for order of x First forward difference approximation
First backward difference approximation f(x) f(x-x) i i-1 First backward difference approximation Taylor series expansion Solve for order of x First backward difference approximation
Central difference approximation Subtracting (2) from (1) Central difference approximation B C x f(x) f(x+x) f(x-x) A i-1 i i+1
Second derivative Multiply (1) by 2 and subtracting it from (2) Solve for forward difference approximation
backward difference approximation Central difference approximation
backward difference approximation forward difference approximation backward difference approximation Central difference approximation
BVP IVP ODE the conditions given are specified at the same value of x, Initial Value Problems IVP Boundary Value Problems BVP the conditions given are specified at the same value of x, the two conditions are specified at different values of x.
Dirichlet BC
y0 =0 y1 y2 y3 y4 =0 x0 x1 x2 x3 x4 0 0.25 0.5 0.75 1 We then substitute in the difference equation for the inner nodes (unknowns) as follows: Rearrange the equations and substitute by the boundary values y0 =0, y4 =0, we get the following 3x3 system
Writing this system in matrix-vector form as
Solving this system in Matlab >> Y=A\b Y = -0.0088 -0.0407 -0.0400 >> format long >> Y=inv(A)*b -0.00880923450790 -0.04070473876063 -0.03999594977724
In case of Neumann BC: we apply FD for the first derivative, for example: This means that the value un at the last node is unknown and will need an extra equation at that node In this equation we replace un+1 from the approximation of Neumann BC
Example: Solve Using FD method. Let h=0.25 Solution du/dx=1 u0 =0 u1 u2 u3 u4 x0 x1 x2 x3 x4 We then substitute in the difference equation for the inner nodes (unknowns) and the Neumann boundary node as follows:
x0 x1 x2 x3 x4 u0 =0 u1 u2 u3 u4 du/dx=1 u5 We substitute by u5 in the last equation from the Neumann BC as
This will lead to a linear system of equations of four unknowns In matrix form Au=b
Heat equation The conservation of heat can be used to develop a heat balance for a long, thin rod. If the rod is not insulated along its length and the system is at steady state. The equation that results is: T1 T2 Ta
For L= 10 m rod with T(0) = 40, T(L) = 200, Ta = 20 and h = 0.01 Solve Solution
Divide the rod into a grid by x = 2m 40 200 i=0 1 2 3 4 5
Writing this system in matrix-vector form as
Exercise
Exercises