It has been done before, but below is an advection - diffusion solver I had to write.
The movie below shows an unphysical advection case - the concentration depended on nodes where the fluid hadn't gotten to yet (can be thought of outside the light cone of the point). I found it really interesting how the solution blew up.
More on the Above:
Advection-Diffusion is modeled by:
$$\rho\left ( \frac{\partial C}{\partial t}+v \frac{\partial C}{\partial x} \right ) - D\frac{\partial ^2 C}{\partial x^2 } =0 $$
I originally used the following stencils for the time and first spatial derivative (advection part).
$$ \frac{\mathrm{d} }{\mathrm{d} x} f(x)\approx \frac{1}{h}\left ( f(x+h) - f(x) \right )+O(h) $$
$$ \frac{\mathrm{d} }{\mathrm{d} x} f(x)\approx \frac{1}{2h}\left ( f(x+h) - f(x-h) \right )+O(h^2) $$
Gaining the higher order in the second stencil made it depend of f(x-h), which in the case of advection was on the wrong side of the wave, and where the unphysical assumption came in.
Just a neat little example of needing to think about the physics of the problem in modeling.
No comments:
Post a Comment