# How to calculate the mass of gas needed to fill a cylinder to a certain pressure?

I m tasked with a tricky situation. I need to calculate the exact amount a tank can take in gas. But I dont know the volume of the tank. I just need to make sure that the tank reaches the right pressure and thus the right density. This is how the system operates: A hose is connected to a tank. pressure and temperature is recorded. Then the tank is filled with 1 kg of gas (by mass flow meter). Then a second point is recorded. From there i would need to calculate how much more gas I need to fill, to reach the target pressure. Is this even possible? I am also able to calculate the compressibility factor z. The gas composition is known and i also know the pressure and temperature. I also know the molar mass of the gas.

Is there a way to accurately calculate the mass needed to fill the tank?

Thank you!

Edit: I forgot to mention, that the tank may not be empty at the beginning. Some data to test with:

$$P_0$$ - Initial pressure - 44,77 bar

$$P_1$$ - Pressure after $$m_1$$ was added - 48,87 bar

$$P_2$$ - Target pressure - 205,09 bar

$$m_1$$ - mass added - 1315.8 g

$$z_1$$ @ P1 - 0,8992

$$z_2$$ @ P2 - 0,7268

$$T$$ - 276,2 K

I converted the pressure to Pa and ran some calculations but didnt get anywhere. If someone could find the time to help me out. Thanks!

Edit2: I could also get a density reading from the mass flow meter, if that would help.

• Hint: Use the ideal gas equation with compressibility factor $z$. Write the equation in terms of density and molar mass. – Abhay Hegde Mar 11 '19 at 15:00
• You'll need a volume to even make use of the ideal gas equation. Estimate as accurately as possible the volume of the tank. – TechDroid Mar 11 '19 at 15:42
• Yes, your problem is solvable. Of course, the devil is in the details. You probably want to have a way to keep the tank cool as you are pumping gas into it, as this operation causes heat of compression due to the Joule-Thompson effect. – David White Mar 11 '19 at 15:46
• I wont be able to estimate the tank volume. The only indication is change in pressure. I also dont mind some margin of error, joule-thomson effect is negligible. – Rivo Sibrik Mar 11 '19 at 16:15
• @TechDroid You wont actually need the tank volume with the process he talks about here. The volume of the tank shouldn't change. Also, he is recording temperature and pressure, adding 1 KG of gas, then recording again, before determining the remaining gas required. This would allow him to also estimate the volume from the points he received. – JMac Mar 11 '19 at 16:46

From the ideal gas law, with the compressibility factor correction for non-ideality, you have the equation $$PV=znRT$$. This equation can be used for the initial case, where you pump 1 kg of gas into the tank and measure the pressure and temperature. This same equation can be used for the second case, where you pump more gas into the tank in order to achieve a final pressure that contains the desired mass of gas. Obviously, you don't know the volume of the tank, but there is a way to eliminate this variable from the problem.

Note that the ideal gas law works with moles, and you specified a mass. Thus, the ideal gas law must be modified to account for mass, such that moles are multiplied by molar mass (or molecular weight - MW).

$$PV=znRT$$

In terms of mass,

$$PV(MW)=z[n(MW)]RT$$

Since $$[n(MW)]$$ is the mass of the gas in the tank, substitute "m".

$$PV(MW)=zmRT$$

This equation applies for both the initial condition, and the final condition. In addition, if you divide the equation for the initial condition by the equation for the final condition, everything that remains constant drops out of the equation. Thus,

$$\begin{equation} \frac{P_1V_1(MW)=z_1m_1RT_1}{P_2V_2(MW)=z_2m_2RT_2} \end{equation}$$

Assuming that your tank is "rigid" (not expandable) such that its volume doesn't change, this equation reduces to

$$\begin{equation} \frac{P_1=z_1m_1T_1}{P_2=z_2m_2T_2} \end{equation}$$

This equation can be solved for $$m_2$$, which is the total mass to add to the tank (which includes the original 1 kg of gas). Thus,

$$\begin{equation} m_2= \frac{z_1P_2T_1}{z_2P_1T_2}m_1 \end{equation}$$

Obviously, if your ending temperature equals your starting temperature, the equation simplifies even further.

• Thank you very much for your input! I do have some further questions. I forgot to mention that the tank may not be completely empty. I have some actual data to calculate with and at the moment this formula didnt get me to the ballpark. Test data: P0 - initial pressure, Pa - 447729; P1 - pressure after m1 was added, Pa - 488721; m1, g - 1315,8; P2 - target pressure, Pa - 20509080; – Rivo Sibrik Mar 12 '19 at 6:39
• T, K - 276,2; z1 @ P1 - 0,8992; z2 @ P2 - 0,7268; – Rivo Sibrik Mar 12 '19 at 6:47
• @RivoSibrik, initially, the tank has $m_1$ kilograms of gas in it. Then, when you add 1 kg of gas, the tank has $m_2=m_1+1 kg$ of gas in it. Solve the equation for $m_1$ to get the initial gas content, and solve the equation again to get the total amount of gas to add. – David White Mar 12 '19 at 15:54
• So you mean like $m_1 + 1=\cfrac{z_1P_2T_1}{z_2P_1T_2}m_1$ That would cancel out $m_1$ ? – Rivo Sibrik Mar 12 '19 at 17:13
• No. I leave it to you to do the algebra required to separate $m_1$, but I assure you that it does not cancel out. – David White Mar 12 '19 at 17:14