Just a little hydrodynamics research I carried out today.
For reference, here's my current theory of water:
http://www.bay12games.com/forum/index.php?topic=32453.0Experiment 1: Relative speeds of different methods of water movement
Abstract:
I wanted to provide a demonstration of different ways of moving water for the benefit of a forums poster who was questioning the best way to fill a cistern. (
http://www.bay12games.com/forum/index.php?topic=40774.0)
The poster originally questioned the merits of simply connecting a river to an aqueduct to a cistern, versus pumping water from the river into the aqueduct and cistern, versus connecting the aqueduct to the river and then pumping it from the aqueduct into the cistern at the cistern end.
I designed an experiment intended to demonstrate the relative speeds of pumped water, water under pressure, and water flowing horizontally. However, failure to account for the effects of the sourced water of a major river caused the various cisterns to fill in an order other than what was predicted, with pipes closer to the source of the river receiving water first.
As a result, I was lead to the hypothesis that rivers place new water onto the map using a shortest-path algorithm, similar but not identical to that used by screw pumps and water pressure effects.
Video:
http://mkv25.net/dfma/movie-1618-riverexperiment1cisternfillcomparisonDetails:
Hypothesis:
Water will be moved more quickly by pumping it out of its source or by causing it to fall into a below-grade channel than by allowing it to flow horizontally along one z-level.
Site:
The experiment required a large source of water. An ocean was initially chosen, but quickly abandoned as waves flooded the experimental channels. A lake was tried next, but had jagged banks which would make aligning the different channels difficult.
Finally, the experiment was carried out on the bank of a 46-tile-wide major river flowing from south to north in a temperate biome.
Design:
The experiment consisted of four pipes leading into cisterns. The cisterns were each 11x9 tiles, and each was separated from the river by a 23x1 pipe.
The pipes and cisterns were numbered 1 through 4, with Pipe 1 being the northmost and Pipe 4 being on the south.
Pipe 1 began with a screw pump adjoining the river, with the pipe and cistern one level above the river. The pump occupied two tiles of pipe space.
Pipe 2 had a stairwell on the third tile from the river, with the pipe and cistern one level below the river. The pipe and cistern were open at the top to permit observation, but a wall immediately behind the stairwell at the level of the river ensured that water did not flow into this observation space.
Pipe 3 and its cistern were dug at the level of the river.
Pipe 4 was also dug at the level of the river, but the cistern was one level above the river, with a screw pump occupying two tiles of pipe space at the cistern end of the pipe.
Pipes 2, 3, and 4 were each closed by a door on the second tile from the river, placed before the first tile next to the river was channeled out. The pump for pipe 2 was connected to a windmill through a disengaged gear. An activation lever was linked to the gear assembly and all three doors, to allow water into all four pipes simultaneously.
Predictions:
Cistern 1 was predicted to fill first, due to the screw pump drawing directly from the river.
Cistern 2 was predicted to fill second, due to water flowing only one way into the pipe and then moving under pressure to the end of the pipe.
Cisterns 3 and 4 were predicted to fill last, with local river water only flowing horizontally into the pipes. Cistern 4 was predicted to fill before Cistern 3 due to the screw pump ensuring water flowed only one way when it reached the end of the pipe.
Results:
When the activation lever was pulled, water was observed flowing into Pipe 4 at a speed consistent with pumped or pressurized water; that is, near-instantaneously. Cistern 4 filled first, much more quickly than had been predicted.
Cistern 1 filled second, at about the same speed as had been expected.
Cistern 3 filled third and Cistern 2 filled last, both at very high speeds. As intended, only the bottom level of Cistern 2 received any water.
During the filling of the cisterns, the north end of the river was observed at low levels of water.
Discussion:
I believe the unexpected results of this experiment were caused by my failure to properly account for the effects of the river.
I expected the river water to behave mainly under the rules for local horizontal flow, and for the pipes to be relatively unaffected by their relative positions along the river. This expectation had worked well enough in previous engineering projects involving brooks.
Instead, the pipes appeared to receive water at speed. Water being placed into the map seemed to be going directly into the pipes, starting with the nearest.
I was led by this experiment to form the hypothesis that the river source tiles employ pathfinding similar to water pressure and pumping in order to find an empty space to place new water onto the map. However, the rule for river water must differ from both pressure (lower level only) and pumps (same or lower level), because although it can sometimes find a path to the same level in order to place water at the far end of the river, it cannot push water through a U-bend to its original level, as shown by the fact that Cistern 2 in this experiment did not fill above its intended level.
Upon examining the recording of the experiment I noticed some other features consistent with the cisterns receiving water from a shortest-path algorithm from the south end of the river. Pipes 3 and 2 did receive some water very rapidly whenever they became the nearest empty space to the south (source) end of the river due to the level of water in Pipe and Cistern 4. During the filling of Cistern 4, Pipe 2 momentarily seemed to be filling faster than Pipe 3, due to the originally predicted effects of the different designs of the pipes. Once Cistern 4 filled, Cistern 3 became the shortest path, whereupon it caught up to and filled before Cistern 2.
Experiment 2: Pathfinding algorithm for river water
Abstract:
After the failure of Experiment 1 I wanted to test the behavior of river flow more precisely. I hypothesized that it would not be able to pathfind through diagonal openings.
I designed an experiment using three pairs of channels. One pair was a control where water could enter both channels orthogonally. In the other two pairs, one channel had a diagonal opening at its entrance.
Consistent with my hypothesis, water flowed more slowly through the diagonal openings.
Video:
http://mkv25.net/dfma/movie-1619-riverexperiment2pathfindingofriverwaterDetails:
Hypothesis:
River flow follows a shortest-path algorithm related to that used by pumps and water pressure, and therefore will not go through a diagonal opening.
Site:
The experiment was performed on the same site as Experiment 1, a 46-tile-wide major river flowing from south to north in a temperate biome.
Design:
Three pairs of channels were dug from the river. Every channel was closed by a door on the second tile away from the river, installed before opening the channel to river water, with the doors for each pair of channels linked to a common lever. Every pair of channels was separated by nine tiles.
The first pair of channels both opened directly to the river. The northern channel was 64 tiles long and the southern channel was 34 tiles long.
In the second pair of channels, the opening to the southern channel was offset by one tile to the south, so that water would have to flow diagonally from the first to the second tile of the channel. Both channels were 34 tiles long.
The third pair of channels was identical to the second, except that the north channel had a diagonal opening instead of the south one.
Predictions:
For the first pair of channels, it was predicted that the channels would both fill at high speed, with the southern channel always leading the northern channel by approximately nine tiles of water (the extra distance which water would have to path to reach the opening of the northern channel). Once the southern channel filled completely, it was predicted that the fill rate of the northern channel would approximately double until it, too, was full.
For the second pair of channels, it was predicted that the river pathfinding would skip the diagonal opening of the southern channel, and fill only the northern channel at high speed. Water would fill the southern channel very slowly, with water flowing through the diagonal only locally.
For the third pair of channels, it was predicted that the southern channel would fill quickly and the northern channel slowly.
It was predicted that neither channel with a diagonal opening would receive fast water even when the other channels were full.
Results:
One pair of pipes at a time was opened to the river. Each pair of pipes behaved exactly as predicted.
Discussion:
The results of the experiment were consistent with the hypothesis that rivers place new water onto the map by finding a path to the nearest available space, not including diagonal opening. This is consistent with the way that pumps find a place to put their output, and water finds a place to teleport under pressure.
Experiment 1B:
With the information gained from Experiment 2, Experiment 1 was repeated with a diagonal opening preventing river flow from flooding the pipes. This modification caused the experiment to behave as originally predicted.
Video:
http://mkv25.net/dfma/movie-1620-riverexperiment1bDetails:
Hypothesis:
Water will be moved more quickly by pumping it out of its source or by causing it to fall into a below-grade channel than by allowing it to flow horizontally along one z-level.
Site & Design:
This experiment was conducted on the same site and with the same apparatus as the above described Experiment 1, with the exception that all pipes were modified so that water had to flow through a diagonal opening to enter the pipe.
Predictions:
It was predicted that the four cisterns would fill in the order originally predicted for Experiment 1: 1, 2, 4, 3.
Results:
With this modification to the design, the experiment behaved as originally predicted. Cistern 1 was filled very quickly, because all water flowing through the diagonal was sucked up by the pump. Cistern 2 filled soon afterward, as water entering the pipe fell down the stairs and traveled to an available space. Cisterns 3 and 4 filled very slowly; at the end of the experiment neither was full, but Cistern 4 contained a slightly higher level of water.