2025-05-09 08:28:08
This post is part of a series of articles about the Finite Difference Method, which includes other topics such as:
In the first article of this series, it has been shown that the derivatives of continuous functions can be approximated on a discontinuous domain.The next step is to apply these derivatives to parabolic partial differential equations (PDEs), with the heat equation being a standard example, and we will discretize this equation.
The one-dimensional heat equation has the form:
∂u/∂t = D(∂2u/∂x2)
Where u(x,t) is the temperature at position x and time t, D is the diffusivity coefficient.
We will approximate the derivative:
Use Forward Difference for the time derivative:
∂u/∂t ≈ (uin+1−uin)/Δt
Use the second-order Centered Difference for the spatial derivative:
∂x2∂2u≈(Δx)2ui+1n−2uin+ui−1n
Substituting the values into the equation, we get:
Δtuin+1−uin=D⋅(Δx)2ui+1n−2uin+ui−1n
Rearrange to find uin+1:
uin+1=uin+(Δx)2DΔt(ui+1n−2uin+ui−1n)
Let α=(Δx)2DΔt will yield:
uin+1=uin+α(ui+1n−2uin+ui−1n)
This equation can be used to directly compute uin+1 from the known values of uin, ui−1n, and ui+1n, hence it is called an explicit equation.
If the initial conditions are set, for example:
u0=[0,0,1,0,0,1,0,0,1,0,0]
With "heat wave peaks" at 3 points and selecting the parameters:
Δx=1,Δt=0.001,D=1⇒α=1⋅0.00112=0.001\Delta x = 1,\quadDelta t = 0.001,\quad D = 1 \Rightarrow \alpha = \frac{1 \cdot 0.001}{1^2} = 0.001Δx=1,Δt=0.001,D=1⇒α=121⋅0.001=0.001
Can use the formula:
Δx=1,Δt=0.001,D=1⇒α=121⋅0.001=0.001
To calculate the time-marching continuous values
If you choose Δt=0.01, you will get α=0.01, which causes the answer to oscillate violently:
To ensure the stability of this explicit method, the condition must be met:
α=(Δx)2DΔt≤21
If this is not followed, the answer will be unstable and may result in distorted waves.
Choose:
Δx=1,Δt=0.001,D=1⇒α=0.001≤0.5
Formula:
uin+1=uin+0.001(ui+1n−2uin+ui−1n)
The result will be:
No negative values.
Accurately reflects the characteristics of heat propagation.
Although this explicit method is easy to compute, the main drawback is the limitation of the time step:
The next article will introduce implicit methods, such as Crank-Nicolson, to avoid this limitation.
Reference: Solving the Diffusion Equation Explicitly
From https://www.quantstart.com/articles/Solving-the-Diffusion-Equation-Explicitly/
2025-01-10 10:12:01
2024-05-31 03:06:49
2024-05-28 03:09:25
There are many other interesting articles, try selecting them from below.
2025-01-21 02:41:00
2025-03-06 04:11:40
2024-03-15 04:59:12
2025-04-18 03:18:46
2023-10-02 05:48:51
2023-10-20 09:55:24
2024-08-06 10:34:57
2025-03-20 02:33:38