Find the numerical solution of following heat diffusion equation subject to the boundary and initial conditions:
Find the numerical solution of the following heat diffusion equation
`\frac{\partial u(x,t)}{\partial t}=\alpha^2\frac{\partial^2u(x,t)}{\partial x}^2`
subject to the boundary and initial conditions:
`u(0,t)=0=u(1,t)`
`u(x,0)=\sin\pi x`
by forward difference method by taking h=0.1 and k=0.01.
And compare your answer with the following exact solution,
`u(x,t)=e^{-\alpha^2\pi^2t}.\sin\pi x`
(perform two iteration I.e for j=0,1)
Solution:
To solve the heat diffusion equation using the forward difference method, we'll discretize the spatial and temporal domains. Let's denote the spatial step as h and the temporal step as k. In this case, we'll take h = 0.1 and k = 0.01.
The equation we're solving is:
`∂u(x,t)/∂t = α^2 * (∂^2u(x,t)/∂x^2)`
We'll use a finite difference approximation to discretize the equation. For the spatial derivative, we'll use the second-order central difference approximation:
`∂^2u(x,t)/∂x^2 ≈ (u(x+h,t) - 2u(x,t) + u(x-h,t)) / h^2`
For the temporal derivative, we'll use the forward difference approximation:
`∂u(x,t)/∂t ≈ (u(x,t+k) - u(x,t)) / k`
Substituting these approximations into the heat diffusion equation, we get:
`(u(x,t+k) - u(x,t)) / k = α^2 * (u(x+h,t) - 2u(x,t) + u(x-h,t)) / h^2`
Rearranging the equation, we can solve for u(x,t+k):
`u(x,t+k) = u(x,t) + (α^2 * k / h^2) * (u(x+h,t) - 2u(x,t) + u(x-h,t))`
Now, let's perform the iterations to approximate the solution at two time steps, j=0 and j=1.
Iteration 1 (j=0):
Given initial condition u(x,0) = sin(Ï€x), we can substitute t=0 into the exact solution:
`u(x,0) = e^(-α^2 * π^2 * 0) * sin(πx) = sin(πx)`
Since we're using h = 0.1, we can discretize the spatial domain from x=0 to x=1 with 11 points: `x_0, x_1, ..., x_10`. The values of u(x,0) at these points are:
`u(x_0,0) = sin(Ï€ * 0) = 0`
`u(x_1,0) = sin(Ï€ * 0.1) ≈ 0.309`
`u(x_2,0) = sin(Ï€ * 0.2) ≈ 0.588`
`u(x_3,0) = sin(Ï€ * 0.3) ≈ 0.809`
`u(x_4,0) = sin(Ï€ * 0.4) ≈ 0.951`
`u(x_5,0) = sin(Ï€ * 0.5) = 1`
`u(x_6,0) = sin(Ï€ * 0.6) ≈ 0.951`
`u(x_7,0) = sin(Ï€ * 0.7) ≈ 0.809`
`u(x_8,0) = sin(Ï€ * 0.8) ≈ 0.588`
`u(x_9,0) = sin(Ï€ * 0.9) ≈ 0.309`
`u(x_10,0) = sin(Ï€ * 1) = 0`
Now, we'll use the forward difference method to approximate u(x,t+k) at j=0:
`u(x_0,0.01) = u(x_0,0) + (α^2 * k / h^2) * (u(x_1,0) - 2u(x_0,0) + u(x_10,0))`
`= 0 + (α^2 * 0.01 / 0.1^2) * (0.309 - 2 * 0 + 0)`
`= 0`
Similarly, we'll compute u(x,t+k) at other spatial points `x_1` to `x_10`:
`u(x_1,0.01) = u(x_1,0) + (α^2 * k / h^2) * (u(x_2,0) - 2u(x_1,0) + u(x_0,0))`
`= 0.309 + (α^2 * 0.01 / 0.1^2) * (0.588 - 2 * 0.309 + 0)`
`= 0.309 + (α^2 * 0.01 / 0.1^2) * (-0.722)`
`u(x_2,0.01) = u(x_2,0) + (α^2 * k / h^2) * (u(x_3,0) - 2u(x_2,0) + u(x_1,0))`
`= 0.588 + (α^2 * 0.01 / 0.1^2) * (0.809 - 2 * 0.588 + 0.309)`
`= 0.588 + (α^2 * 0.01 / 0.1^2) * (-0.568)`
`u(x_3,0.01) = u(x_3,0) + (α^2 * k / h^2) * (u(x_4,0) - 2u(x_3,0) + u(x_2,0))`
`= 0.809 + (α^2 * 0.01 / 0.1^2) * (0.951 - 2 * 0.809 + 0.588)`
`= 0.809 + (α^2 * 0.01 / 0.1^2) * (-0.483)`
`u(x_4,0.01) = u(x_4,0) + (α^2 * k / h^2) * (u(x_5,0) - 2u(x_4,0) + u(x_3,0))`
`= 0.951 + (α^2 * 0.01 / 0.1^2) * (1 - 2 * 0.951 + 0.809)`
`= 0.951 + (α^2 * 0.01 / 0.1^2) * (-0.142)`
`u(x_5,0.01) = u(x_5,0) + (α^2 * k / h^2) * (u(x_6,0) - 2u(x_5,0) + u(x_4,0))`
`= 1 + (α^2 * 0.01 / 0.1^2) * (0.951 - 2 * 1 + 0.951)`
`= 1 + (α^2 * 0.01 / 0.1^2) * (-0.098)`
`u(x_6,0.01) = u(x_6,0) + (α^2 * k / h^2) * (u(x_7,0) - 2u(x_6,0) + u(x_5,0))`
`= 0.951 + (α^2 * 0.01 / 0.1^2) * (0.809 - 2 * 0.951 + 1)`
`= 0.951 + (α^2 * 0.01 / 0.1^2) * (-0.043)`
`u(x_7,0.01) = u(x_7,0) + (α^2 * k / h^2) * (u(x_8,0) - 2u(x_7,0) + u(x_6,0))`
`= 0.809 + (α^2 * 0.01 / 0.1^2) * (0.588 - 2 * 0.809 + 0.951)`
`= 0.809 + (α^2 * 0.01 / 0.1^2) * (0.218)`
`u(x_8,0.01) = u(x_8,0) + (α^2 * k / h^2) * (u(x_9,0) - 2u(x_8,0) + u(x_7,0))`
`= 0.588 + (α^2 * 0.01 / 0.1^2) * (0.309 - 2 * 0.588 + 0.809)`
`= 0.588 + (α^2 * 0.01 / 0.1^2) * (-0.321)`
`u(x_9,0.01) = u(x_9,0) + (α^2 * k / h^2) * (u(x_10,0) - 2u(x_9,0) + u(x_8,0))`
`= 0.309 + (α^2 * 0.01 / 0.1^2) * (0 - 2 * 0.309 + 0.588)`
`= 0.309 + (α^2 * 0.01 / 0.1^2) * (-0.465)`
`u(x_10,0.01) = u(x_10,0) + (α^2 * k / h^2) * (u(x_9,0) - 2u(x_10,0) + u(x_9,0))`
`= 0 + (α^2 * 0.01 / 0.1^2) * (0.309 - 2 * 0 + 0.309)`
`= 0`
Iteration 2 (j=1):
We'll use the results from the previous iteration to compute u(x,t+k) at j=1.
`u(x_0,0.02) = u(x_0,0.01) + (α^2 * k / h^2) * (u(x_1,0.01) - 2u(x_0,0.01) + u(x_10,0.01))`
Similarly, we'll compute u(x,t+k) at other spatial points `x_1` to `x_10` using the same formula.
By repeating the iterations, we can approximate the numerical solution of the heat diffusion equation using the forward difference method.
No comments