July 21, 2014

2D Nonlinear Convection

21.7.14 Posted by Florin No comments
Now it's time for the 2D nonlinear convection; this is just a re-writing of the linear convection code, except that now the wave speed components are not constant, but the actual components of the flow velocity.
Without going in too much detail, the equations to be solved are the following:
ut+uux+vuy=0
vt+uvx+vvy=0

These are approximated using the finite difference method:

un+1i,juni,jΔt+uni,juni,juni1,jΔx+vni,juni,juni,j1Δy=0

vn+1i,jvni,jΔt+uni,jvni,jvni1,jΔx+vni,jvni,jvni,j1Δy=0

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,jui,jΔtΔx(uni,juni1,j)vni,jΔtΔy(uni,juni,j1)


vn+1i,j
=vni,jui,jΔtΔx(vni,jvni1,j)vni,jΔtΔy(vni,jvni,j1)

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]
The initial condition plot is the same as the linear convection problem. The domain is mesh using 500 cells in each direction; the solution after 400 steps is the following:

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