July 21, 2014

2D Diffusion

21.7.14 Posted by Florin No comments
From all components of the Navier Stokes equations, I think that the diffusion is the most spectacular and the most intuitive.
The idea is that in a given static (i.e. velocity is zero) fluid domain a property will be transported from high concentration regions to low concentration regions; this transport is possible because of the particles collision and is more powerful for gases than for liquids.

We will be solving this numerically with Python. The equation for 2D diffusion is the following:
ut=ν2ux2+ν2uy2

Using the methods seen in previous steps, this equation can be approximated as:

un+1i,juni,jΔt=νuni+1,j2uni,j+uni1,jΔx2+νuni,j+12uni,j+uni,j1Δy2

And the scheme to be implemented in Python is the following:

un+1i,j=uni,j+νΔtΔx2(uni+1,j2uni,j+uni1,j)

+νΔtΔy2(uni,j+12uni,j+uni,j1)

The scheme will be implemented as a function to be called with different values of iteration. The Python code is the following:

Python code for 2D Diffusion [lines 1-43]
Python code for 2D Diffusion [lines 26-67]
The initial conditions are the same as usual and are represented with the following plot:


The solution is plotted for various steps in order to see the evolution in time:




The images tell the story better than any words; the code and plots are available on my GitHub account.
If you have any questions feel free to leave a comment below.

0 comments:

Post a Comment