# v0.34:Pressure

Dwarf Fortress features some pretty complex behavior in an attempt to simulate fluid mechanics. One aspect of this behavior is seen in the form of pressure. The basic idea here is quite simple - certain forms of fluids movement exert pressure, causing them to potentially move upwards into other areas.

## Summary

Contrary to what many people may believe, pressure is not a property of a body of liquid. Pressure is simply one of 3 rules by which liquids can be moved - the others are simple gravity (when the tile beneath contains less than 7/7 of liquid and it simply falls downward) and diffusion (when the liquid levels of two adjacent tiles are averaged, possibly pushing items around).

The following types of liquid movement follow the rules of pressure:

• Water falling downward into more water
• River/brook source tiles (whether the map edge or the "delta" where the river itself begins) generating water
• Lakes (surface or subterranean), oceans, and the magma sea refilling from the map edge do not exhibit pressure
• Screw pumps moving water or magma

When a liquid is moved (or created) with pressure, it attempts to locate the nearest tile on the same Z-level as its destination tile (for falling water, this is 1 Z-level beneath its original location) by moving north, south, east, west, down, or up. As it tries to locate an appropriate destination, the liquid will first only try to move sideways and downward - only when this fails will it attempt to move upward. Pressure will not propagate through diagonal gaps.

## A demonstration of pressure using U-Bends

A U-Bend is a channel that digs down, and curves back up. With pressure a fluid will be pushed up the other side of the u-bend. By understanding how pressure works in a u-bend you should be able to adapt this knowledge to use fluids in any configuration you desire without any unexpected surprises that could make life in your fortress more fun than anticipated. Water and magma both behave very differently with regards to pressure, so read carefully.

### Water in a U-Bend

The key to understanding how high a z-level water will reach is to understand which tile(s) pressure is being exerted on. Pressure will cause the water level to go as high as the tile upon which pressure is being exerted, but no higher.

The following three diagrams demonstrate different ways water might behave in a u-bend. In all three cases, the water source is on the left side of the diagram and water is filling the area to the right. In the first example (Diagram A), we have water taken directly from a (flat) river used to fill a u-bend. In this case, the river is free to flow off the edge of the map, so the only pressure comes from the water tile on the top of the u-bend's left side (highlighted in green) falling downward (into the tile highlighted in red), so the water on the right side stops one level below the river itself, because even though the source tile is at river level, the destination tile (in red), whose height the water will reach because of pressure, is one z-level below the source tile.

In the next example (Diagram B), a dam has been placed, preventing the river from flowing off the edge of the map. In this case, the pressure exerted by the river source (highlighted in red) allows the water to fill up the remaining level of the u-bend. Use caution when placing a dam on your river. Note that this situation also applies on a map where the river is running into the sea. Rivers running into the sea are obviously not free to flow off the edge of the map, so the sea itself actually "dams" them.

The final example (Diagram C), demonstrates how a screw pump exerts pressure - in this case, the water fills up to the same level as the pump's output tile (highlighted in red).

With these three simple examples, you should be ready to go build your enormous plumbing masterpiece, and be relatively safe from any unanticipated flooding. If you plan to work with magma as well however, you should read further.

Diagram A Diagram B Diagram C
Undammed River Dammed River Screw Pump
 ▓ ≈ ≈ ≈ ≈ ≈ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ≈ ▓ ≈ ≈ ≈ ▓ ▓ ≈ ▓ ≈ ≈ ≈ ▓ ▓ ≈ ≈ ≈ ≈ ≈ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓
 ▓ ≈ ≈ ≈ ≈ ≈ ▓ ≈ ≈ ≈ ▓ ▓ ▓ ▓ ▓ ▓ ≈ ▓ ≈ ≈ ≈ ▓ ▓ ≈ ▓ ≈ ≈ ≈ ▓ ▓ ≈ ≈ ≈ ≈ ≈ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓
 ▓ ÷ ÷ ≈ ▓ ≈ ≈ ≈ ▓ ▓ ≈ ≈ ≈ ≈ ▓ ▓ ≈ ▓ ≈ ≈ ≈ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ≈ ▓ ≈ ≈ ≈ ▓ ▓ ≈ ≈ ≈ ≈ ≈ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓

### Magma in a U-bend

Magma does not exert pressure when it falls downward. In our first magma example (Diagram A) we show how this works by creating a short u-bend and connecting it up to a magma pipe - it simply fills the lowest point and makes no further attempt to go back up.

In the second diagram (Diagram B) we see how with the addition of a single screw pump, the entire situation changes dramatically - when the screw pump moves magma to the right side, it does so using the rules of pressure and allows the area to fill up to the level of the pump. Accidentally flooding your fortress with magma is considerably more fun than a flood of water.

```  Diagram A       Diagram B
Magma Pipe      Screw Pump
Side View       Side View
▒≈≈≈▒             %%≈▒≈≈≈▒     %% = Pump
▒≈≈≈▒   ▒     ▒≈≈≈▒▒≈▒≈≈≈▒      ≈ = Magma
▒≈≈≈▒   ▒     ▒≈≈≈▒▒≈▒≈≈≈▒      ▒ = Solid Ground
▒≈≈≈≈≈≈≈▒     ▒≈≈≈▒▒≈≈≈≈≈▒
▒≈≈≈▒▒▒▒▒     ▒≈≈≈▒▒▒▒▒▒▒▒
```

### Lazy model

Pressure is a lazy model, but will always behave like above. For example, a system on z0 receives water from a cistern z3 in amounts of ~3/tick. This system consists of a tree of passages, one tile wide, and contains 'underpasses' on z-1. Water will flow into the system to a depth of 7 before coming up on the other side of a the first underpass, as is expected. However, if faced with two underpasses, it will choose the nearest one and fill all the system on the other side of that underpass to a depth of 7 before filling the system on the other side of the far underpass. Similarly, if faced with multiple exits from the system, the whole flow will flow out of one exit, the nearest lowest one.Verify

### Waterfalls

Waterfalls are of special concern. When drawing water from a waterfall it is important to understand that, since the water is falling on top of the river's surface, the pressure exerted when it falls down into the river will permit it to pass through U-bends that would normally not be filled when using a flat undammed river - if you tap into a river below a waterfall just as you would above it, you could very easily flood your fortress.

## Neutralizing Pressure

There are three methods for neutralizing fluid pressure: fortifications, diagonal connections and screw pumps. Knowing how to manipulate pressure as needed allows you to quickly move fluids wherever you wish in your fortress allowing you to build things a dwarf can be proud of.

### Fortifications

The simplest method for cancelling pressure is to build or carve fortifications. Water that flows through a fortification will push already-present water sideways, but never upward. Unlike diagonal connections, fortifications do not slow down flow (which can be good or bad depending on circumstances.)

### Diagonal Flow

Liquids moving via pressure can only move to orthogonally adjacent tiles. When faced with a diagonal gap, pressure will fail to move the liquid, forcing the liquid to instead spread out. By forcing fluids through a diagonal connection you can prevent pressure from propagating past a certain point.

This does not work on a vertical basis - water only travels straight up and down to different Z-levels, never diagonally.

If you wish to maintain the rate of flow after de-pressurizing, it's recommended that you have more diagonals than water tiles - that is, if the source is 3-tiles wide, you may wish 4 or more diagonal passages.

```Top View
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
> > >      ▒   >  >  >
4Z Deep    ▒    1Z Deep
> > >    ▒     >  >  >
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
```
```Side View
▒≈≈≈▒
▒≈≈≈▒
▒≈≈≈▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒
▒≈≈≈≈≈≈≈≈RRR≈≈≈≈≈≈≈▒     RRR = Regulator design as seen in top view
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
```

### Pumps

Since water pressure does not propagate through pumps, it is possible to fill a pool from a "pressurized" source using a screw pump without it overflowing. Of course, there is a downside - you still have to run the pumps and due to the source water's pressure, the pump must be powered instead of run by a dwarf, as the tile the dwarf needs to stand on is filled by water. Furthermore, the pump will likely need to be powered from above or below (as water would simply flow around a gear or axle placed next to the pump), though creative setups are still possible by using additional screw pumps to transmit power.

Your vertical axles or gear assemblies need to be placed above the solid tile of the pump, and there must not be a channel over the walkable pump tile. (Water can only flow straight upward, not up and to the side at the same time.) Multiple adjacent pumps will also transfer power between themselves automatically.

```Side view

Power  Water       Key
↓    ↓↓↓↓↓       ▒ = Normal wall
▒▒▒▒▒▒║▒▒▒▒≈≈≈≈≈       ▒ = Wall that pressurised water would flow into if it were to be dug out
▒▒▒▒▒▒║▒▒▒▒▒≈≈≈≈       ≈ = Regular water
_ ___▒║▒▒▒▒▒▒▒≈≈       ≈ = Pressurised water
▒≈≈≈≈≈%%≈≈≈≈≈≈≈≈      %% = Pump
▒▒▒▒▒▒▒▒≈▒▒▒▒▒▒▒       ║ = Axle
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒       _ = Floor
```

Do note that the screw pump will still exert pressure when filling the pool, but said pressure will be independent of the source and can be subsequently blocked by diagonal gaps.

## Hatches

Hatches can be placed over channels, stairs, ramps, etc. to prevent water from moving vertically but will still allow the tile to be used, even as a water source (and possibly still for fishing too).