工学系大学院生のブログ

2人の大学院生による雑記ブログ

7-1 Explicit Method and Implicit Method[python]


$$\frac{\partial}{\partial t}(\rho C T)= \frac{\partial}{\partial x} \left( \lambda \frac{\partial T}{\partial x} \right ) + \frac{\partial}{\partial y} \left ( \lambda \frac{\partial T}{\partial y} \right ) $$


In Part 7, we aim to solve the two-dimensional unsteady diffusion equation by the implicit method and finite volume method.


What is the Implicit Method?


In the previous articles , it was discretized by the explicit method. This is a method of obtaining future information from previous information, and the images are as follows (black is known information, red is the value to be acquired).




On the other hand, the implicit method is a method of finding a solution by using future values (black is known information, red is the value to be acquired).



We will tell you how to use the implicit method in the next article.

A Comparison Between Explicit Method and Implicit Method



This time, we will use von Neumann’s stability analysis to compare the differences and advantages and disadvantages of the explicit and implicit methods.


Von Neumann’s stability analysis is used as one indicator for stable calculations. First, let’s try the following advection equation.

$$\frac{\partial u}{\partial t}+c\frac{\partial u}{\partial x}=0$$

Using explicit Method


We will use the same explicit method as before.


We use forward difference method for time and backward difference method for space.

$$\frac{u^{n+1}_j-u^n_j}{\Delta t}+c\frac{u_j^n-u^n_{j-1}}{\Delta x}=0$$

$$⇔u^{n+1}_j=u^n_j-\nu(u_j^n-u_{j-1}^n) \ \ \ \ \ \dots ①$$

Attention! \(\nu=c\frac{\Delta t}{\Delta x}\)



Then substitute the following equation used in the von Neumann stability analysis:

$$u^n_j=g^n exp(i(j\theta))$$

Since (exp (i (jtheta))) represents a unit circle in the complex plane, (g ^ n) is the radius. (N) gets larger as time passes. When (| g |> 1), (g ^ n) becomes infinitely large and diverges.

It means \(|g| \le 1\) is a stable condition.



Let’s rearrange the equation.

$$ g^{n+1} exp(i(j\theta)) = g^n exp(i(j\theta))-\nu( g^n exp(i(j\theta)) – g^n exp(i(j-1)\theta) ) $$
∵➀

$$⇔ g=1-\nu+\nu exp(-i\theta)$$

$$⇔ g=1-\nu+\nu cos\theta-i\nu sin\theta$$

$$⇔ |g|^2=(1-\nu+\nu cos\theta)^2+(\nu sin\theta)^2$$

$$⇔ |g|^2=1+2\nu ^2(1-cos\theta)-2\nu (1-cos\theta)$$


Then,

$$ 1+2\nu ^2(1-cos\theta)-2\nu (1-cos\theta) \le 1$$
∵\(|g| \le 1\)

$$ ⇔ 2\nu ^2(1-cos\theta)-2\nu (1-cos\theta) \le 0$$

$$ ⇔ \nu \le 1$$

$$ ⇔ c\frac{\Delta t}{\Delta x} \le 1$$

This is the condition for stable calculation. The articles so far have been set to satisfy this.


Maybe, you don’t care about using present time \(n\). This is the explicit method.


Using Implicit Method



Next, let’s try using the implicit method with the future time n + 1 for the spatial term.

$$\frac{u^{n+1}_j-u^n_j}{\Delta t}+c\frac{u_j^{n+1}-u^{n+1}_{j-1}}{\Delta x}=0$$

$$⇔u^{n+1}_j=u^n_j-\nu(u_j^{n+1}-u_{j-1}^{n+1}) \ \ \ \ \ \dots ②$$

$$ ⇔ g^{n+1} exp(i(j\theta)) = g^n exp(i(j\theta))-\nu( g^{n+1} exp(i(j\theta)) – g^{n+1} exp(i(j-1)\theta) ) $$

$$⇔ g=1-\nu g+\nu gcos\theta-i\nu gsin\theta$$

$$⇔g=\frac{1}{1+\nu-\nu cos \theta +i\nu sin\theta}$$

$$⇔g=\frac{1+\nu-\nu cos \theta -i\nu sin\theta}{(1+\nu-\nu cos\theta)^2+(\nu sin\theta)^2}$$

$$⇔|g|^2= \frac{(1+\nu-\nu cos \theta)^2+(\nu sin\theta)^2}{((1+\nu-\nu cos\theta)^2+(\nu sin\theta)^2)^2} $$

$$⇔|g|^2= \frac{1}{(1+\nu-\nu cos\theta)^2+(\nu sin\theta)^2} $$


Attention! \(|g| \le 1\)

$$ \frac{1}{(1+\nu-\nu cos\theta)^2+(\nu sin\theta)^2} \le 1$$

$$ ⇔1 \le (1+\nu-\nu cos\theta)^2+(\nu sin\theta)^2 $$

$$⇔0 \le \nu ^2 (1-cos\theta)+\nu(1-cos\theta)$$

$$⇔0 \le \nu+1$$

It’s always stable because of \(\nu=c\frac{\Delta t}{\Delta x} \ge 0\)


This “stability” is the strength of the implicit method.



In the explicit method, in order to increase the spatial resolution, if \(\Delta x\) is made 10 times finer, (Delta t) must be made 10 times finer.
Since the implicit method is always stable, it is not necessary to change \(\Delta t\) by making \(\Delta x\) 10 times finer.


Of course, the implicit method also has disadvantages such as “long calculation time per step” and “rough accuracy in time step”, but it is now widely used.



Next time, we will discuss how to solve a specific implicit method. We will also write the case of the diffusion equation below, so please take a look if you are interested.


*We will show the example code in Part 7-5.


by hide




・Stability analysis of diffusion equation

$$\frac{\partial u}{\partial t}=D \frac{\partial u}{\partial x^2}$$


In case of explicit method (time: forward difference method, space : central difference method)

$$\frac{u^{n+1}_j-u^n_j}{\Delta t}=D \frac{u^n_{j+1} -2 u_j^n+u^n_{j-1}}{\Delta x^2}$$

$$⇔u^{n+1}_j=u^n_j+\nu( u_{j+1}^n -2 u_j^n+u_{j-1}^n) \ \ \ \ \ \dots ①$$

Attention! \(\nu=D\frac{\Delta t}{\Delta x^2}\)


Because of ①

$$ g^{n+1} exp(i(j\theta)) = g^n exp(i(j\theta))+\nu( g^n exp(i(j+1)\theta) -2 g^n exp(i(j\theta)) + g^n exp(i(j-1)\theta) ) $$

$$⇔g=1+\nu exp(i\theta)-2\nu +\nu exp(-i\theta)$$

$$⇔g=1-2\nu +2\nu cos\theta =1-2\nu (1-cos\theta )$$

$$⇔|g|^2=1-4\nu(1-cos\theta )+4\nu ^2(1-cos\theta)^2$$

Because of \(|g| \le 1\)

$$ ⇔-4\nu(1-cos\theta )+4\nu ^2(1-cos\theta)^2 \le 0 $$

$$ ⇔-1+\nu (1-cos\theta) \le 0$$

$$ ⇔nu \le \frac{1}{1-cos\theta } \le \frac{1}{2}$$

$$ ⇔D \frac{\Delta t}{\Delta x^2} \le \frac{1}{2}$$

The diffusion equation is more stringent.



In the case of implicit method (time: forward difference method, space: center difference method)

$$\frac{u^{n+1}_j-u^n_j}{\Delta t}=D \frac{u^{n+1}_{j+1} -2 u_j^{n+1}+u^{n+1}_{j-1}}{\Delta x^2}$$

$$⇔u^{n+1}_j- \nu (u^{n+1}_{j+1} -2 u_j^{n+1}+u^{n+1}_{j-1})=u^n_j \ \ \ \ \ \dots ②$$

Attention! \(\nu=D\frac{\Delta t}{\Delta x^2}\)


Because of ②

$$ g^{n+1} exp(i(j\theta))- \nu( g^{n+1} exp(i(j+1)\theta) -2 g^{n+1} exp(i(j\theta)) + g^{n+1} exp(i(j-1)\theta) ) = g^n exp(i(j\theta)) $$

$$⇔ g(1- \nu exp(i\theta) +2\nu – \nu exp(-i\theta) ) = 1 $$

$$⇔ g(1+2\nu – 2 \nu cos\theta) = 1 $$

$$⇔ g = \frac{1}{ 1+2\nu( 1- cos\theta ) } $$

$$⇔ |g|^2 = \frac{1}{ 1-4\nu(1-cos\theta )+4\nu ^2(1-cos\theta)^2 } $$

Because of \(|g| \le 1\)

$$⇔ \frac{1}{ 1-4\nu(1-cos\theta )+4\nu ^2(1-cos\theta)^2 } \le 1 $$

$$⇔ 0 \le -4\nu(1-cos\theta )+4\nu ^2(1-cos\theta)^2 $$

$$⇔ \frac{1}{1-cos\theta} \le \nu $$

$$⇔ 0\le \frac{1}{1-cos\theta} \le \nu $$


Since it is always \(0 \le \nu\), the above condition is always satisfied.


Therefore, the implicit method is always stable even in the diffusion equation.



“Please click ads to cheer us up! Thank you! “

このエントリーをはてなブックマークに追加

Leave a Reply

Your email address will not be published. Required fields are marked *