I am faced with the following problem:
A cylinder containing $n_{0} = 4$ moles of ideal monoatomic gas, at temperature $T_{0} = 280\ \mathrm{K}$ and pressure $p_{0} = 150\ \mathrm{kPa}$, is equipped with a safety valve that causes the gas to escape into the surrounding atmosphere when the internal pressure exceeds $p_{1} = 200\ \mathrm{kPa}$. The surrounding atmosphere is at temperature $T_{0}$ and pressure $p_{a} = 101\ \mathrm{kPa}$. The cylinder is heated to $T_{1} = 500 \ \mathrm{K}$; the leaked gas subsequently reaches thermal equilibrium with the surrounding environment. How many moles of gas come out of the cylinder?
I have solved this in the ‘obvious’ way: call $V$ the volume of the cylinder and $n_{1}$ the moles of gas that stay in the cylinder, we have $p_{0}V = n_{0}RT_{0}$ for the initial state and $p_{1}V = n_{1}RT_{1}$ for the final state. Therefore
$$ V = \frac{n_{0}RT_{0}}{p_{0}} $$
and
$$ n_{1} = \frac{p_{1}V}{RT_{1}} = n_{0} \frac{p_{1}}{p_{0}} \frac{T_{0}}{T_{1}} \approx 3$$
so that the answer is $1$.
The thing is, even though I know this solution is correct (at least that’s the answer the book provides), I don’t really understand why it should be correct.
Here is how I visualize the process and what troubles me:
We start heating the cylinder. Once the gas has reached temperature $\tilde{T}$ given by $p_{1}V = n_{0}R\tilde{T}$, i.e.
$$ \tilde{T} = \frac{p_{1}}{p_{0}} T_{0} \approx 373\ \mathrm{K}, $$
the valve opens and the gas starts leaking out. We keep heating the cylinder, gas is coming out of it, and I have no idea what’s going on with the pressure inside the cylinder (it is certainly not decreasing, but does it stay constant during the process? If so, how do we know that?). We have now reached temperature $T_{1}$. At this point I guess we stop heating the cylinder. Part of the gas keeps leaking out until the valve closes (it does, right?). So, I’m sure that now the pressure inside the cylinder must be $p_{1}$. But how can we be sure that the temperature is still $T_{1}$? Couldn’t it have decreased, since part of the gas continued to escape after we stopped heating the cylinder?
I really hope someone can enlighten me, and appreciate all your help.