Be careful on some points: there is no relation between speed of the fluid and the pressure of the fluid. What you actually have is a (linear) relation between the speed and the difference of pressure. It is really crucial to understand this.Dominik wrote: ↑Sun Sep 16, 2018 7:18 pmHi Yeast,TheYeast wrote: ↑Sat Sep 15, 2018 8:47 pmPhysicist here. I happened to bring up the wonky fluid behaviour about a year ago, but it didn’t seem to be a high priority at the time. Back then I came up with some alternative algorithms and ran some simulations in an Android app I hacked together for this purpose (can send APK+source if interested).
Based on what I came up with, the proposed model seems needlessly complicated to me. So I think my findings are worth sharing.
In my simulation I used the Euler equations (assumes zero viscosity) because they are computationally cheap and good enough for our purpose.
thanks you for your proposal, so far it seems to be the most reasonable, although I am still unsure about the electricity model which also is interesting.
I admit that my knowledge of physics is rather limited, I had to rely on my common sense. About the “speed kinda models the pressure”, I suppose I could have put more thought into it when writing it. When I think about it, pressure describes it best, it's just that it developed from speed originally and is still called that and I never took the time to rethink what it is.
The model actually is not that dissimilar. The pipe segment has volume (same to level), and the pressure, and connections store the speed - which is just the last step flow. The speed only plays some role in the update and does not control it fully.
From what you propose I really like the idea to push towards only using the last state. I will have to think about it, might steal it. Right now I am thinking about allowing going over the pipe volume limit which would allow this and simplify things a lot.
Your equations are a simplified version of what I currently have. Unfortunately I don't think it would work very well in this form.
The main issue I see is a very low reaction speed. For example - have a straight pipe from source to drain, source is pumping, drain is closed, pipe is full. The drain opens. What I think your model does is that in first tick, only the last segments moves 1/4 of its fluid into the drain (assuming dt=1, which is about what we have) and all the rest stays in place. In next step, one more segments moves a bit, 1/16. Etc. You need "length of pipe" iterations for the wave to reach the source and quite many more to get speed. And then when you get the momentum and you close the pipe, how does the flow stop?
Even so, your ideas are inspiring, I think I will use them, if you don't mind
Thank you, D.
Even more important to realize: a pipe might have a maximum flow per tick higher than its own volume (if the fluid is really fast).
Also, I still think the electricity model is the way to go. I wrote a post about it a few pages ago: viewtopic.php?f=38&t=62489&start=120#p378993