# Using Finite Difference for explicit discretization of conservation law system

I'm trying to use finite difference to explicitly discretisize the following system:

$\frac{{\partial \rho }}{{\partial t}} = - \frac{{\partial \rho }}{{\partial x}}u - \rho \frac{{\partial u}}{{\partial x}}$

$\frac{{\partial u}}{{\partial t}} = - u\frac{{\partial u}}{{\partial x}} - \frac{\partial }{{\partial x}}\left[ {\frac{1}{{\sqrt \rho }}\frac{{{\partial ^2}(\sqrt \rho )}}{{\partial {x^2}}}} \right]$

where:

$\rho (x,t)\,\,\,,\,\,\,u(x,t)$

But i'm having difficulties since the $\rho$ time derivative is dependent on $u$ as well! I don't know which time step of $u$ to insert (or vice-versa for the $u$ time derivative).

Can it be done with finite differences ?

Thanks !

• Yes it can be done with finite differenes. A better way might be to use the method of lines and use an inbuilt ODE solver like the Matlabs ODE45 solver to do the time integration. Mar 23, 2017 at 23:44
• I'm not familiar with the methods of lines. Can you indicate how to use the finite differences here ? Mar 24, 2017 at 7:51