# How can I calculate two gases approaching equilibrium over time?

There are two well insulated, rigid tanks (a and b) with known volumes. Each contains a gas with different temperatures, mass, density, specific heat, etc. Gas in tank 'a' has higher pressure than gas in tank 'b'. All of the initial conditions of both gasses are known. The tanks are connected by a small orifice with cross-sectional area 'A'. I would like an equation to roughly approximate the conditions of the gases after 't' time as they approach equilibrium. I am ignoring any effect of friction/turbulence/gravity. The following is the approach I took/what I have so far:

To calculate the mass flow rate at a given point in time, I found an equation which I believe is derived from Bernoulli's equation:

$$\dot{m} = A \rho_a \sqrt{2(P_a - P_b) \over \rho_a}$$

Where ṁ = Mass Flow Rate, A = Cross Sectional Area, P = Pressure, ρ = Density, subscripts 'a' and 'b' are for the gasses in tanks 'a' and 'b'.

This equation describes the relationship between the flow rate, the pressure differential, and density. The issue with this is that the actual flow rate isn't constant. While the gas flows from tank 'a' to tank 'b', the pressure differential decreases, so the flow rate decreases. So, the flow rate is dependent on the pressures/density and the pressures/density are dependent on the flow rate. If I temporarily assume a constant mass flow rate, and separate the gases into a, b, and z (with z being the gas which flows from 'a' to 'b' over time 't'), I can use the following equations to solve for the density of 'a' and pressures of 'a' and 'b':

(1) Solve for the final pressure in tank 'a' after 't' time by using adiabatic expansion:

$$P_{a,f} = \left({V_a \over V_a-{\dot{m}t\over\rho_a}}\right)^{\gamma_a}$$

Where V = Volume of Tank, and γ = Heat Capacity Ratio.

(2) Solve for the final density of gas in tank 'a' after 't' time by finding new mass of gas in tank 'a' and divide by volume of tank 'a':

$$\rho_{a,f} = {m_a - \dot{m} t\over V_a}$$

(3) Solve for the final pressure of gas in tank 'b' after 't' time:

(3a) Get the partial pressure of the gas 'z' which has flowed from tank 'a' to 'b' by using adiabatic expansion of 'z' from it's previous volume within tank 'a' to it's new volume of tank 'b':

$$P_z = {\left(V_b\div{\left(\dot{m}t\right)\over\rho_a}\right)}^{-\gamma_a}P_a$$

Where gas 'z' is identical to gas 'a', except that it is the portion of gas 'a' which has flowed to tank 'b'. For example, the mass of gas 'z' is m = ṁ * t, Cv of 'z' = Cv of 'a'.

(3b) Get the new temperature of gas 'z' since it was affected by the changes in volume/pressure:

$$T_z = \left({P_z \over P_a}\right)^{\left(\left(\gamma_a-1\right)\over\gamma_a\right)}$$

(3c) Combine the temperatures of gases 'z' and 'b':

$$T_{z,b,f} = {T_zCv_a\dot{m}t + T_bCv_bm_b \over Cv_a\dot{m}t+m_bCv_b}$$

Where Cv = specific heat in constant volume.

(3d) Adjust the partial pressures for 'b' and 'z' in response to the change in temperature:

$$P_{z,f} = {P_zT_{z,f} \over T_z}$$ $$P_{b,f} = {P_bT_{b,f} \over T_b}$$

Then add partial pressures to get total pressure of gas in tank 'b':

$$P_{b,z,f} = P_{b,f} + P_{z,f}$$

(4) All of step 3 can be simplified to:

$$P_{b,f} = {P_b \over T_b} \times {T_bCv_bm_b + Cv_a \dot{m}tT_a \left(\left(V_b \over V_a\right)^{-\gamma}\right)^{\gamma -1 \over \gamma}\over m_aCv_b+Cv_at\dot{m}}$$

Where $$P_{b,f}$$ is the total pressure of the gases in tank 'b' after time 't'.

Assuming that my math is correct and obeys thermodynamics (roughly), then I guess the next steps would be to plug in the final pressures/density back into the initial mass flow rate equation in some kind of iterative function and then go from there? Hopefully there is a relatively simple method that will result in a single equation where I can plug in all the initial parameters(Volume, pressure, Cv, etc.) and time and the result will be total mass that flows from a->b or something along those lines. Inevitably, I would like to avoid storing outputs and iteratively putting them into the inputs of other equations. Intuitively I am thinking my solution would be related to a logarithm?

P.S. I apologize for any clumsy and/or incorrect math, I am learning as I go..

• Are you familiar with the open-system (control volume) version of the first law of thermodynamics? Have you had a course in ordinary differential equations? Apr 19, 2021 at 11:26
• No and no, I am a noob with all this. I will check out both. Apr 19, 2021 at 12:51
• The 2 gases do not interact so you can calculate the pressures of each independently. ie Gas 1 flows from tank A into tank B until both partial pressures are equal. And the reverse for Gas 2. The total pressure in each tank is the sum of the partial pressures of gas 1 and gas 2. See Confused about ideal gas law with two types of gases Apr 28, 2021 at 14:59