So I have a code that I use which solves a 1D variable coefficient diffusion problem in cartesian coordinates:

$\frac{\partial u}{\partial t}=\frac{\partial}{\partial x}\left(D(x)\frac{\partial u}{\partial x}\right)$.

It solves the equation implicitly using a backward euler discretization. it works fine, but I want to convert it into a spherically symmetric code. The problem is that I can't find information on how to do this for variable coefficients. I would appreciate if someone shows me the specific modifications I need to make.

Also, how much different those the solution for this equation looks in a 1D cartesian slab vs a 1D spherically symmetric radial slab? If they look about the same then maybe I shouldn't do the modifications. Thanks!


More generally, the equation you are solving is \begin{equation} \frac{\partial u}{\partial t} = \nabla \cdot \left( D(x) \nabla u \right) \quad , \end{equation} where the first nabla operator represents the divergence operator, and the second represents the gradient operator. Your equation is the special case for a one-dimensional cartesian coordinate system.

From a practical point of view, if you want to move into a cylindrical or spherical coordinate system all you have to do is to apply the respective definitions of the nabla operators. For example, you can find them on Wikipedia:

If you take axial and azimuthal symmetry into consideration, you can derive a similar equation in $r$ that includes metric terms, i.e.: \begin{equation} \frac{\partial u}{\partial t} = \frac{1}{r} \frac{\partial}{\partial r} \left( D(r) r \frac{\partial u}{\partial r} \right) \quad , \end{equation} As you can see, it does not really matter in this approach whether your diffusion coefficient is constant or not.

I am not sure whether telling you the final equation was already spoiling too much. But I am sure that you know how to do the implementation from here on. ;-)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.