I'm having a hard time finding information on how to model/simulate this. I attached a couple files, both of which show an example tank & pump network. It's just nonsense that I made up for this post, but it shows what kind of system I'm trying to simulate.

(I just put it on the web instead: pdf link, vsd link)

I've been looking on the web to find information on how to do this, but I keep running into formulas that are way more complex than what I need to do. I just want to know what the pressure and flow is at any node in the system, with 80% or so accuracy. There's no need to consider fluid compression, and we can just use a constant for the resistance experienced through valves or narrowing pipes. We don't need to consider friction of fluid against piping. We can ignore heat. It's important to note, again, that I don't need complete accuracy, it's much more the behavior of the simulated system that is important.

I've tried this going in both directions, that is following a flow path down from the tanks/sources and propogating pressure changes through the system, and I've also tried it directly from the node in question, and considering that each node has a number of source nodes in terms of pressures and flows. Both of these simulated SW systems become highly erratic the further downstream from the pumps that you get, and the more on/off valves that I put into the system.

Even if you just told me where to look or what book to read, that would be a huge help. If there's example source code out there somewhere that does this, I will buy you a 60 oz beer of your choice.

Thanks in advance.

(post edit 4/12)

Thanks for the answers so far, I've ended up spending quite a bit of time looking around for a solution that already exists, because I was just convinced that many have run into this problem before, and knew that it was solvable in a general sense. Part of the reason I was so interested in a general solution is that I can rip through 12 more of these simulations that I have to do quickly and accurately if that's the case.

I've found another piece of software called EPAnet, which seems like a simpler solution than what was listed below, and I'm looking through their SDK at the moment and playing around with it. I'll keep you posted, the few that are interested ... this might not be a big deal to most, but to the few that it matters to it will be huge, so I'll write up what I find.

(edit 4/13)

I've spent the last two days building a solid wrapper around the EPAnet programmer's toolkit, and making a scratch program that does some of the things I want to do. (Incidentally, I've broken a new record for the # of times in a day I can make LabVIEW crash quickly and silently.)

It's really quite complex underneath, and I'm delighted by how much mathematical power I can stand on. I don't think they've fleshed out all the issues, so I've been working around some of them. But it's looking like it's 80% chance so far that it's going to work for what I want.

  • $\begingroup$ You keep running into horrendous difficulty because the full problem is one of the touchstone "hard" problems in physics (and for that matter in computational methods). Its not my field, but I know a few people who are in it. I don't think they ever use a system as simple as you describe. $\endgroup$ Commented Apr 10, 2011 at 20:51
  • $\begingroup$ 60 oz beer sounds like a fine bounty to me :) Just to make it clear (sorry if I am blind): is your situation stationary (i.e. with constant flows) or not (due to finite amount of water in those tanks)? $\endgroup$
    – Marek
    Commented Apr 10, 2011 at 20:52
  • $\begingroup$ It is not stationary, but if I could at least get a stationary model working correctly, I would be much better off than I am right now. I think I could add in special conditions to get a non-stationary system modeled fairly correctly. $\endgroup$ Commented Apr 10, 2011 at 21:08
  • 2
    $\begingroup$ @Ben Phillips Have you thought of transforming your problem to an electric circuit? Your simplified behavior seems amenable to an electrical analogy (bomb -> source, pipe -> resistor, tank -> capacitor, ...). $\endgroup$
    – mmc
    Commented Apr 13, 2011 at 2:22
  • $\begingroup$ Pardon the naive question, but could you explain the various symbols in the diagram? The tanks are obvious enough. I assume the two-triangles thing is a valve. What about the two little circles with lines through them? And the triangle of horizontal lines (looks like an electrical ground symbol)? Also, what is the action of a valve? Does it limit the rate of flow to a fixed value, or just present a fixed aperture, or ...? $\endgroup$
    – nibot
    Commented Apr 13, 2011 at 2:49

2 Answers 2


My advice is to look into the Lattice Boltzmann Method, which is robust and simple for athermal non-compressible flows. Try out this open source GPL3 software for example:


  • $\begingroup$ Thanks for the answer, looks like I'll be reading about this and using GCC a whole lot this week. $\endgroup$ Commented Apr 10, 2011 at 21:52
  • $\begingroup$ lbmethod.org/numerics:matlab_samples good place to start. $\endgroup$
    – Janne808
    Commented Apr 10, 2011 at 22:08
  • 1
    $\begingroup$ I don't think it is a good idea -- explicit CFD is a huge overshoot in this case. I unfortunately can't help with that, but surely there is some engineering software just for doing it. $\endgroup$
    – user68
    Commented Apr 14, 2011 at 7:25
  • $\begingroup$ @mbq: I'm thinking it is too, and it's already been done. I'm using a toolkit that gives far more info than what I need, yet I've been able to whittle it down. This is what I plan to write up in a couple days when I know for sure. The EPAnet toolkit attempts to model water quality, but in order to do that, they first have to do what I'm interested in, namely pressure at each node and flow through pipes. Beautiful! $\endgroup$ Commented Apr 14, 2011 at 7:45

Turns out, EPAnet can actually do what I want. It's a little hairy to try to plug into, as I don't think any real updates have come for 5 years or more, but there's several commercial products that base their underlying engine on EPAnet, even if they extend or tweak it a bit. This little fact gave me more confidence plowing forward that I wasn't jumping down a rabbit hole.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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