Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 5

Author Topic: Hydrodynamics Education  (Read 53224 times)

Kanddak

  • Bay Watcher
    • View Profile
Hydrodynamics Education
« on: March 17, 2009, 10:57:09 pm »

I get the impression that a lot of people don't understand how fluids work, and when I read the wiki articles about water and pressure, it's not hard to see why. The water pressure article still lists buggy behaviors from older versions. The "current best pressure model" is overly complex, and can be replaced by one simple rule which I am about to present.
A couple times I posted in threads explaining fluid behavior to people, but it seems like if there were better documentation of this behavior in the first place, a lot of these questions might be avoided.
Therefore I am writing this post, with the intention of linking to it from water-questions threads, and the hope that some of this material makes its way to the wiki.

This is my current understanding of water:

For each frame, a loop runs through every tile with water in it, and determines, one at a time, what each tile of water is going to do, according to the following three rules:
1. If water is in open space above a tile which is not full of water, it falls into the space until the space is full or there is no water left to fall. This sometimes generates mist.
2. If water is in open space above a tile which is full of water to 7/7, it finds a path through tiles of 7/7 water to the nearest non-full space on a lower z-level, and then teleports there until the space is full or there is no water left to teleport. It only pathfinds north, east, south, west, up, and down; not diagonally. It does not move creatures or objects. This one rule is "pressure".
3. If water is unable to fall or move under pressure, because it is resting on a floor or because it is on top of more water but all connected spaces on lower z-levels are full, it will spread out to adjacent tiles (including diagonally) which have a lower level of water in them. This may move creatures and objects. (I don't know exact rules for where it will go if there are multiple tiles to spread into, though observation of partly-full reservoirs suggests there is some pattern. I also don't know whether objects' masses affects whether they will move.)

This is illustrated by the following flow flowchart:
Spoiler (click to show/hide)

Magma is exactly the same as water with the omission of rule 2. It can fall, or spread out, but not move under pressure. If magma is in a 1x1 chute over a mostly-full reservoir, it has to wait for a 6 in the reservoir to line up under it so that it can fall in.

Pumps are the last thing that need explanation.
When there is a fluid in the tile from which a pump pumps, the pump tries to pump the fluid as follows:
1. If there is space in the pump's output tile (the one next to the solid tile of the pump, in the line of the pump), it puts fluid there.
2. If the output tile is full, the pump attempts to find a path through 7/7 fluids to the nearest empty space on the same or a lower z-level, and puts fluid there. As with water-pressure pathing, pump output cannot path through diagonals.
3. If there is no available connected output space on the pump's z-level or lower, nothing happens.

This applies equally for water or magma, which explains all magma-pressure phenomena. Pumps do not "give magma pressure"; the pump moves the magma according to the rules of pumping, which can span z-levels, but after it has been placed by the pump, the magma moves only according to its own rules, which do not include pressure.

A couple relevant posts I've made:
http://www.bay12games.com/forum/index.php?topic=31425.msg439298#msg439298
http://www.bay12games.com/forum/index.php?topic=31312.msg438288#msg438288

See also Akhler's application of the inextinguishable-flaming-lignite-blocks-in-a-bin trick:
http://mkv25.net/dfma/movie-1124-itwinssohard

Things I still don't know:
Suppose a pump is merrily pumping magma, and someone pulls a lever that closes the door allowing magma under the pump intake, then opens a source of water. Will the pump path through the magma to find a place to put the water?
What's up with that one flood-the-world pump experiment? I tried unsuccessfully to recreate that once but it was a pretty casual attempt. Does that work in 40d, and if so, how exactly do you do it? I do have one power plant that drains into the same cave river it pumps out of (drain is downstream of intake), and that river flooded nicely.
How do waterwheels really work? I've heard "it has to be less than 7/7 water" but that's definitely an oversimplification, because I've designed power plants that were constantly at 7/7 water and ran fine. I was about to conclude that "when water at 4/7 or above spreads-out under a waterwheel, or a pump (and possibly water pressure) paths through a tile under a waterwheel, the waterwheel runs" when I built a power plant that should have worked if that were true, but only generated 500 power instead of 3000. I'll have to take the thing apart to figure out which five of the thirty wheels are running, and see if I can figure out why.
Logged
Hydrodynamics Education - read this before being confused about fluid behaviors

The wiki is notoriously inaccurate on subjects at the cutting edge, frequently reflecting passing memes, folklore, or the word on the street instead of true dwarven science.

Dorten

  • Bay Watcher
  • [CAFFEINE_DEPENDENT ]
    • View Profile
Re: Hydrodynamics Education
« Reply #1 on: March 17, 2009, 11:41:40 pm »

How do waterwheels really work? ... I was about to conclude that "when water at 4/7 or above spreads-out under a waterwheel, or a pump (and possibly water pressure) paths through a tile under a waterwheel, the waterwheel runs" when I built a power plant that should have worked if that were true, but only generated 500 power instead of 3000. I'll have to take the thing apart to figure out which five of the thirty wheels are running, and see if I can figure out why.

I think, that you are right in the part of "or a pump (and possibly water pressure) paths through a tile under a waterwheel...". And your plant doesn't work fully just because the paths of water pressure do not go unnder every tile, they just pick a single route inder 5 of the wheels and not the other.

IMHO
Logged
Cacodemon 2nd Leutenant
medals: 8/40
specials: 30/44
badges: 13:8:3:0:0

Jim Groovester

  • Bay Watcher
  • 1P
    • View Profile
Re: Hydrodynamics Education
« Reply #2 on: March 18, 2009, 05:18:35 am »

Excellent post. I recommend you immediately put this information on the wiki.

Regarding the flood the world thingy, I think that was the U-bend bug that generated infinite water which has since been fixed, I think.

As for water wheels, I have no clue what makes them decide to work. They seem pretty finicky.
Logged
I understood nothing, contributed nothing, but still got to win, so good game everybody else.

RAM

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #3 on: March 18, 2009, 10:48:56 am »

I think that water must be able to have a flow, in rivers and brooks at least, that allows them to turn wheels, tough if there are any other conditions I do not know of them.

http://www.mkv25.net/dfma/poi-12240-channel critters got through my fortifications and kept scaring my builders before they could make more wheels, so I closed of the inlet to the river and let my channel drain, it would have been at about 2-4 depth, and I sent in my military to clear out the beasties, and, well, there was blood, and I noticed that there was a bloody wall all the way from where I was fighting, up to the floodgates that were preventing the water from getting into my channel from the river, and yet no bloody walls in the direction of the lower section of the river. So the blood was somehow travelling through the water. It travelled an extremely long distance, probably close to 100 tiles. It went around corners. And it flowed only in one direction, more specifically, it flowed into a floodgate, when there was an open path to an area that 'seemed' to be draining the water in the opposite direction. I can't see how any water could have entered the system from anywhere other than the closed floodgate, so I can't see how rule 3 could cause the water to flow exclusively towards the floodgate. So somehow the water was propelling blood in a flat, pressureless environment, in the opposite direction to where it should have been draining, kind of sounds like a bug now that I think about it, I will go looking through my old saves to see if I can find any evidence...

Found some evidence, it isn't conclusive, but it does suggest that there is some other force at work...
http://www.mkv25.net/dfma/movie-1183-bloodisfasterthanwater
http://www.mkv25.net/dfma/poi-12241-bloodsmear
« Last Edit: March 18, 2009, 12:41:21 pm by RAM »
Logged
Vote (1) for the Urist scale!
I shall be eternally happy. I shall be able to construct elf hunting giant mecha. Which can pour magma.
Urist has been forced to use a friend as fertilizer lately.
Read the First Post!

Myroc

  • Bay Watcher
  • Lurking Skeleton
    • View Profile
Re: Hydrodynamics Education
« Reply #4 on: March 18, 2009, 12:56:42 pm »

Suppose a pump is merrily pumping magma, and someone pulls a lever that closes the door allowing magma under the pump intake, then opens a source of water. Will the pump path through the magma to find a place to put the water?
Not really, since when water meets magma, it creates an obsidian wall. There is no way water and magma can coexist next to each other without creating obsidian.
Logged
We all have problems. Some people just have more awesome problems than others.
Getting angry is fun. Getting angry over petty things even better.

Zaranthan

  • Bay Watcher
  • Plump Helmet Smelter
    • View Profile
Re: Hydrodynamics Education
« Reply #5 on: March 18, 2009, 01:28:42 pm »

That's the rub, they're not next to each other, the water is being teleported by the pump. If it calls separate code (which it likely does, given the different behaviors of water), it might not trip the obsidian check.
Logged
Quote from: Howard, Nerf This, by Scott D. Ferguson
Villains sleep with hookers, heroes sleep with destiny.

Myroc

  • Bay Watcher
  • Lurking Skeleton
    • View Profile
Re: Hydrodynamics Education
« Reply #6 on: March 18, 2009, 02:16:00 pm »

Oh. Gotta check that sometime.
Logged
We all have problems. Some people just have more awesome problems than others.
Getting angry is fun. Getting angry over petty things even better.

Qwernt

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #7 on: March 18, 2009, 06:04:13 pm »

Pump Question:

How much water can a screwpump pump? (no, not a woodchuk reference)  I was thinking something like: move a 7/7 pile of water from one side to the other, but it seems to do more than that.

Example: I hooked up a screw pump to create a water fall.  The single pump had no problem filling all 5 lanes and then going on to try and flood the world.
Logged

betamax

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #8 on: March 19, 2009, 08:31:08 am »

The water in your picture is cute.
Logged

freeze

  • Bay Watcher
  • nominal
    • View Profile
Re: Hydrodynamics Education
« Reply #9 on: March 20, 2009, 06:56:08 am »

Suppose a pump is merrily pumping magma, and someone pulls a lever that closes the door allowing magma under the pump intake, then opens a source of water. Will the pump path through the magma to find a place to put the water?
Not really, since when water meets magma, it creates an obsidian wall. There is no way water and magma can coexist next to each other without creating obsidian.

I've had this happen when jacking around with obsidian production via aquifer (no concrete proof handy, mind): creates obsidian in the pump output tile
Logged

winner

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #10 on: March 20, 2009, 12:34:26 pm »

one point that people might miss from your presentation the first time is that normal pressure doesn't make water go around a bend to the same level, the highest it can go is one level lower.
Logged
The great game of Warlocks!

KrunkSplein

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #11 on: March 20, 2009, 01:14:52 pm »

I generally don't mess with water, but I felt compelled to comment on how great that image is.
Logged

Musluk

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #12 on: March 20, 2009, 04:20:40 pm »

I vote to change the teleporting water's face into >:3.

It's the only thing appropriate.
Logged
Fe3g12 - the fourth iron ore.
Quote
The man who can smile when things go wrong has thought of someone he can blame it on.

Yanlin

  • Bay Watcher
  • Legendary comedian.
    • View Profile
Re: Hydrodynamics Education
« Reply #13 on: March 20, 2009, 04:55:08 pm »

I can't believe nobody did this.

That's one great "flow" chart there.
Logged
WE NEED A SLOGAN!

eerr

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #14 on: November 20, 2009, 05:33:49 pm »

I can't believe nobody did this.

That's one great "flow" chart there.
Everybody loves flow charts!
Logged
Pages: [1] 2 3 ... 5