What is the differential equation for pressure in a container with an orifice? I've seen similar problems all over physics.SE and other sites. Most of the time it is about non-compressible fluids, or not about the differential equations. The physical system of interest is comprised as follows:
A rigid container with a gas at temperature $T_1$, pressure $p_1$ and with volume $V_0$. This rigid container has one hole to the surrounding environment. The temperature $T_r$ and pressure $p_r$ of the surrounding environment is constant.
Given that $p_1$ is greater than $p_r$ at $t=0$, what is the change of $p_1$ with $t$?
I assume the following:


*

*We have an ideal gas

*It is an isothermal process (Is this even a good assumption?)


Here is a sketch: 

My problem is, I can't even construct a differential equation for this system. I thought I could derive one by simply using the following two equations:
The ideal gas law,
$$ p_1V_0 = n R T_1, $$
and the volume flow rate through the orifice, which I assume is 
$$ \frac{dV}{dt} = K\Delta p = K ( p_r - p_1 ),$$
with $K$ as a constant which represents the geometry of the orifice.
Edit: I think I made an error here. The last equation is only applicable for incompressible fluids.
I tried to get a differential equation for $n$, the number of molecules in mole which are in the container, by substituting $V$ with $\frac{m}{\rho}$ and $m$ with $Mn$:
$$ \frac{d}{dt}V = \frac{d}{dt} \frac{M n}{\rho}$$
But $\rho$ is also depend on $t$ so, there is nothing won here.
Am I on the right track? I do think I have to incorporate the Bernoulli's equation for compressible fluids, but than again, I do not know how.
 A: One very simple way to solve this problem is by using an electrical circuit analogy where your rigid container with a compressed fluid would be represented by a charged capacitor (voltage equivalent to pressure) and the hole in the container as a resistor that's connected to the capacitor with the other end at a voltage equivalent to the pressure on the outside of the container. 
Since you're willing to assume ideal gas in an isothermal process as gas expands through the orifice, the relationship between container pressure and the volume of fluid molecules in the container is linear: $P_1 = V/C$. Here $V$ is not $V_o$ ,the container volume, but rather the volume of gas molecules at $p_r$ that were used to charge the pressure in the container to pressure $P_1$. The pneumatic equivalence of capacitance is 'compliance' and that can be determined using the container volume: $C = V_o/p_r$. 
With the two elements you have two equations, 
The pressure in the container
$$p_1(t)={1\over C} \int Q(t)dt$$
and the pressure drop across the orifice
$$p_1(t) - p_r = Q(t)^2R$$
where $Q$ is the volumetric flow through the orifice, which is equivalent to current in the electrical circuit.
and the volume that leaves the container at pressure $p_r$ is
$$V(t) = \int Q(t)dt$$
Solving the second of these equations for $Q$ and substituting into the first, then solving for $p_1$ gives you the differential equation you need.
