6. The 2D advection equation
6.1. Basic formulas
Here I show the 2-dimensional advection equation.
Where, \(t\) is the time, \(x, y\) are the axes of Cartesian coordinates, \(f\) is a variable to be advected, and \(u,v\) are advection velocities in the directions of \(x, y\).
Similar to the 1D advection equation, while the distribution form is maintained, the theoretical solutions to this equation, \(f\), move in the direction of \(x\) at a velocity of \(u\) and in the direction of \(y\) at a velocity of \(v\).
6.2. The upwind difference scheme
The upwind difference equation for the advection term is as follows.
Where, \(\Delta x, \Delta y, \Delta t\) are the calculation step sizes in the directions of \(x, y, t\), respectively, and \((i,j)\) are the grid numbers in the directions of \((x,y)\), respectively. Consequently, for example, when \(u>0, \; v>0\), the difference scheme for Equation (6.1) is as follows.
Where, \(f_n(i,j)\) is the value of \(f(i,j)\) at \(t=t+\Delta t\). From Equation (6.4), \(f_n(i,j)\) can be obtained by repeating calculations for the following equation for a step of \(\Delta t\). In this case, the scheme gives a backward difference in the direction of \(x\) and in the direction of \(y\).
6.2.1. An example of calculations by backward difference scheme
This is an example of calculation for when \(u>0, \; v>0\). The initial distribution of \(f\) is conical, as shown in Figure Figure 6.1.
A conical distribution is given by following equation.
Where,
Where, \(X_p, Y_p\) are the locations of peaks, \(f_p\) is the value of the peak, and \(R\) is the radius of the bottom.
6.2.1.1. The Python code and a calculation example
The Python code using (6.5) is as follows. https://github.com/YasuShimizu/Python-Code/blob/main/2d_backward_p3d.py The following figure shows the calculation results calculated by using the code. In this example, \(u=v=0.5\) (m/s) and:math:f_p=0.5, R=20 (m).
As with the 1D case, the peak values gradually decrease due to numerical diffusion and the cone gradually flattens while it moves. The results of this calculation are not entirely accurate.
6.2.2. The upwind difference scheme with varying advection direction
The updating formula for \(f\) in which the advection terms of Equation (6.2) and Equation (6.3) are expressed with one equation is as follows.
Equation (6.8) is an upwind difference scheme that can be applied regardless of the sizes or signs of of \(u, v\).
Now, let us try to test this 2D upwind difference scheme under the condition where \(u, v\) vary. We assume that \(u,v\) is expressed by the following equations.
The motion expressed by these equations is circular, where \(r_t\) is the radius of curvature for circular motion, \(\omega\) is the angular velocity, and \(\theta\) is the phase angle. Assuming that the peak of the cone shown in Figure Figure 6.1 moves according to Equation (6.9), the calculation results are shown by the following figure (Figure 6.3). In this example, \(T\) is the period of circular motion, and when we assume that \(T=\) = 100 sec, \(r_t\) = 30 m and f_p = 0.5. The relationship between \(T\) and \(\omega\) is given by the following equation.
Figure 6.3 is given merely by moving the distribution of the cone with the velocity of Equation (6.9). It is not the difference calculation result for Equation (6.1). However, in a sense, this is the target exact solution for the numerical calculations we will be performing. For reference, the Python code for calculating the animation of Figure 6.3 is below.
https://github.com/YasuShimizu/Python-Code/blob/main/3dcone_circle_m3d.py
I am sorry for the long introduction, but now let us try the upwind difference scheme of the 2D advection equation, which is the goal of this section.
6.2.2.1. The Python code and a calculation example
Below is the Python code using Equation (6.1).
https://github.com/YasuShimizu/Python-Code/blob/main/2d_upwind_circle.py
Using this code, under the initial conditions of Equation (6.6), \(u,v\) are varied using Equation (6.9). The results are shown in the figure below.
As expected, the upwind difference scheme results in the gradual diffusion of the initial shape and in the attenuation of the peak values. Although the calculation results are stable, as they were the 1D calculation, the upwind difference scheme is proven not to give accurate calculation results.
6.2.2.2. Problem (4)
\(f\) is a variable whose initial condition is the cone-shape distribution. |
Calculate the changes in \(f\) with time when \(f\) continuously moves along the sides of the rectangular area.
6.3. The higher-order difference scheme
Here, as I explained for the 1D higher-order difference scheme, I describe the 2D version of the CIP method as a 2D higher-order difference scheme.
6.3.1. Calculating the advection term by using the 2D CIP method
To simplify the explanation, first, we calculate for when \(u<0\) and \(v<0\).
As shown in Figure 6.5, set the calculation point numbers in the \(x, y\) directions as \(i,j\). We assume that points within the range of \(i, i+1, j, j+1\) (shown by the white dot) at time \(t\) move during the time of \(\Delta t\) to the black dot in the figure. 前
As was explained for the 1D calculation, this is a problem for the estimation of the distribution of \(f\) regarding the black dot in Figure 6.5. How can we estimate the distribution form of \(f\)? Therefore, assuming that when…
When we can estimate the distribution form of \(F(X,Y)\), we have…
With this, we can update the time of \(f\). Note that, here, \(f\) is a discrete value for the \((i,j)\) grid, and \(F\) is a continuous function.
Although \(F\) was assumed to be a curve of the third order for the 1D problem, here we assume it to be a surface of the third order. \(F(X,Y)\) must satisfy the following relationships when \(X=0, Y=0\).
(Where, \(F_x(X,Y)=\displaystyle{{\partial F}\over{\partial x}}\), \(F_y(X,Y)=\displaystyle{{\partial F}\over{\partial y}} (X,Y)\), \(f_x(i,j)=\displaystyle{{\partial f}\over{\partial x}} (i,j)\), \(f_y(i,j)=\displaystyle{{\partial f}\over{\partial y}} (i,j)\).)
Therefore, we set \(F(X,Y)\) as follows.
This equation automatically satisfies Equation (6.13). Other conditions that need to be satisfied are…
By using these relationships, the factors in Equation (6.14) are as follows.
6.3.1.1. Problem (5)
Derive Equation (6.16) to check whether the expression of \(a_1 \sim g_1\) is right. |
6.3.2. Calculating the advection term with the 2D CIP method (generalization)
The explanation thus far is for \(u<0\) and \(v<0\). Actually, there are eight possible combinations for the combinations of signs of \(u, v\). However, it would be very complicated to formulate and program all the combinations. Therefore, we introduce a sign function (\(\mbox{sign}\)) as we did for the ID calculation.
\(F(X,Y)\), the distribution form of the variables between grids, is defined as (6.18) by defining \(X, Y\) as Figure 6.6, and by transforming Equation (3.7) to the second order.
Where, the factors \(a_1 \sim g_1\) are expressed as follows by using \(i_s, j_s, i_m, j_m\), regardless of the signs of \(u, v\).
6.3.2.1. Problem (6)
Derive Equation (6.19) to check whether the expression of \(a_1 \sim g_1\) is right. |
6.3.3. Updating the differentiation amount
Under the CIP method, in addition to the variable \(f\), its differentiation, \(f_x, f_y\), also needs to be updated from time to time. Now, we perform partial differentiation for both sides of Equation (6.1) with respect to \(x\).
Assuming that \(\displaystyle{{{\partial f}\over{\partial x}}}\) is \(f_x\), we have…
As we can see, the left side is a 2D advection equation with respect to :f_x. This means that, here, we can directly apply the 2D CIP method. When \(u, v\) are constants, the right side is 0. When they are variables, we can apply [ The basic concept of the CIP method ], which is explained under the 1D CIP method. The calculation should apply the split method. The central difference scheme can be applied for the difference form on the right side.
Similarly, when we perform partial differentiation for Equation (6.1) with respect to \(y\), and we assume that \(\displaystyle{{{\partial f}\over{\partial y}}}\) is \(f_y\), then we have…
This is the same form as Equation (6.21). Therefore, the advection term on the left side can be calculated with the CIP method, and the source term on the right side can be calculated with a central difference scheme.
6.3.4. The Python code and a calculation example
The Python code for the 2D CIP method mentioned above is found at…
https://github.com/YasuShimizu/2d_advection_cip
The calculation that results from the code is shown below. The calculation conditions are the same as the aforementioned The upwind difference scheme; that is, a cone distribution with circular motion.
The calculation results show that the circular motion continues and that the cone shape is largely preserved. The CIP method is a numerical calculation method for the 2D advection equation and gives highly accurate calculation results.