Two non-mixing fluids dynamics

I am trying to implement the model describing flows of two fluids that do not mix (like water and oil for example). They have different material parameters as well (density, viscosity etc.) If it would be just one fluid, I would just implement Navier-Stokes equations. However, for two fluids I need somehow keep track, of which fluid is where since it changes the parameters of Navier-Stokes. I was trying to do it by introducing a scalar variable that is 0 for the first fluid and 1 for the second, and updating this variable according to the velocity field. However, this approach in my case is very unstable, so I didn’t succeed.

Does anyone now existing examples of modeling two unmixing fluids? Or someother method I should try? Thank you!

This is a challenging problem, with many solutions available in the literature. The methods from this paper are all stated in terms of variational forms, and should be possible to implement in FEniCS, but I don’t know of an existing open-source implementation.


There are many available methods for approximating immiscible fluid problems each with advantages and disadvantages. As for existing libraries which are based on FEniCS to some degree, two come to mind:

  • Using an HDG discretised PDE-constrained projection of tracer data so to exactly conserve mass: LEoPart (paper)
  • Using DG methods Ocellaris.