Without going in too much detail, the equations to be solved are the following:
These are approximated using the finite difference method:
If you've done the previous steps this is a peace of cake; the objective is to determine the term with the n+1 superscript and the final scheme that will be used for solving the problem is:
un+1i,j=uni,j−ui,jΔtΔx(uni,j−uni−1,j)−vni,jΔtΔy(uni,j−uni,j−1)
vn+1i,j=vni,j−ui,jΔtΔx(vni,j−vni−1,j)−vni,jΔtΔy(vni,j−vni,j−1)
The domain used will be a square of size 2; both components of the velocity are initialized with the value of 1 all over the grid points, except for the points that have x and y between 0.5 and 1; these will have an initial value of 2.
Another issue is the boundary conditions of the domain; the velocity is set to zero at the limits of the domain.
The code looks like this:
Python code for 2D Nonlinear Convection [lines 1-44] |
Python code for 2D Nonlinear Convection [lines 21-63] |
Solution after 400 iterations |
Some observations apply here:
- the plot is created using a color-map available in pylab module, named coolwarm; this is used to show the high values of the velocity; other color-maps are available on the SciPy page;
- the solution shows a change in the wave profile that appears as the wave travels through the domain;
- in reality this deformation creates a brake at the crest of the wave;
- thus the nonlinear convection creates a non-uniform transport of the properties in the fluid domain.
The code and plots can be downloaded freely from my GitHub account; if you have any questions feel free to leave a comment below.
Next we will see the behavior of the diffusion component.
0 comments:
Post a Comment