Respiration, Air Pumps, and Partial Pressure

Hey Folks! I think I got the partial pressure stuff from yesterday figured out.

It turns out the error I was seeing yesterday was due to the way I derived room pressure after exchanging the gases and temperatures. The underlying molar gas amounts were accurate, but the pressure resulting from them was being calculated incorrectly. After some fixing, I was finally seeing rooms equalize pressure after a few seconds of being exposed to each other.

Once that was done, I could add O2 to atmospheric pressure in room A, and N2 to atmospheric pressure in room B, and open the door to watch them mix. Depending on the sizes of rooms A and B, the final partial pressures would differ, but the overall pressure in both rooms would remain atmospheric pressure (since both rooms started at that overall pressure). A bigger room A would mean the resulting O2 partial pressure is higher, while a smaller room A would be lower.

This, as a result, meant I could have AIs interact with a room, and depending on the O2 partial pressure, they could "breathe" more or less O2. If the "breathe" interaction took place in a room with 50% normal O2 partial pressure, it would only be 50% effective at maintaining O2 levels in the body.

So that's sorted, in theory anyway. I have yet to test it, but I'm pretty optimistic it'll work.

What concerns me more, however, is life support systems. They do something similar to the AI above and also have to move it around between rooms. And air pumps process a certain volume of air per unit time, not a certain molar amount. If they gobble up a liter per second, for example, that liter is either full of gas (pressurized room) or empty (vacuum). Running a pump between empty rooms does nothing, so the interaction it uses to gobble air from source and pump to destination needs to move a variable amount of gas moles depending on pressure.

Furthermore, since I have mixed gases now (e.g. N2, O2, CO2, and maybe others in the future), the interaction needs to grab moles of each constituent gas in proportions relevant to their partial pressures. After a bit of rubber duck debugging, I thought I had sorted it out. I figured I could just make the interactions reply with a number of moles guaranteed to exist in a room based on current partial pressure.

However, this turns out to be trickier than I realized. The variable size of a room means I'd have to limit my air pumping to the number of moles expected in a 1x1 room, because anything more might violate the conservation of matter.

Of course, I still have access to actual molar amounts of each gas in a room. I could probably leverage those in some way to make sure I never get more than they'd allow.

It's doable. I don't have a firm grasp on it yet, but I think all the pieces are in place. Everything except a fresh brain, that is :) So I'm off to rest it for a couple.

See you Monday!