Take the 2-minute tour ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free, no registration required.

Before introducing my question I would like to outline the fact that I'm a coder, so I can be wrong when using some kind of terminology.

What is a good model for computing the flow, the shape and all the geometric properties of the water? ( and other similar liquids in general, like mixtures based on water or some more oily and viscous substances )

I assume that this kind of simulation will be based on particles, which means entities that are part of the domain that defines the "drop" of water, but what I need is the math, the equations and the mathematical model/s; I have no idea what is the math behind a liquid that meets a surface and if there is any algorithm or model that can be translated into machine code to compute that.

To keep things simple I'm not considering the air and what kind of properties the air can possibly modify, or any other extra variable outside the domain of this drop of liquid, like adding a inclined plane where the drops, let's say that for now I'm considering a vector and an X quantity of liquid, this quantity is than sprayed or just dropped on the surface and I should be able to reproduce a realistic dispersion of the water on the surface, even better I should be able to compute different liquids with different properties at the same time, like water and oil.

share|improve this question
1  
I would think any hydrodynamics code would work. –  Kyle Kanos Feb 9 at 11:17
add comment

2 Answers 2

up vote 5 down vote accepted

As I commented, I would think that any 3D hydrodynamics code would work. The basics of hydrodynamics can be summed up in the following five equations: \begin{eqnarray} \frac{\partial \rho}{\partial t}+\nabla\cdot\rho\mathbf{v}=0 \tag{1} \\ \frac{\partial \rho\mathbf{v}}{\partial t}+\nabla\cdot\left[\rho\mathbf{v}\otimes\mathbf{v}+P\mathbb I\right]=\rho\mathbf{g} \tag{2,3,4} \\ \frac{\partial E}{\partial t}+\nabla\cdot\left[\left(E+P\right)\mathbf{v}\right]=\rho\mathbf{g}\cdot\mathbf{v} \tag{5} \end{eqnarray} where $\rho$ is your mass density, $\mathbf{v}$ the velocity, $P=\left(\gamma-1\right)\left(E-\frac12\rho v^2\right)$ is the fluid pressure (assumes an ideal gas with adiabatic index $\gamma$), $\mathbb I$ the identity matrix (tensor),$E$ is the total energy (internal and kinetic), and $\mathbf{g}$ the gravitational acceleration. In order, these three describe mass conservation, momentum conservation and energy conservation.

Since computers are discrete objects, we define a volume $dx\cdot dy\cdot dz$ (usually $dx=dy=dz$ so the volume is $dx^3$, but it is not necessarily true) with a cell-centered position of $(x_i,\,y_j,\,z_k,\,t_n)$ where $i,j,k,n\in \mathbb Z$. Each variable is then defined by a volume-averaged value: $$\rho_{i,j,k}^n = \rho\left(x_i,\,y_j,\,z_k,\,t_n\right)$$

We can then numerically model the three conservation equations as (I'm going to use the mass conservation for the example) $$ \frac{\rho^{n+1}_{i,j,k}-\rho^n_{i,j,k}}{dt}=\frac{\pi_{x;\,i+1,j,k}^n-\pi_{x;\,i-1,j,k}^n}{2dx}+\frac{\pi_{y;\,i,j+1,k}^n-\pi_{y;\,i,j-1,k}^n}{2dy}+\frac{\pi_{z;\,i,j,k+1}^n-\pi_{z;\,i,j,k-1}^n}{2dz} $$ where $\pi=\rho\mathbf{v}$. The above uses a forward difference for the temporal derivative while the spatial derivatives use a central difference. There are some stability caveats with this equation (e.g. $dt\leq c_{s,max}dx/n_{dim}$ the time derivative is limited by the maximum wave speed divided by the number of dimensions times the cell length), but is fairly straight-forward to implement.

In three dimensions, you can either solve the equations directionally (i.e., $x,\,y,\,z$ solved independently but alternating order each time step) or you can combine them into what is called "corner transport" where the flux from say $\pi_{i-1,j-1,k}$ is accounted for in finding $\rho_{i,j,k}^{n+1}$. The latter choice is more difficult to code but provides a more accurate solution, while the former is pretty easy to implement.

For boundary conditions, you'd want a reflective boundary at the surface ($\mathbf{v}\cdot\hat{n}\to-\mathbf{v}\cdot\hat{n}$ where $\hat{n}$ is the normal direction to the surface) and probably extrapolated every where else ($\rho_{I,j,k}=\rho_{I-1,j,k}$ where $I$ is the maximum number of cells in the $x$ direction). These two boundaries and the above 5 equations should allow you to fully model the water droplet colliding with a surface.

You can also add viscous effects to Equations (2,3,4) by adding, to the RHS, the divergence of the viscosity tensor, $\tau$: $$ \tau=\rho\nu\left[\nabla\mathbf{v}+\left(\nabla\mathbf{v}\right)^T-\frac23\mathbb I\nabla\cdot\mathbf{v}\right] $$ with $\nu$ the kinematic viscosity. This complicates matters because you are introducing second-order derivatives ($\sim\nabla^2\mathbf v$) and the stability condition for these equations is $dt\leq \kappa dx^2/n_{dim}$ where $\kappa$ is the parabolic coefficient, in this case $\nu$. There are ways to get around this (e.g. using an implicit method that requires a matrix solver), but it definitely complicates matters.


With all of this, I conclude that you have two options:

  1. write your own 3D code from scratch
  2. search github for someone else's code that contains all the necessary physics and attribute the author when and where necessary

Given the difficulty in coding a multi-dimensional hydrodynamics code (personal experience here), it might be significantly easier for you to take Option 2, but my sole warning on that is this: the code you find and use is not a black box and should not be treated as such; you must understand what the code does and why before you can consider even running the code.

share|improve this answer
    
Nice answer! To add to your option 2: OpenFOAM and Gerris are two well-known and very capable open-source flow solvers that have a fairly large user base –  Michiel Feb 9 at 20:17
    
ok, thanks, so as I see it's pretty much infinitesimal calculus with derivatives and a mix of coefficients ( numerically speaking ). I have to document myself because this looks fine but fragmented and time consuming, but I think that the formulas are a really nice start. Thanks again –  user2485710 Feb 11 at 6:58
    
@user2485710 If you are interested in building your own model, then you might want to consider picking up Randy LeVeque's Finite Volume Methods for Hyperbolic Problems and Eleuterio Toro's Riemann Solvers and Numerical Methods for Fluid Dynamics. Both books are invaluable for fluid dynamics (albeit expensive ones). –  Kyle Kanos Feb 11 at 14:14
add comment

First a word of advise: don't ignore the air! Research in the past couple of years has shown that the air (in particular the air pressure) is crucial in determining whether the droplet makes a splash and if so, what the dynamics are. One of the landmark paper in this field is the one from Weitz Group in PRL in 2012.

Then on to your question of modelling the droplet falling a splashing. I think that a lagrangian approach for the liquid (i.e. fluid 'particles') would indeed give the most realistic simulation, but it will also be extremely computationally expensive. Therefore, you could consider finite volume methods such as Volume-of-Fluid, Level-Set and Front-Tracking. It is hard to give you any advice on which is the best because it depends a lot on experience and details of the implementation but you might find some good discussion on this website of the Institut Jean Le Rond d'Alembert.

share|improve this answer
    
my point is slightly different from theoretical research, I would like to know what are the equations, the matrices and vectors behind this kind of behaviours, so after studying the "math" behind I can try to simplify the computation. By the way I'm not aiming to simulate a "realistic" physics, my applications are artistic or something that mimics this behaviour, more than something that is a good replica of real world scenarios; I found several topics in hydrodynamics but none with a good explanation in math terms. –  user2485710 Feb 9 at 11:48
    
@user2485710 I'd like to point out that the phrase "good explanation" is completely subjective and offers no suggestion as to what might be a better suited text for your wants. –  Kyle Kanos Feb 9 at 19:00
1  
@user2485710 - just checking: have you ever heard of Computational Fluid Dynamics (CFD)? If not: make sure to read up on it. It is basically a lump term for all kinds of methods that solve the Navier-Stokes equations in a discretized fashion –  Michiel Feb 9 at 19:42
1  
@user2485710 - it is certainly not overkill to check out what CFD is. I don't know what kind of assignment you've got but writing a (Set of) solver(s) that can handle the Navier-Stokes equations (I hope you do know those?!) is not exactly a walk in the park. –  Michiel Feb 9 at 19:58
1  
I get the feeling that you are trying to take a shortcut here while you should be trying to understand some fundamentals of fluid dynamics first, before you start writing code about it –  Michiel Feb 9 at 20:00
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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