# Calculating mass of gas in container

Given pressure is directly proportional to density, my understanding is that you can use the pressure of gas in a container to calculate the mass of the gas in the container. My reasoning being;

$$p=k\rho$$ ($$p$$ = pressure and $$\rho$$ = density)

Then;

$$\rho = \frac{m}{V}$$ ($$m$$ = mass and $$V$$ = Volume)

Therefore;

$$\frac{p}{k} = \frac{m}{V} \rightarrow m = \frac{pV}{k}$$.

This means that assuming $$k$$ is kept constant (i.e. constant temperature etc.) the pressure in the container should be directly proportional to the mass of the gas in the container, and therefore you can calculate the mass of gas in the container by using the pressure.

My first question is whether this is correct? And my second question is, assuming this is correct, would this still be accurate if the container is in use i.e. gas is being added/removed from the container, or would this only work when the container is sealed with no pipes in or out?

# Isolated System

An isolated system allows no mass or heat flow. The equation for an ideal gas is

$$p V = n R T$$

where $$p$$ is pressure, $$V$$ is volume, $$n$$ is number of moles, $$R$$ is the gas law constant, and $$T$$ is temperature. Use the molar mass $$M$$ and the relationship that density $$\rho = m/V = n/MV$$ to obtain your equation.

$$m = \frac{V}{MRT}\ p$$

Real gases must use a modification of the above. The pressure may not be a linear function of moles (mass) of gas. To the extent that you are operating in a region where the gas is ideal or where the equation of state keeps a linear relation between pressure and moles, you can continue with the ideal gas law expression.

# Non-isolated System

For a steady state process, mass flow in equals mass flow out. The mass inside the container is constant with time. Also, the temperature of the system is constant with time. Under this condition, you can use the equation for an isolated system with no reservations.

When the system has flow, the modification of the ideal gas law becomes

$$\frac{dm}{dt} = \frac{V}{MRT} \frac{dp}{dt} - \frac{pV}{MRT^2} \frac{dT}{dt} - \frac{pV}{M^2RT} \frac{dM}{dt}$$

When temperature and gas composition in the system are not changing with time, you can use pressure change with time as a measure of mass change with time.

Yes for a closed system you can calculate the mass in a container if you know the volume, pressure and temperature just as you did. In terms of solving this if it is not a closed system you can do it but you will need more information.

• Thanks for your answer. What extra information would you need? Just to avoid confusion, I would like to add that although gas would be added/removed, any new gas entering the container would still be of the same temperature and composition as the original gas in the container. Apr 10, 2019 at 20:50
• You will need to know the flow rate in and out of the cylinder but remember if the flow into the system does not equal the flow out then the pressure or the volume will have to change. Apr 11, 2019 at 0:34
• I pointed out gasi n and gas out as a comment but it seems to have been ddleted.. was going to suggest something else but will stay away... Apr 11, 2019 at 3:53