Bay 12 Games Forum

Dwarf Fortress => DF Dwarf Mode Discussion => Topic started by: Kanddak on March 17, 2009, 10:57:09 pm

Title: Hydrodynamics Education
Post by: Kanddak 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 (http://mkv25.net/dfma/movie-1073-perpetualpowerfromalake). 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.
Title: Re: Hydrodynamics Education
Post by: Dorten 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
Title: Re: Hydrodynamics Education
Post by: Jim Groovester 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.
Title: Re: Hydrodynamics Education
Post by: RAM 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 (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/movie-1183-bloodisfasterthanwater)
http://www.mkv25.net/dfma/poi-12241-bloodsmear (http://www.mkv25.net/dfma/poi-12241-bloodsmear)
Title: Re: Hydrodynamics Education
Post by: Myroc 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.
Title: Re: Hydrodynamics Education
Post by: Zaranthan 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.
Title: Re: Hydrodynamics Education
Post by: Myroc on March 18, 2009, 02:16:00 pm
Oh. Gotta check that sometime.
Title: Re: Hydrodynamics Education
Post by: Qwernt 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.
Title: Re: Hydrodynamics Education
Post by: betamax on March 19, 2009, 08:31:08 am
The water in your picture is cute.
Title: Re: Hydrodynamics Education
Post by: freeze 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
Title: Re: Hydrodynamics Education
Post by: winner 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.
Title: Re: Hydrodynamics Education
Post by: KrunkSplein 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.
Title: Re: Hydrodynamics Education
Post by: Musluk 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.
Title: Re: Hydrodynamics Education
Post by: Yanlin on March 20, 2009, 04:55:08 pm
I can't believe nobody did this.

That's one great "flow" chart there.
Title: Re: Hydrodynamics Education
Post by: eerr 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!
Title: Re: Hydrodynamics Education
Post by: Sysice on November 20, 2009, 06:40:30 pm
Nobody loves necromancy, though.
Title: Re: Hydrodynamics Education
Post by: Limul Thak on November 20, 2009, 09:04:00 pm
Well, I'm certain some goblinoid necrophiliacs would disagree with you. >:(
Title: Re: Hydrodynamics Education
Post by: Innominate on November 20, 2009, 09:56:37 pm
To test the magma/water pump, I suggest this as a setup:
Code: [Select]
╔════════╕
║~~~~~~~~≡
║÷O÷╔════╛
║÷║÷║
║≈║~║
╚═╩═╝
Pump magma to fill the hallway (should perhaps be significantly longer, say 15 tiles). Once it is full, shut off the magma pump. Pull another lever to turn on the water pump and open the floodgate.

To be comprehensive two scenarios should be tested:
1. Does pumping water with the floodgate closed (i.e. no non-7/7 or wall spaces) do anything?
2. Does pumping water with the floodgate open and at least one 7/7 magma space in front of the water pump cause teleportation?

Personally I think that Toady's liquid code probably iterates separately for water and magma, treating the two as essentially different. There's a flag which defines whether a tile's liquid is magma or not, and I suspect it is trying to add one to the other that will cause obsidian to form, not a separate function.
Title: Re: Hydrodynamics Education
Post by: MrLobster on November 20, 2009, 10:34:16 pm
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".

Except for pump pressure...

Here's how I think about it: pressure-creating a fluid means simply trying to put the fluid in a certain space, with special rules. If there's room, it just goes there. If there's not room because of solid stuff like rock walls or floodgates, creation fails.

However, if a 7/7 stack of the fluid is sitting there, it does an orthogonal flood-fill through connected 7/7 fluid stacks looking for a place to create the fluid. This can go down and up z-levels, but NOT ABOVE the z-level we're originally trying to create fluid at. Notably, the flood fill does not go diagonally, and looks all the way through one z-level before going vertical. Anyway, if a space is found, the fluid is created there instantly (and possibly, quite far away from where we were originally trying to pressure-create). If not, the creation fails.

The previous paragraph is the mechanism for 'pressure' in the game; it starts with the attempt to pressure-create a fluid at a certain z-level, and is the act of looking around through the 7/7 spaces to find where to put it.

So when does pressure-creation occur?

1. Water tries to fall by pressure-creating water down 1 z-level. Think of water not as ever falling, but being destroyed on level X and pressure-created on level X-1.
2. Notably, magma falls simply and does NOT pressure-create down. Magma in pipes is also created in a weird way that's not pressure-creation.
3. Pumps pressure-create whatever they pump into the destination square (which can be water or magma.)
4. Water coming in from the edge of the map is being "pressure created" at that z-level. Note that streams and rivers have drainage off the end of them, so pressure-creation can find a spot way down near the end of the river to create water, and will not rise back up to its own level.

That's it, one mechanism that explains pressure and final z-levels. At least, so far as I understand :D
Title: Re: Hydrodynamics Education
Post by: Doomshifter on November 20, 2009, 10:51:11 pm
The water in your picture is cute.

I wholeheartedly agree. Adorablewater FTW.
Title: Re: Hydrodynamics Education
Post by: eerr on December 12, 2009, 12:41:51 am
Nobody loves necromancy, though.
This thread shouldn't _need_ necromancy!

It is a staple unto itself, requiring no new content to fascinate people who have already read the thread.
Title: Re: Hydrodynamics Education
Post by: RAM on December 12, 2009, 12:52:59 am
I just want to voice my support for necromancy in all its forms.
Title: Re: Hydrodynamics Education
Post by: Kinoko_Otoko on December 13, 2009, 06:41:46 pm
And to show my support for necromancy, since it occurred yesterday, I have a question: If I want to make a waterfall out of an existing brook without using a pump, can I channel it off the map? One person said you could dig up to the map edge and then carve a fortification...
Title: Re: Hydrodynamics Education
Post by: RAM on December 13, 2009, 07:25:57 pm
Oooooh, I have never tried to carve the edge of the world, should be eay enough to test though, just walk up to the edge, dig a ramp, and then carve. Still no guarantee the water will leave though.
Title: Re: Hydrodynamics Education
Post by: SenorOcho on December 13, 2009, 07:35:38 pm
I just want to voice my support for necromancy in all its forms.

As the Professor of Creative Necromancy, I must agree with this sentiment.
Title: Re: Hydrodynamics Education
Post by: Jim Groovester on December 13, 2009, 08:22:40 pm
And to show my support for necromancy, since it occurred yesterday, I have a question: If I want to make a waterfall out of an existing brook without using a pump, can I channel it off the map? One person said you could dig up to the map edge and then carve a fortification...

Digging out to the edge of the map and carving fortifications usually works as a drain, so yes. There are some cases where the fortifications will actually let water flow in, but that only seems to happen when there are aquifers.
Title: Re: Hydrodynamics Education
Post by: Vanguard Warden on December 13, 2009, 11:21:00 pm
Oddly enough, you can't seem to drain magma off the edge of the map as you can water.
Title: Re: Hydrodynamics Education
Post by: Kanddak on December 13, 2009, 11:32:26 pm
I'm going to take this opportunity to tack on a few miscellaneous pieces of information about water behavior that have been studied since I made this thread.

And to show my support for necromancy, since it occurred yesterday, I have a question: If I want to make a waterfall out of an existing brook without using a pump, can I channel it off the map? One person said you could dig up to the map edge and then carve a fortification...

Water can leave from a map edge using rule 1; that is, if it's next to a map edge, and happens to flow in that direction, it falls off the edge and disappears. Magma doesn't do this, and pressure-pathfinding can't just find a path off an edge and make water vanish. You can get water to the map edge at low elevations by carving fortifications.
If you are on an ocean site, any map edge tile below sea level is an ocean source and water will come in through it. I haven't experimented with lakes but I suspect they'd be likely to work the same way. I keep hearing about aquifers too, but if you have an aquifer you have water shooting out of so many places I'm going to maintain a healthy skepticism about what's coming from the map edge until I see a good demonstration. Map edge ocean sources appear to only create water in adjacent tiles, without pressure pathfinding.

Speaking of aquifers, here's basically how they work: Any unsmoothed aquifer wall tile will periodically create water in an orthogonally adjacent space or a space below it. Aquifers don't create water diagonally, and they don't appear to use any pressure pathfinding; only adjacent spaces. Water can pressure pathfind into aquifer walls to disappear; the mechanics of this aren't precisely understood, but essentially you need to drop the water into the aquifer, you can't pump it in from the side.

River sources work like pump outputs and will pressure-pathfind to find a place to put water. Normally there is empty space near the downstream map edge created by water falling off said edge. Sometimes river flow can exceed drainage (especially but not exclusively if you dam it), and the river will then (and only then) be able to push water through a U-bend to the original height of the river (which can be how people get their wells flooded); pressure pathfinding only goes up as an absolute last resort, and will take any down/horizontal path available, no matter its length, before going up. (studied here (http://www.bay12games.com/forum/index.php?topic=40844.0))

Magma vents: The magma flow tiles at the bottom of vents periodically pathfind in a vertical line to find a place to create 7/7 magma, no higher than the top level of the vent. Speaking of magma, it has been confirmed by experiment that the horizontal diffusion rates of water and magma are the same, and the idea that "magma moves very slowly compared to water" is a myth stemming from magma's lack of natural pressure.

Order of evaluation, FPS issues: (gleaned from my walrus trapping adventures (http://www.bay12games.com/forum/index.php?topic=45269.0))
The water movement algorithm appears to break the map up into 16x16 blocks, and then evaluate water movement in each of these blocks starting from the top left corner, moving down in a column first before going right to the next row. You can observe this by dropping a fire bin into an ocean. (see here (http://www.bay12games.com/forum/index.php?topic=31244), here (http://www.bay12games.com/forum/index.php?topic=42303.0))
It turns out that not every water tile is evaluated on every single frame. The algorithm goes through a specific pattern, which you can observe by draining an ocean into an aquifer; on the first frame, only certain tiles will disappear into the aquifer, and so on.
It appears that long-distance pressure pathfinding is a major drain on FPS, compared to static fluids or local diffusion. When a drained ocean refills, each level begins filling quickly; as the level fills up and the remaining empty spaces become farther from the map edge, I have observed FPS deteriorating, only to improve dramatically as soon as the level fills and the ocean sources begin to fill the next level starting from spaces near the edges.

Open areas of fluids research:
There is a bug where a closed hatch can break pressure pathing such that when the hatch is opened, the game doesn't recognize that there is now a clear path, and water doesn't rise up through the hole when it should.
There is another bug where water on ocean and lake sites can be vanished as if in an aquifer by dropping it into a hole.
The exact flow rates of different water sources have never been quantified. Stream & river sources seem to create water more quickly than brooks.
The behavior of underground waterfalls (river sources) has not been studied. http://www.bay12games.com/forum/index.php?topic=37861.0 (Thanks Vanguard Warden)
The rules governing when waterwheels turn are still shrouded in mystery and certain power plant designs seem to work some times and not others. I've had some luck (http://www.bay12games.com/forum/index.php?topic=44126.msg841659#msg841659) starting a power plant by throwing a bucket of water in from a couple levels up.
Title: Re: Hydrodynamics Education
Post by: Jim Groovester on December 13, 2009, 11:42:08 pm
Open areas of fluids research:
...
The behavior of underground waterfalls (river sources) has not been studied.
...

Here (http://www.bay12games.com/forum/index.php?topic=37861.0)'s a little test study done by Maw. To summarize it, the waterfall tile creates a 7/7 tile of water on top of it, and it fluid paths just like a pump. Further, it can be collapsed and its water creating potential will be preserved.
Title: Re: Hydrodynamics Education
Post by: Kinoko_Otoko on December 14, 2009, 02:02:28 am
Alright, so apparently trying to drain the water off-map is dangerous because pressure doesn't affect it, so it's kind of random. So here's anther idea. In order to keep the highest water tiles from 'backtracking' I could have a channel (one or more tiles wide; probably more) that drops a Z-level for every tile it travels toward the edge of the map.

Am I correct in thinking this will cause it to drain faster than letting it flow straight and level to the edge?

Or better yet, should I just make a big reservoir with one side pressed against the edge, with as many tiles pressing as possible?
Title: Re: Hydrodynamics Education
Post by: MrLobster on December 14, 2009, 07:14:34 am
Sometimes river flow can exceed drainage (especially but not exclusively if you dam it), and the river will then (and only then) be able to push water through a U-bend to the original height of the river
This is true for pumps as well, of course (the 'studied here' link suggests otherwise).
Title: Re: Hydrodynamics Education
Post by: wagawaga on December 14, 2009, 02:12:02 pm
Sometimes river flow can exceed drainage (especially but not exclusively if you dam it), and the river will then (and only then) be able to push water through a U-bend to the original height of the river
This only happens if the u-blend is neat the end of the river, if you put the u-blend near the beginning of the river, the u-blend will fill, the river will start to drain, near the end.
Title: Re: Hydrodynamics Education
Post by: Kanddak on December 14, 2009, 03:37:12 pm
This only happens if the u-blend is neat the end of the river, if you put the u-blend near the beginning of the river, the u-blend will fill, the river will start to drain, near the end.
You have no idea what you're talking about, please don't post silly crap that takes 5 minutes to debunk:
http://mkv25.net/dfma/movie-1877-u-bendatupstreamendofriver
Title: Re: Hydrodynamics Education
Post by: ebenezer on December 14, 2009, 05:43:27 pm
Now I know what killed my mayor. Rule 2.
Title: Re: Hydrodynamics Education
Post by: INSANEcyborg on December 14, 2009, 05:43:52 pm
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".

Some things I've noticed that should be confirmed/added about how it teleports.   One, it will not path up unless it can't path orthogonally or down.   Two, it will not favor down over orthogonal directions. Three, it will go to the closest spot, which is considered the one with the fewest orthogonal or down moves.   

The key part is if you use too much water at once, it can "jump" over gaps and pits before filling them, as well as loop around obstructions.   Horizontally, it will spread out in a diamond shape, while in 3d it'll look like an upside down pyramid  (it might seem distorted, the water doesn't move all at once so some of it has time to fall)

For example, I had built a 26x23x9 reservoir next to an emptied lake to speed up refilling.  I had planed on the water falling down into the lake, instead... well see for yourself

Before
Spoiler (click to show/hide)

After
Spoiler (click to show/hide)

While it happened relatively fast in game time, it wasn't instant.  And water never appeared outside above the opening, even with the water level inside the reservoir was still higher.
Title: Re: Hydrodynamics Education
Post by: Innominate on December 14, 2009, 07:42:01 pm
I assume that Toady would be using an A* implementation (technically, Dijkstra's algorithm) for his fluid pressure. My guess is that water will teleport to the first space accessible by a series of planar-orthogonal or downwards moves, where it considers each step the closest possible move which has not yet been considered. This explains the diagonal structure seen in INSANEcyborg's picture. If no move is possible by pressure and the water is at least 2 levels below the source, it will search all considered tiles on the initial z-level to see if it is possible to move upwards and then restart the algorithm on that level (though not resetting the list of "considered" tiles, so it won't backtrack).
Title: Re: Hydrodynamics Education
Post by: Moogie on December 15, 2009, 10:13:15 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.

(etc)


I spotted this thread yesterday and forgot to comment. I'd just like to say "thank you" for posting this, Kanddak! This is the first time I've understood the basics of what is going on with water pressure, thanks to your simple explanation. I'm no dullard, but I think people try way too hard to explain the complex systems behind this when people like me just need a simple, to-the-point answer to avoid killing ourselves in floods every time we try to work with liquids.

So again, thank you for putting it in terms that don't require hours of studying and mathematics just to make a basic pump system. :)
Title: Re: Hydrodynamics Education
Post by: spikesp on December 16, 2009, 12:19:03 am
thanks kand with your cute water i can now work on my prototype hydro dam  ;D
Title: Re: Hydrodynamics Education
Post by: Dr. Hieronymous Alloy on January 23, 2010, 09:22:08 am
OK, so, question: if I want to make a "pressure washer" that will push goblins or monsters out of my entranceway, is it possible and how do I do it? From what I'm reading here, simply emptying a huge reservoir of water into my entrance won't do it, because the water will just teleport past the gobbies.
Title: Re: Hydrodynamics Education
Post by: bluea on January 23, 2010, 10:50:57 am
You need moving water that is not 7/7. If I understand correctly:

Code: [Select]
7777X..._
7777X..._
7777X..._
7777X..._
7777X..._
7777X..._
7=water, X=floodgate/bridge, .=ground, _=channel

You might need more water beyond what I drew, but something like that can plausibly push things off of the causeway and into the channel. The water is all on the same level - so it won't be using the teleporting rules. But there is a lot of it - so it won't be at 1 or 2 when it hits the goblins.
Title: Re: Hydrodynamics Education
Post by: Dr. Hieronymous Alloy on January 23, 2010, 11:30:18 am
You need moving water that is not 7/7. If I understand correctly:

Code: [Select]
7777X..._
7777X..._
7777X..._
7777X..._
7777X..._
7777X..._
7=water, X=floodgate/bridge, .=ground, _=channel

You might need more water beyond what I drew, but something like that can plausibly push things off of the causeway and into the channel. The water is all on the same level - so it won't be using the teleporting rules. But there is a lot of it - so it won't be at 1 or 2 when it hits the goblins.

Ahh! sounds good.

What about something like this:

Code: [Select]
777777#.#
777777#.#
777777#.#
777777#.#
777777#.#
777777#.#
777777X.#
#########

7's are water, . is empty space, # is wall, X is bridge/floodgate tile. Would something like that push anything (goblin, titan, dragon, whatever) back out the entrance again?
Title: Re: Hydrodynamics Education
Post by: bluea on January 23, 2010, 11:52:13 am
Part of the issue is that 7s don't 'push'. And the arrangement you've presented would lead to depths like: 0,0,1,2,4,6,7,7,7,7 along the path a goblin is actually going to attempt. There's only one or two squares pushing, and the goblin is walking directly opposite to the direction of travel - they might well get past the 'pushing' portion.

With the 'push off causeway' approach, any individual goblin needs to experience pushing three times to be swept away. With the approach you have, they have to be pushed all the way back up the entranceway.

Pushing is tricky enough that I don't have high hopes for that arrangement.
Title: Re: Hydrodynamics Education
Post by: Dr. Hieronymous Alloy on January 23, 2010, 12:13:38 pm
Ok, sounds good. I'm just trying to think of different/unusual types of fortress defenses, since it looks like things are going to be rougher in the new version now that marksdwarves aren't a cure-all. A causeway like that should actually be fairly easy to set up, thanks.
Title: Re: Hydrodynamics Education
Post by: Djohaal on January 23, 2010, 10:58:50 pm
This thread deserves all the necroing for all eternity.
Title: Re: Hydrodynamics Education
Post by: RAM on January 24, 2010, 12:15:20 am
What about something like this?
Code: [Select]
77777#.#
77777#.#
7##X##.#
7#444#.#
7X444#.#
7#444X.#
X#X#####
Title: Re: Hydrodynamics Education
Post by: Grimlocke on January 24, 2010, 01:06:42 am
Open areas of fluids research:
...
The behavior of underground waterfalls (river sources) has not been studied.
...

Here (http://www.bay12games.com/forum/index.php?topic=37861.0)'s a little test study done by Maw. To summarize it, the waterfall tile creates a 7/7 tile of water on top of it, and it fluid paths just like a pump. Further, it can be collapsed and its water creating potential will be preserved.
Anyone got more info on this? Does he mean that collapsing the 'waterfall' tiles into a lower z-level will cause them to create water there, or will it create water in midair?

Also, what will happen if something crashed through the waterfill tiles? I assume it will just be destroyed, which would a total waste, but I like to be sure  ;)
Title: Re: Hydrodynamics Education
Post by: wagawaga on January 24, 2010, 03:08:25 pm
This only happens if the u-blend is neat the end of the river, if you put the u-blend near the beginning of the river, the u-blend will fill, the river will start to drain, near the end.
You have no idea what you're talking about, please don't post silly crap that takes 5 minutes to debunk:
http://mkv25.net/dfma/movie-1877-u-bendatupstreamendofriver

Excuse me for my "silly crap" post , but I clearly recall one of my fortresses getting completely flooded up to the level of the river from a breach on a lower level, and half the river was almost dry. There had to be some other breach on the river level then.
Title: Re: Hydrodynamics Education
Post by: Maw on January 25, 2010, 08:06:26 am
Open areas of fluids research:
...
The behavior of underground waterfalls (river sources) has not been studied.
...

Here (http://www.bay12games.com/forum/index.php?topic=37861.0)'s a little test study done by Maw. To summarize it, the waterfall tile creates a 7/7 tile of water on top of it, and it fluid paths just like a pump. Further, it can be collapsed and its water creating potential will be preserved.
Anyone got more info on this? Does he mean that collapsing the 'waterfall' tiles into a lower z-level will cause them to create water there, or will it create water in midair?

Also, what will happen if something crashed through the waterfill tiles? I assume it will just be destroyed, which would a total waste, but I like to be sure  ;)


As to your first question:

Collapsing the 'waterfall' tile to a lower z-level will cause them to create water at the new level location.  The waterfall creation is tied to the tile, not to the location.  Your question was the reason for my testing in the first place (I wanted the latter effect)  ;)

As to your second question, please find from a later post in the referred thread:

Quote
3) I lose the waterfall source completely (and have to redirect a brook instead)?

Note that you can destroy the waterfall tile by collapsing on it a natural wall (blocking the tile) or a natural floor (not blocking the tile).  Collapsing a constructed floor will not have an effect, as falling constructions deconstruct into their source materials.

Thus, 3) will only be the result if you collapse a natural wall or floor onto the waterfall tiles, destroying said tile.  It is immaterial if you just collapse with the waterfall tile supported by natural walls underneath, or cause collapses down several z-levels; either way the waterfall source tile is 'covered' and destroyed.

Assumption - given that natural floor destroys the source, I doubt collapsing a wall, then mining the wall would re-reveal the waterfall source tile.  You essentially replace the waterfall source tile with the upper floor's floor tile.

Note: Untested - does a falling construction (which deconstructs so no new floor tile), smashing into the waterfall tile with open space underneath cause the waterfall tile to collapse to a new zlevel, or does it destroy the waterfall tile.  The reference above is for a natural floor/wall onto the waterfall tile.  Simple test to collapse a construction on any floor tile (e.g. a coloured stone) onto some other colour stone.  Which do you end up with?
Title: Re: Hydrodynamics Education
Post by: wagawaga on January 25, 2010, 08:53:08 am
Could it be that all waterfall/brook source tiles are small aquifers and so follow their rules? IIRC a dug out aquifer won't produce water. Nor a smoothed one will. This needs testing.
Title: Re: Hydrodynamics Education
Post by: Samoorai on April 08, 2010, 10:34:07 am
Is this thread still accurate for 2010?
Title: Re: Hydrodynamics Education
Post by: ByDurinsBeard on April 08, 2010, 11:45:12 am
Going by the "don't fix it if it ain't broke" rule of programming, I'd assume fluid dynamics work as they used to.

I'm wondering about the apparent redundancy in the initial post though. Strictly, rule #2 for pumps doesn't seem to be necessary. They should only need to feed the exit tile with fluid, and the fluid dynamic code handles the spread. There's no need to run the same function twice over same fluid tiles.
Title: Re: Hydrodynamics Education
Post by: Shurhaian on April 08, 2010, 12:21:46 pm
I think the reason that rule became relevant was magma, which DOESN'T obey the usual pressure mechanics but can be pushed up to the pump's level through a u-trap.
Title: Re: Hydrodynamics Education
Post by: LemonFrosted on April 08, 2010, 03:04:06 pm
From what I've been seeing the only thing that's really changed in fluid behavior is that mass is now a bigger factor in if something will be pushed by flow, and flow also has some measure of relative force associated with it. I've figured that one of the big reasons why so many people are reporting that fishing is much less useful than before ("I have no fish anywhere!") is because the fish are all getting bundled up at the exit end of the river/stream by the force of the flow where they get hit against the walls over and over again until they die.
Title: Re: Hydrodynamics Education
Post by: Samoorai on April 08, 2010, 11:40:46 pm
I'm mostly wondering about this because I'm planning to build a large magma-fall system with a constant amount of magma and I'm wondering, if I have rooms built to a level where they will be totally or partially submerged in the magma reservoir with a channel in the bottom for forges/smelters, will the magma rise up through the channel?
Title: Re: Hydrodynamics Education
Post by: Samoorai on April 09, 2010, 12:00:15 pm
No-one has an answer? I kind of need to know this before I move on with the next stage of design for my fortress.
Title: Re: Hydrodynamics Education
Post by: LemonFrosted on April 09, 2010, 12:03:10 pm
I'm mostly wondering about this because I'm planning to build a large magma-fall system with a constant amount of magma and I'm wondering, if I have rooms built to a level where they will be totally or partially submerged in the magma reservoir with a channel in the bottom for forges/smelters, will the magma rise up through the channel?
No, it won't. I thought I didn't know the answer then I realized that my magma smelters are three levels below the surface of my magma and I've done nothing to neutralize the pressure to no ill consequences. Magma still only flows sideways and down.
Title: Re: Hydrodynamics Education
Post by: Terbert on April 09, 2010, 12:05:47 pm
Quote
Magma still only flows sideways and down.

Except for when it is pumped, in which case it will act exactly like pumped water.
Title: Re: Hydrodynamics Education
Post by: LemonFrosted on April 09, 2010, 12:10:38 pm
Quote
Magma still only flows sideways and down.

Except for when it is pumped, in which case it will act exactly like pumped water.
Which is sideways and down.
Title: Re: Hydrodynamics Education
Post by: gtmattz on April 09, 2010, 12:36:36 pm
Quote
Magma still only flows sideways and down.

Except for when it is pumped, in which case it will act exactly like pumped water.
Which is sideways and down.

And up through any u-bends to the level of the pump.
Title: Re: Hydrodynamics Education
Post by: Samoorai on April 09, 2010, 12:59:40 pm
Yeah, that's my question. I (will) have the magma pumped up to the top of a cavern, where it will flow out and fall down about 10 z levels and then pool at the bottom 3-4 z layers. In this instance, will the magma still act pressurised and flow up through a channel in a partially submerged room?
Title: Re: Hydrodynamics Education
Post by: Shurhaian on April 09, 2010, 03:14:48 pm
I've figured that one of the big reasons why so many people are reporting that fishing is much less useful than before ("I have no fish anywhere!") is because the fish are all getting bundled up at the exit end of the river/stream by the force of the flow where they get hit against the walls over and over again until they die.

Actually I have to disagree on this. Aside from the question of whether or not fish can be killed that way, being vermin, the real problem is in maps without flowing water; pools and the flooded portions of caverns are lacking in fish(except turtles and/or lungfish as appropriate). The map I played on that had a brook was loaded with enough fish that four fisherdwarves couldn't exhaust the supply.
Title: Re: Hydrodynamics Education
Post by: LemonFrosted on April 09, 2010, 03:22:48 pm
My brook had plenty of fish.

My river had thirty dead carp bundled up in the exit square.
Title: Re: Hydrodynamics Education
Post by: Syff on April 09, 2010, 03:33:12 pm
Yeah, that's my question. I (will) have the magma pumped up to the top of a cavern, where it will flow out and fall down about 10 z levels and then pool at the bottom 3-4 z layers. In this instance, will the magma still act pressurised and flow up through a channel in a partially submerged room?

The flowing magma will not act pressurized, as magma does not have pressure.

However, if the pump is active, it may choose to place the magma inside the partially submerged rooms if it can pathfind to them through 7/7 magma orthogonally connected to the pump output.
This means your 10z drop will have to back up before it can start flooding said rooms, but it can if left unattended.

From the OP:
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.
Title: Re: Hydrodynamics Education
Post by: Kuraudo on April 09, 2010, 08:00:00 pm
I find it a relief that pressure (and magma's lackthereof) still works as described in this excellent post.
Title: Re: Hydrodynamics Education
Post by: TheDancinZerg on May 08, 2010, 03:08:41 am
Thank you for this!
Title: Re: Hydrodynamics Education
Post by: Deathworks on May 08, 2010, 03:20:59 am
Hi!

First of all, I need to say that the "flowchart" in the first post is really awfully cute. I really like it.

Secondly, as far as I recall, people have reported that pressurized water has become much more vicious in 2010 - which would not mean that the basic rules have changed, but that more care needs to be applied.

Deathworks
Title: Re: Hydrodynamics Education
Post by: Kaos on May 13, 2011, 05:41:58 pm

I have a question/observation regarding
number 3: can't fall or under pressure, and
number 2: over 7/7 water - teleport


What if it's a combination of both? like it can't fall because is over 7/7 water AND is under pressure?


Scenario:
A river, over the river build a floor, on the floor build a pump, pumping in the same directions as the river flows


In my fortress (genned in 31.21 and updated to 31.25) I did just that in an attempt to drain a river to dam it, the river is 4 tiles wide flowing from north to south, on a section of the river I built a 2x3 floor (enough to fit 3 pumps powered by a water wheel on the 4th lane) on the floor I built a water pump, pumping from the north, at the right I had I water wheel providing power, after I built the first pump, I forgot about it and when I returned, the river tile where it was pumping from is keept empty or 1/7, the surrounding river tiles 2/7, the problem is the output I got a big circular 3/7 2/7 1/7 flood on the ground surrounding the river, (I was expecting that the output water would simply fall ontop of the 7/7 water down-stream and teleport to the map edge on the south)... instead a good portion (about 6x4 tiles) of the river on the south where it drains is 1/7 2/7 3/7.


So the water is spreading like number 2 says, but what about the downstream effect???


Title: Re: Hydrodynamics Education
Post by: Girlinhat on May 13, 2011, 05:51:31 pm
If water is over 7/7 water, then it is under pressure.  If it cannot path, such as it's a single 2/7 tile on top of a 7/7 layer in a sealed cistern, then it will spread as if it were on solid land, turning into 2x1/7 tiles.  Ironically, because of the positioning, the water will dance atop the water layer, moving around rapidly in some sort of pattern.

In your attempt to divert river flow, this won't really work because the water will leave the river, appear a bit downstream, and then spread out, backwashing towards the pump as it naturally spreads.  You're much better off diverting water flow into a pit, digging this pit to the map's edge, and then smoothing the stone and carving a fortification at the edge.  This allows water to drain freely, and you can place hatches to control when the river is diverted or flowing normally.  When you try to drain a river into itself, it usually doesn't work.  You CAN drain a river upriver of itself, by having the pump move water in the opposite direction as the water flows, and a lot of the water will re-absorb into the river, though you'll still have widespread flooding.
Title: Re: Hydrodynamics Education
Post by: Kaos on May 18, 2011, 03:49:06 pm
If water is over 7/7 water, then it is under pressure.  If it cannot path, such as it's a single 2/7 tile on top of a 7/7 layer in a sealed cistern, then it will spread as if it were on solid land, turning into 2x1/7 tiles.  Ironically, because of the positioning, the water will dance atop the water layer, moving around rapidly in some sort of pattern.

In your attempt to divert river flow, this won't really work because the water will leave the river, appear a bit downstream, and then spread out, backwashing towards the pump as it naturally spreads.  You're much better off diverting water flow into a pit, digging this pit to the map's edge, and then smoothing the stone and carving a fortification at the edge.  This allows water to drain freely, and you can place hatches to control when the river is diverted or flowing normally.  When you try to drain a river into itself, it usually doesn't work.  You CAN drain a river upriver of itself, by having the pump move water in the opposite direction as the water flows, and a lot of the water will re-absorb into the river, though you'll still have widespread flooding.
Let's get this straight:


1) what a pump does is grab 7/7 (or whatever amount) of water in its input tile (leaving it empty) and place it in its output tile, right?
so the first "cycle" of a pump will get the 7/7 "wall" of water and place it over its output tile (in my case open space "floor", with 7/7 water "wall" below, with a river "floor" tile below that)


2) Next up, the input tile (that's empty now) will start getting water back by spreading from the surrounding tiles (or maybe the river floor tile generates water itself?? nope, the river source floor tiles are the ones that do that!)


3) the 7/7 wall of water falls because is above open space floor tile??
4) when it finds the 7/7 wall of water below shouldn't it teleport? it can find a path through the river water up to the outflow of the river that's usually 4/7's, 5/7's and 6/7's??
5) In my observation it did spread (not sure if before or after teleporting, by your post I'm under the understanding that it did teleport but not all the way to the outflow downstream, instead to a few tiles downstream and then it spreads???  :o )
6) the other weird thing was the effect it caused downstream, the last 6 tiles of the river had 2/7's 3/7's and even 1/7's??? and I just used 1 pump!!! what drained the river outflow??



By throwing water on top of 7/7 of river, shouldn't it path to the edge where there are 6's and 5's or doesn't it path that far away? or maybe there's a priority for the scenarios? like it checks if it easier to spread or path a long way???
Title: Re: Hydrodynamics Education
Post by: slawr34 on January 21, 2012, 03:05:53 am
You, good ser, are long overdue for the Urist medal for *!!SCIENCE!!*