Numerical Error Analysis
Numerical Error Analysis
Space Space
At 𝑥 = 𝑎, 𝑦0 = 𝑦2 − 2𝛼. So at 𝑥 = 𝑎,
2(𝑦2 −𝑦1 −𝛼)
+ 𝑓 𝑥1 , 𝑦1 = 0
∆𝑥 2
2(𝑦𝑁−1 −𝑦𝑁 +𝛽)
At 𝑥 = 𝑏, 𝑦𝑁+1 = 𝑦𝑁−1 + 2𝛽. So at 𝑥 = 𝑏, +𝑓 𝑥𝑁 , 𝑦𝑁 = 0.
∆𝑥 2
For any general node 𝑖,
(𝑦𝑖+1 −2𝑦𝑖 + 𝑦𝑖−1 )/∆𝑥 2 = −𝑓𝑖
Where 𝑓𝑖 = 𝑓 𝑥𝑖 , 𝑦𝑖 .
Advection-Diffusion Equation in Neumann Boundary
Condition:
𝜕𝑢 𝜕𝑢 𝜕2 𝑢
The Advection- Diffusion equation is = −𝑣 + 𝐷 2.
𝜕𝑡 𝜕𝑥 𝜕𝑥
𝜕𝑢
We consider zero flux BC, i.e., = 0 at 𝑥 = 𝑥1 = 𝑎 and 𝑥 = 𝑥𝑁 = 𝑏.
𝜕𝑥
𝑑𝑢1
At 𝑥 = 𝑥1 , = 2𝐷 𝑢2 − 𝑢1 .
𝑑𝑡
𝑑𝑢𝑁
At 𝑥 = 𝑥𝑁 , = 2𝐷 𝑢𝑁−1 − 𝑢𝑁 .
𝑑𝑡
For any general node 𝑖,
𝑑𝑢𝑖 1
= − 𝑣 𝑢𝑖+1 − 𝑢𝑖−1 + 𝐷(𝑢𝑖+1 − 2𝑢𝑖 + 𝑢𝑖−1 ).
𝑑𝑡 2
𝐷 𝑣
Where 𝐷 = , and 𝑣 = .
2∆𝑥 2 ∆𝑥
Advection-Diffusion Equation in Neumann Boundary Condition(2nd Method):
𝜕𝑢 𝜕𝑢 𝜕2 𝑢
• The Advection- Diffusion equation is = −𝑣 + 𝐷 2.
𝜕𝑡 𝜕𝑥 𝜕𝑥
𝜕𝑢
• We consider zero flux BC, i.e., = 0 at 𝑥 = 𝑥1 = 𝑎 and 𝑥 = 𝑥𝑁 = 𝑏.
𝜕𝑥
• To impose the Boundary Condition at the left boundary, 𝑢(𝑥 + ∆𝑥) and 𝑢(𝑥 + 2∆𝑥) are
needed to be expanded in Taylor Series:
𝜕𝑢 1 2 𝜕 2 𝑢 1 3 𝜕 3 𝑢
𝑢 𝑥 + ∆𝑥 = 𝑢 𝑥 + ∆𝑥 + ∆𝑥 2
+ ∆𝑥 3
+ ⋯…………..
𝜕𝑥 2 𝜕𝑥 3! 𝜕𝑥
and
𝜕𝑢 1 2 𝜕2𝑢 1 3 𝜕3𝑢
𝑢 𝑥 + 2∆𝑥 = 𝑢 𝑥 + 2∆𝑥 + 4 ∆𝑥 2
+ 8 ∆𝑥 3
+ ⋯…………..
𝜕𝑥 2 𝜕𝑥 3! 𝜕𝑥
Multiplying the first equation by 8, and then subtracting the second equation from it, we get
𝜕𝑢
𝜕2 𝑢 8𝑢 𝑥+∆𝑥 −𝑢 𝑥+2∆𝑥 −7𝑢 𝑥 −6∆𝑥 𝜕𝑥
= +𝑂 ∆𝑥 2
𝜕𝑥 2 2∆𝑥 2
𝜕2 𝑢 8𝑢2 −𝑢3 −7𝑢1
The Boundary condition at 𝑥 = 𝑥1 gives =
𝜕𝑥 2 2∆𝑥 2
𝑑𝑢1 𝐷
So at 𝑥 = 𝑥1 , = 𝐷 8𝑢2 − 𝑢3 − 7𝑢1 , with 𝐷 = .
𝑑𝑡 2∆𝑥 2
• To impose the Boundary Condition at the right boundary, 𝑢(𝑥 − ∆𝑥) and 𝑢(𝑥 − 2∆𝑥) are
needed to be expanded in Taylor Series:
𝜕𝑢 1 2 𝜕 2 𝑢 1 3 𝜕 3 𝑢
𝑢 𝑥 − ∆𝑥 = 𝑢 𝑥 − ∆𝑥 + ∆𝑥 2
− ∆𝑥 3
+ ⋯…………..
𝜕𝑥 2 𝜕𝑥 3! 𝜕𝑥
And
𝜕𝑢 1 2 𝜕2 𝑢 1 3 𝜕3 𝑢
𝑢 𝑥 − 2∆𝑥 = 𝑢 𝑥 − 2∆𝑥 + 4 ∆𝑥 − 8 ∆𝑥 + ⋯…………..
𝜕𝑥 2 𝜕𝑥 2 3! 𝜕𝑥 3
Multiplying the first equation by 8, and then subtracting the second equation from it, we get
𝜕𝑢
𝜕2 𝑢 8𝑢 𝑥−∆𝑥 −𝑢 𝑥−2∆𝑥 −7𝑢 𝑥 +6∆𝑥
= 𝜕𝑥
+𝑂 ∆𝑥 2
𝜕𝑥 2 2∆𝑥 2
𝜕2 𝑢
8𝑢𝑁−1 −𝑢𝑁−2 −7𝑢𝑁
The Boundary condition at 𝑥 = 𝑥𝑁 gives =
𝜕𝑥 2
2∆𝑥 2
𝑑𝑢 𝐷
So at 𝑥 = 𝑥𝑁 , 𝑁 = 𝐷 8𝑢𝑁−1 − 𝑢𝑁−2 − 7𝑢𝑁 , with 𝐷 = .
𝑑𝑡 2∆𝑥 2
• For any general node 𝑖,
𝑑𝑢𝑖 1 𝑣
= − 𝑣 𝑢𝑖+1 − 𝑢𝑖−1 + 𝐷(𝑢𝑖+1 − 2𝑢𝑖 + 𝑢𝑖−1 ) , with 𝑣 = .
𝑑𝑡 2 ∆𝑥