I'm playing around with building a very basic simulation of (air) pressure in a grid environment. The idea is that I have this 2d (or 3d) grid of cells. Each cell has a certain atmosphere. Between the cells there may be walls, doors, nothing.

To keep it simple let's say each cell only has pressure (between 0 and 5).

Walls have a certain level or airtightness, so a half open door between two cells would be 0.5 airtight. A full wall would be 1.0 airtight.

I am simulating this step by step, so let's say each step is 1 second.

So let's look at an example:

|0|0|0| # the numbers stand for the current pressure in this cell
|2=5=0| # the = stand for open doors (0.0 airtightness)
|__H__| # the H stands for a half open door (0.5 airtightness)
|0|2|0| # everything else are walls

To now calculate what happens in the first step (1 second) I probably need to decide how much flow 0.0 airtightness allow per step, so let's say 0.5 airtightness mean 0.5 flow per second.

So my main question is, how does a pressure difference behave/even itself out. I think to remember, that pressure only flows one way, but might be mixing that up with temperature.

Is it just as simple as taking the average between all pressures and then moving all of the cells closer to that (with a max delta based on the respective airtightness)? Or does a 0.5 airtightness influence the pressure difference somehow (like a tight gap "pretending" there is less pressure behind there)?

Or is it really just taking the mean of all pressures, and for each calculating how much delta it needs to get there and if it's more than the airtightness allows per step, do less?

I hope I could make this clear somehow and would really appreciate some clarity myself.


1 Answer 1


If all the rooms are the same size and the same temperature, then your numbers could represent the quantity of gas as well as the pressure.

Then you could do a simplified mass flow.

  • When there is a numerical difference between two rooms, gas will try to flow from the larger number to the smaller number
  • Constraints will limit how much can flow in one "step". Perhaps an open door can allow 5 units per turn, while a closed door could allow only 1 unit per turn.

Beware of rounding or making the steps too large. If you have an "8" surrounded by four rooms of "7", it would be wrong to move 1 unit into each room. That would drop the first room too much.

  • $\begingroup$ My question is more if a half closed door would mean that the flow behaves as if there was less difference between the cells. Or if it's the same "force" on the flow, but just less comes through. $\endgroup$ Mar 6, 2022 at 16:57
  • $\begingroup$ And I wonder how to best calculate the right amount of pressure to got to each cell. $\endgroup$ Mar 6, 2022 at 16:58
  • $\begingroup$ Usually it would be modeled as a resistance. A simple method is to assume same pressure but flow limits. A better model would be to assume it creates a back pressure that is proportional to flow. $\endgroup$
    – BowlOfRed
    Mar 6, 2022 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.