In order to discretize this equation we will use the same method as in the 1D problem:
Solving for the unknown, we get the scheme we will implement in Python:
The initial conditions are similar; the domain will be a square of size 2; this will be divided in grid points; all points will be assigned with a starting velocity of 1, except for the points that have the x and y coordinates between 0.5 and 1; these will have an initial velocity of 2. You can see a representation of the initial conditions below:
Initial condition |
The resulted code is given below:
Python code for 2D Linear Convection [lines 1-44] |
Python code for 2D Linear Convection [lines 33-76] |
Solution after 100 iterations |
The behavior is the same as for the 1D problem: the wave is moving without change in the shape of the profile.
The difficulty of this problem lies in the coding of the second dimension.
The code and plots can be downloaded from GitHub.
In the next post we will be solving the nonlinear 2D problem.
If you have questions or observations, feel free to leave a comment below.
0 comments:
Post a Comment