mathmanican

ONIversity: Hydrodynamics - How to Create a Single Liquid Waterfall

Recommended Posts

suxkar    99

Whoa, that's a lot of information! Thanks! 

Can fish live inside waterfalls? The last design can allow for very aesthetically pleasing configurations

Share this post


Link to post
Share on other sites
5 hours ago, suxkar said:

Whoa, that's a lot of information! Thanks! 

Can fish live inside waterfalls? The last design can allow for very aesthetically pleasing configurations

Ohh that would be so sweet if that was possible.. I'm going to have to try to do this in sandbox...

 

Share this post


Link to post
Share on other sites
mathmanican    2,318
6 hours ago, suxkar said:

Can fish live inside waterfalls?

Live? Yes. Swim? No. Lay eggs? Yes. 

They will sink to bottom and not move, whick is great for pathing. You can put a mesh tile where you want them to stay.

@Siromatik gave some great info on this.

 

Share this post


Link to post
Share on other sites
mathmanican    2,318
19 minutes ago, BLACKBERREST3 said:

Oxygen waterfall it is. That will look nice in my evil magma lair.

Haha.  Why stop there. Just include all the elements (a one tile gap between each) that have min horizontal flow of 0.01. :) Hydrogen, chlorine, methane, carbon, oxygen, polluted water, water, carbon dioxide, carbon (tricky melting point...), and supercoolant. Might as well alternate between super cold and hot. While we're at it, use an escher water fall to get the magma falling too. :) I may build this later, just for fun.  Beware of the "flash phase change" issue when dropping liquids on insulated insulation tiles, as it will ruin things quite quickly (make sure your cold liquid falls on airflow). 

 

  • Thanks 1

Share this post


Link to post
Share on other sites
mathmanican    2,318
1 hour ago, socooo said:

使用机械门也可以实现

For those who need it. Translation "It can also be achieved using mechanical doors".

Yep. Anything that gets the correct tiles filled with liquid. Ez beads. Doors. A tile that gets deconstructed. Tons of ways.

2 minutes ago, BLACKBERREST3 said:

I think I'm getting the hang of this. 

That configuration requires a lot more liquid to remain stable on load. You loose 7/16 liquid each tick so worst case scenario (repeated save loads at 6 tick intervals) means 40( (16/9)^6-1) = 1223 as your flow rate. It can be set at 671 and not fail till save load. Something around 700 or so will protect you unless you save/load several times in rapid succession.

@socooo, I love your stuff. I know one tile falls are doable.  I haven't seen anyone post the exact requirements. This post is an academics, more info than needed, study. Thanks for adding the mech door version.

Share this post


Link to post
Share on other sites
socooo    85
13 minutes ago, mathmanican said:

I added an "Alternate Configurations" section to the post. Thanks for the reminder @socooo. :) 

还是感谢你提供的精确数据,我只是一个凭着直觉的玩家

  • Thanks 1

Share this post


Link to post
Share on other sites
mathmanican    2,318

Translation: "Thank you for the precise data you provided, I am just an intuitive player." Let me know if my translations are ever off. :) 

My real goal is a perfect understanding of the liquid, gas, solid interactions. 

Share this post


Link to post
Share on other sites
BLACKBERREST3    232
1 hour ago, mathmanican said:

That configuration requires a lot more liquid to remain stable on load. You loose 7/16 liquid each tick so worst case scenario (repeated save loads at 6 tick intervals) means 40( (16/9)^6-1) = 1223 as your flow rate. It can be set at 671 and not fail till save load. Something around 700 or so will protect you unless you save/load several times in rapid succession.

You are probably right about the save/load. I got this config stable at 367 however.

Spoiler

image.png.69d326bfb022a81e422f7e3fb431c5c6.png

 

I am currently trying to figure out how to cascade this into a wide fall. I don't completely get it yet, but I will mess around with it for a little bit. I can cascade it to the left pretty well. it takes some tinkering to get it to the right.

Share this post


Link to post
Share on other sites
mathmanican    2,318

The min valve computations I gave are all wrong. It is not a geometric series. The mass change depends on the difference between two masses. Its a linear difference equation with boundary conditions. I'll post details later.

  • Confused 1

Share this post


Link to post
Share on other sites
mathmanican    2,318
7 hours ago, BLACKBERREST3 said:

I went down a rabbit hole and there is no turning back.

I hope we run into each other, but there are probably too many twists and turns. :) I'm currently on a math related rabbit hole tangent of this. 

9 hours ago, BLACKBERREST3 said:

You are probably right about the save/load. I got this config stable at 367 however.

My computation was completely wrong (too little sleep, and way too much simplifying).  As mentioned above, the computation involves a linear difference equation. First the values (for water), and then the details (just a tiny bit of matrix math, not too much). 

Summary:

  • To keep a single sided waterfall going till save/load, you need the valve set to 671/8=83.875 g/s, so 84g/s rounded up. I checked this value in game, and sure enough all computations match perfectly. Drop to 83g/s, and you'll see a hole appear every few seconds. Raise it up to 84 and after a bit the waterfall starts and continues. 
  • To keep a single sided waterfall going THROUGH save/load, you need the valve set to 14725/128 = 115.039 = 116 (rounded up). This computation assumes that the maximum number of ticks you can experience without getting more water is 6.  If this number is wrong, then the formula below will give the correct value. 
  • For a two sided waterfall, you need 324 (verified in game, but may die on save load) or 513 (survives save/load). 

Here is the math for a one sided waterfall (it was an extremely fun problem to solve).

Spoiler

These computations are for a waterfall off one side. 

  • Let m(t) be the mass of the central tile after t ticks.  
  • Let n(t) be the mass of the tile at the top of the waterfall after t ticks.
  • Since 1/4 of the difference in mass moves to waterfall top tile, we have n(t+1)= (1/4)(m(t)-n(t)).
  • The updated mass of the tile with the vent is m(t+1)=m(t)-n(t+1) = 3/4 m(t)+(1/4) n(t).
  • This gives the difference equation in matrix form as 
    (n,m)(t+1) = ( (-1/4,1/4),(1/4,3/4) ) .(n,m)(t).
    This means that after k ticks, we have
    (n,m)(k) = ( (-1/4,1/4),(1/4,3/4) )^k .(n,m)(0).
  • If we want to find the minimum flow without save/load, then we need both n(0)=10 and n(5)=10.  What is not known is the mass m(5) and m(0)=m(5)+x, where x is the valve setting. 
  • There are two unknown, namely m(5) and x.  The equation (n,m)(5) = ( (-1/4,1/4),(1/4,3/4) )^5 .(n,m)(0) gives the simple system
    (10,m(5)) = ( (-1/4,1/4),(1/4,3/4) )^5 .(10,m(5)+x). 
    The solution to this system is m(5) = 337/8 and x=671/8 = 83.875.

To find the value for 6 ticks (safe for save/load), just solve the same equation with k=6. The solution to (10,m(6)) = ( (-1/4,1/4),(1/4,3/4) )^6 .(10,m(6)+x) is m(6)=5435/128 and x=14725/128 = 115.039. The number 10 is the min horizontal flow rate of the given liquid.

The computations off the right side are identical, if the left side is blocked off, so liquid flow really is the same (once the waterfall starts). 

Now let's look at the math for a 2 sided waterfall. 

Spoiler

For a two sided waterfall, we have three variables that change each tick.  They are:

  • L(t) = left side mass after t ticks,
  • C(t) = center mass after t ticks,
  • R(t) = right side mass after t ticks.

Assuming the flow has not exceeded the viscosity (we're making waterfalls, so this is reasonable), the next tick of the game gives

  • L(t+1)=(1/4)(C(t)-L(t))=(-4/16)L(t) +(4/16)C(t)
  • C(t+1)=C(t)-L(t+1) - (C(t)-L(t+1)-R(t))/4 = (3/16)L(t)+(9/16)C(t)+(4/16)R(t)
  • R(t+1) =(C(t)-L(t+1))/4 = (1/16)L(t)+(3/16)C(t)-(4/16)R(t). 

Our matrix equation is (L,R,C)(t+1) = ( (-4/16,4/16,0),(3/16,9/16,4/6),(1/16,3/16,-4/16) ) .(L,R,C)(t), which means after k ticks we get

  • (L,C)(k) = [(1/16)( (-4,4,0),(3,9,4),(1,3,-4) ) ]^k .(L,C)(0)  (notice the 4:9:3 ratio in both the middle column and middle row)

We let R(0) =10 = R(5), then we let L(0)=L(5), and we let C(0)=C(5)+x where x is the desired flow rate. We then solve (L(0),C(5),10) = [(1/16)( (-4,4,16),(3,9,4),(1,3,-4) ) ]^5 .(L(0),C(5)+x,10) for x to get x=323.078  (L(0)=12.4992, C(0)=44.547). 

  • A two sided waterfall, if you don't care about save/load, requires a min valve setting of 324. 

For a save load, version, just change the 5 to a 6, and we get x=512.026. 

  • You can use a valve setting of 513 and the two sided fall will persist  between save load. 

 @Saturnus, I think you'll have fun with this computation, if you're following the hydrodynamics stuff. 

I did manually verify all the non save/load calculations in game, and got a perfect match. 

Edited by mathmanican
Typo
  • Thanks 1

Share this post


Link to post
Share on other sites
mathmanican    2,318
4 hours ago, BLACKBERREST3 said:

This is so wrong, but it feels so right.

Now you're speaking my language. :) This is just a beautiful application. 

Should I run the math computations to see exactly how far down we can make this work?  With another vent above your starting tile, you could get a second vent adding another 10kg/s, and the liquid arriving every 2 and 3 tick, instead of once every 5 ticks, could help. It only gets you so much though to add water in one place, as percentages drop the total content very quickly. This is the best you can get with 2 pumps.

maximumflow-2pumps.thumb.png.38c00510219cbea959bc57e8344c2cea.png

Of course, if you are happy using a vent at each spot, you get extra leverage for the same power (this doesn't use the full power of 2 pumps, rather I got tired adding more stuff). 

valvesandwaterfalls.thumb.png.63568ff390a38e1481c5bc08b1d2d46e.png

Now that we've got exact values, and know the way to make things, we have power. :) This was so much fun, it became my profile picture.

 

Edited by mathmanican
  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites
BLACKBERREST3    232

This is pretty amazing. similar to the complexities of real world physics, but simplified enough to not be too resource heavy. Whats funny is that it takes a lot of effort and ingenuity to reverse engineer these sorts of things and at the same time, the devs had to code this into the game. There is so much more to this game in terms of what it is, what it will be, and what it could be...cough diseases cough cough. Now that @mathmanican has given us the numbers, there are going to be a lot more waterfall builds. Can’t wait for the next installment of hydro/aerodynamics, maybe we’ll get another crazy mechanic out of it like a low pressure escher fall or even a fountain or dupe made geyser.

  • Like 1

Share this post


Link to post
Share on other sites
mathmanican    2,318
2 hours ago, BLACKBERREST3 said:

maybe we’ll get another crazy mechanic out of it like a low pressure escher fall or even a fountain or dupe made geyser.

They (thankfully) got rid of the dupe made liquid geysers, though the metal cannon still exists. Does this count as a fountain?

hp-flare-animatied.gif.9aefa9e5311bc10c0d5c55a8bc54891e.gif

For a sneak peak at the next installment, I'm analyzing high pressure beads first, before I move onto multi-layer flow.

Spoiler

hp-insulated-insulation-animated.thumb.gif.41f55649e46060b72207b59088f8228d.gif

As a side note, I believe that the hardness of the solid under the liquid has an impact on the formation. Fun time ahead. 

 

  • Haha 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now