# How to discretize continuity equation with velocity calculated using Darcy's law?

$$\partial_t(\epsilon_g\rho_g)+\partial_x\cdot(\epsilon_g\rho_g\mathbf{v}_g)=\Pi$$

I want to program normal continuity equation and Darcy's law to calculate velocity. $$\mathbf{v}_g=-\frac{1}{\epsilon_g \mu}\mathbf{\bar{\bar{K}}}\cdot\partial_x p$$

I approach it like this:

I am using upward differencing to discretize the equation and initially guessing the value of velocity in each cell. Now, having calculated the density, I find pressure field using ideal gas law and use Darcy's law to update velocity. (I am not modelling the time variable term in the continuity equation)

Now, I iterate this process by calculating density again via the updated velocity and repeat the procedure. But my solution doesn't converge. In fact, after 5 iterations I begin to get negative density values. (Values of density and velocity are known at the boundary, and it is a 1-D case)

So please guide me on how should I approach the problem, what am I wrong about, and what am I missing?

• Why not just solve the coupled problem for velocity and pressure at once, rather than trying to iterate things out? – Wolfgang Bangerth Dec 28 '18 at 18:24
• Also, it would probably be useful to add the equations you are trying to solve. – Wolfgang Bangerth Dec 28 '18 at 18:24
• @Wolfgang Bangerth I am writing as a separate answer to ur query since I can't add a comment right now due to low reputation. As I mentioned, to calculate velocity I need pressure in the domain, and for that I would need density in the domain, which also I need to calculate. So I am starting with an initial approximation for velocity, to calculate a density which is not correct(since I calculated it as per the initial approximation for u). Then I use this density to calculate pressure(using ideal gas law), which in turn I am using to update velocity using darcy's law. And then I calculate dens – anshul suri Dec 28 '18 at 19:43
• Whatcis $\epsilon_g$? Are you solving compressible flow in porous media? – Paul Dec 29 '18 at 16:23
• What is the relationship between $\rho$ and $p$ in your equations? – Wolfgang Bangerth Dec 30 '18 at 17:28