How to calculate the mass of gas in a tank?

  • #1
Leopold89
59
5
Dear community,

I have a question comparable to https://www.physicsforums.com/threads/calculating-the-mass-of-air-in-a-pressurised-air-tank.1053707/, but with some additional peculiarities.

My setup is:
1) I got a time series of gas pressure and temperature, with a time step of 2 minutes
2) I cannot measure the gas temperature, only the surrounding/room temperature
3) My gas can be either monoatomic or not and it has negligible contamination
4) The pressure is so large, that the gas turns into liquid
5) At arbitrary times during day time someone releases some gas from the tank, but not at night

Question: What is the remaining gas mass or particle number respectively?

My ansatz: First I can see that change in temperature will affect the pressure after some time delay, so I assume that should the tank contain a gas not at room temperature, the gas gets to room temperature after some time as well. This lag I can get from analysing the two time series.

I would have assumed that I am moving along the p-T-curve when releasing gas, since some of the liquid evaporates until a new equilibrium between gas/vapour and liquid is reached, but the data shows I am well above this curve.
From this point onward I believe I am confusing myself. Now I know cannot use the ideal gas equation, because by releasing gas I am also converting liquid to gas/vapour, which should cool down the gas temperature below room temperature, followed by a heating phase, where the gas gets back to room temperature. As far as I understand I now need to somehow get the vapour volume, liquid volume, Gibbs energy and entropy to arrive at the remaining gas mass (or number of particles), right? I don't know how to get these.
 
Science news on Phys.org
  • #2
Are you taking into account the thermal inertia of the tank? Are you including the heat transfer rate between the tank contents and the air outside? What is the measured pressure and temperature vs time?
 
  • #3
Are you taking into account the thermal inertia of the tank? Are you including the heat transfer rate between the tank contents and the air outside?
Other then by the time delay, no. The tank's heat transfer rate should be around 45 W/mK.

I have also included the time series. The pressure (blue, left axis) is in Pa and the temperature (red, right axis) in Kelvin. On x is the time series index, so multiplied by two minutes is the time.
 

Attachments

  • gas_plot.png
    gas_plot.png
    7.9 KB · Views: 20
Last edited:
  • #4
I think you need to get your feet wet with a simpler versions of the model first, before going to the full model. Would you be able to formulate a model where the tank is adiabatic, and where the thermal inertia of the tank itself is negligible?
 
  • #5
Under these conditions I would use ##p^{1-\gamma}T^{\gamma}=\mathrm{const}##, such that I would get ##\tau_2:=\left( \frac{p_1}{p_2}\right)^{\frac{1}{\gamma} - 1} T_1##. Now that I got the temperature, I can get the particle number with ##N=\frac{p_2V}{k_B\tau_2}##. Now that I got the temperature difference ##T_2-\tau_2## between the measured temperature ##T_2## and the gas temperature ##\tau_2##, I can get the new pressure, after thermodynamic equilibrium is established with ##p_\mathrm{eq}=\frac{Nk_BT_2}{V}##.
I used the fixed volume ##V## of the gas tank and I know the ##\gamma## from the type of gas in the container.
 
  • #6
Leopold89 said:
Under these conditions I would use ##p^{1-\gamma}T^{\gamma}=\mathrm{const}##, such that I would get ##\tau_2:=\left( \frac{p_1}{p_2}\right)^{\frac{1}{\gamma} - 1} T_1##. Now that I got the temperature, I can get the particle number with ##N=\frac{p_2V}{k_B\tau_2}##. Now that I got the temperature difference ##T_2-\tau_2## between the measured temperature ##T_2## and the gas temperature ##\tau_2##, I can get the new pressure, after thermodynamic equilibrium is established with ##p_\mathrm{eq}=\frac{Nk_BT_2}{V}##.
I used the fixed volume ##V## of the gas tank and I know the ##\gamma## from the type of gas in the container.
I thought you said you have two phases. What do you do in that case?
 
  • #7
Chestermiller said:
I thought you said you have two phases. What do you do in that case?
Ask the forum, because all I get is the Gibbs energy ##G=U + pV - TS##, which I can rewrite as ##\Delta U + p\Delta V - T\Delta S =0##, where ##U## is the inner energy and ##S## the entropy. Theoretically I can rewrite the liquid volume as ##V-V_\mathrm{vapour}## with ##V_\mathrm{vapour}## as the real root of ##pV_\mathrm{vapour}^3-V_\mathrm{vapour}^2n_\mathrm{vapour}(bp+RT)+an^2V_\mathrm{vapour}-n_\mathrm{vapour}b=0##, where I used that pressure and temperature of vapour and liquid are equal. Then ##\Delta V=2V_\mathrm{vapour}-V## and I just replace one variable I don't know, ##V_\mathrm{liquid}##, with another that I don't know, ##n_\mathrm{vapour}##. I am not sure how to use the heat energy for condensation ##Q=\frac{\mathrm{d}p}{\mathrm{d}T}(V_\mathrm{vapour}-V_\mathrm{liquid})T##, because I am not moving along the p-T-curve, right?
 
  • Haha
Likes Juanda
  • #8
For the adiabatic, reversible, 2 phase case, the open system version of the 1st law of thermodynamics tells us that $$dU=h_Vdm\tag{1}$$ where U is the internal energy of the tank contents, m is the mass of the tank contents ( dm is negative), and ##h_V## is the enthalpy per unit mass of the vapor. Eqn. 1 assumes that mass leaves the tank as a vapor through a valve at the top of the tank.

U is given by: $$U=m[(1-x)u_L+xu_V]\tag{2}$$where x is the mass fraction vapor in the tank, ##u_L## is the internal energy per unit mass of the liquid in the tank and ##u_V## is the internal energy per unit mass of the vapor in the tank.

The constant volume of the tank V is related to the specific volumes of liquid and vapor in the tank by: $$m[(1-x)v_L+xv_V]=V\tag{3}$$Solving Eqn. 3 for x gives:$$x=\frac{\frac{V}{m}-v_L}{v_V-v_L}\tag{4}$$OK so far?
 
  • #9
I think so. If I understand correctly, I can then go and calculate ##\frac{\partial U}{\partial m}=(1-x)u_L+xu_V -m\frac{\partial x}{\partial m}u_L +\frac{\partial x}{\partial m}u_Vm## and get from this ##u_V-u_L=\Delta u = \frac{(v_V-v_L)(u_L-h_V)}{v_L}##, where I used ##\frac{\mathrm{d}U}{\mathrm{d}m}=h_V## and ##\Delta u## related to ##\Delta U## in the above equation. But then I see no way forward, because the only equation linking enthalpy and entropy is the Gibbs energy, that I already used.
 
  • #10
Leopold89 said:
I think so. If I understand correctly, I can then go and calculate ##\frac{\partial U}{\partial m}=(1-x)u_L+xu_V -m\frac{\partial x}{\partial m}u_L +\frac{\partial x}{\partial m}u_Vm## and get from this ##u_V-u_L=\Delta u = \frac{(v_V-v_L)(u_L-h_V)}{v_L}##, where I used ##\frac{\mathrm{d}U}{\mathrm{d}m}=h_V## and ##\Delta u## related to ##\Delta U## in the above equation. But then I see no way forward, because the only equation linking enthalpy and entropy is the Gibbs energy, that I already used.
The next step is to substitute Eqn. 4 into Eqn.2. What do you get?

The saturated liquid and saturated vapor properties ##u_L##, ##u_V##, ##h_V##, ##v_V##, and v_L are known functions of temperature T. So we will first be deriving an equation for dT/dm, and then integrating this equation to obtain T as a function of the decreasing m.
 
  • #11
I don't know if I am doing this right: starting with ##h_V=u_V+pv_V##, ##u_V=\frac{c_VR}{Mk_B}T## and ##v_V=\frac{RT}{Mp_V} ## I rewrite this as ##\frac{\mathrm{d}T}{T}=\frac{M}{R}\mathrm{d}h_V-(\frac{c_V}{k_B}+\frac{1}{m})\mathrm{d}m+\frac{\mathrm{d}V}{V}+\frac{\mathrm{d}p}{p}##. Now I have to guess and say that I can use the specific heat capacity under constant pressure ##\frac{\mathrm{d}H}{\mathrm{d}T}=c_p##, but because of ##\frac{\mathrm{d}H}{\mathrm{d}T}=\frac{\mathrm{d}(mh_V)}{\mathrm{d}T}=\frac{h_V\mathrm{d}m+m\mathrm{d}h_V}{\mathrm{d}T}## I cannot seperate the temperature from the ##\mathrm{d}m##-term for the integration.

P.S.: Maybe the solution is ##\mathrm{d}T=-\frac{h_v}{\frac{R}{M}-\frac{c_p}{m}}\mathrm{d}m \Rightarrow T=-h_v\frac{c_p \mathrm{ln}(c_p-\frac{R}{M}m) +\frac{R}{M}m}{\frac{R^2}{M^2}}##, where ##M## is the molar mass and ##R## the molar gas constant.
 
Last edited:
  • #12
I get $$U=\frac{u_V-u_L}{v_V-v_L}V+\frac{v_Vu_L-v_Lu_V}{v_V-v_L}m$$
 
  • #13
Yes, that was
Chestermiller said:
substitute Eqn. 4 into Eqn.2

But from that point onward I don't understand. You said that ##u_L## and ##v_L## are known, but I don't know the formulas for liquids.
 
  • #14
Leopold89 said:
Yes, that was


But from that point onward I don't understand. You said that ##u_L## and ##v_L## are known, but I don't know the formulas for liquids.
If it is water, then. you have the Steam Tables, which give all there functions. For other pure substances like refrigerants and many others, there are tables for these too. Are you familiar with the Steam Tables. They are in most Thermo books.

The vapor does not have to be ideal gas.
 
  • #15
From post #12, the internal energy has the form $$U=F_1(T)V+F_2(T)m$$ where F1 and F2 are known functions of T. So, from the first law, $$F'_1V+F'_2m+F_2dm=h_vdm$$or $$\frac{dm}{dT}=F_3V+F_4m\tag{5}$$where $$F_3(T)=\frac{F'_1}{h_v-F_2}$$ and $$F_4(T)=\frac{F'_2}{h_v-F_2}$$All that needs to be done is to integrate Eqn. 5 numerically with respect to T.
 
Last edited:
  • Like
Likes Leopold89
  • #16
I did not know of steam tables before.

I still have problems with two points:
1) I looked for water steam for example (https://roymech.org/Related/Thermos/Thermos_Steam_Tables_2.html).
So by integrating you mean solving a inhomogenous first order differential equation numerically? For that I would need an initial value, so a fresh gas tank, right?
2) A problem I have is that I could derive ##\frac{\mathrm{d}U}{\mathrm{d}m}=h_V=u_V+pv_V=F_2(T)## and from that deduce ##v_V=0## by comparing coefficients, which is false, but what am I doing wrong?
 
  • #17
Leopold89 said:
I did not know of steam tables before.

I still have problems with two points:
1) I looked for water steam for example (https://roymech.org/Related/Thermos/Thermos_Steam_Tables_2.html).
So by integrating you mean solving a inhomogenous first order differential equation numerically?
yes
Leopold89 said:
For that I would need an initial value, so a fresh gas tank, right?
That wouldn't be a problem if you know the equation of state.
Leopold89 said:
2) A problem I have is that I could derive ##\frac{\mathrm{d}U}{\mathrm{d}m}=h_V=u_V+pv_V=F_2(T)## and from that deduce ##v_V=0## by comparing coefficients, which is false, but what am I doing wrong?
This is not done correctly. The correct derivation is in post #15. U is a function of both m and T and its differential involves dm and dT.
 
  • #18
Show using the Clapeyron equation that $$F_1=T\frac{dP}{dT}-P$$ and that $$F_2=h_v-\left(T\frac{dP}{dT}\right)v_V$$where P is the equilibrium vapor pressure at temperature T.
 
Last edited:
  • #19
First one:
##F_1=\frac{\Delta u}{\Delta v}\frac{m}{m}##
##F_1=\frac{\Delta U}{\Delta V}=\frac{T\Delta S - p\Delta V}{\Delta V}##
##F_1=T\frac{\mathrm{d}p}{\mathrm{d}T}-p##

Second:
##F_2=\frac{u_Lv_V-u_Vv_L}{\Delta v}##
##=\frac{u_Lv_V-u_Vv_L + u_Vv_V-u_Vv_V}{\Delta v}##
##=\frac{u_V\Delta V -v_V\Delta U}{\Delta V}##
##=h_V-\frac{p\Delta V + \Delta U}{\Delta V}v_V##
##=h_V-\frac{T\Delta S}{\Delta V}v_V##
##=h_V-T\frac{\Delta p}{\Delta T}v_V##

One other question appeared while I was looking for the steam tables: Some tables do not show the internal energy, but instead the entropy. Would I then use ##F_1=T\frac{\Delta s}{\Delta v}-p## and analogously for ##F_2##?
 
Last edited:
  • #20
Leopold89 said:
First one:
##F_1=\frac{\Delta u}{\Delta v}\frac{m}{m}##
##F_1=\frac{\Delta U}{\Delta V}=\frac{T\Delta S - p\Delta V}{\Delta V}##
##F_1=T\frac{\mathrm{d}p}{\mathrm{d}T}-p##

Second:
##F_2=\frac{u_Lv_V-u_Vv_L}{\Delta v}##
##=\frac{u_Lv_V-u_Vv_L + u_Vv_V-u_Vv_V}{\Delta v}##
##=\frac{u_V\Delta V -v_V\Delta U}{\Delta V}##
##=h_V-\frac{p\Delta V + \Delta U}{\Delta V}v_V##
##=h_V-\frac{T\Delta S}{\Delta V}v_V##
##=h_V-T\frac{\Delta p}{\Delta T}v_V##

One other question appeared while I was looking for the steam tables: Some tables do not show the internal energy, but instead the entropy. Would I then use ##F_1=T\frac{\Delta s}{\Delta v}-p## and analogously for ##F_2##?
All the ones I am familiar with have T, P, v, u, h,and s for saturated liquid and vapor.
 
  • #21
The variables m and V in Eqn. 5 of post #15 can be combined into a single variable ##\rho=m/V## which represents the average density of the combination of vapor and liquid at any time:$$\frac{d\rho}{dT}=F_3+F_4\rho\tag{5}$$This eliminates the mass and volume as separate variables.
 
  • #22
Maybe I was not using the term right, but I meant the tables for other gases than water. For example the table for Argon I found only had the densities and vapour enthalpy for given temperature and pressure. In case of water I have indeed every variable. If you have a source with better tables, can you please link it to me?

In the next step with the thermal inertia of the tank, I believe I would have to construct a system of differential equations, one for ##T_\mathrm{tank}(t)## based on the heat diff. equation with both the inside as well as the room temperature as external influence, then one for the inside ##T_\mathrm{inside}(p, t)## using the tables and lastly ##m(p,T)## similar to post #15, right?
 
  • #23
Leopold89 said:
Maybe I was not using the term right, but I meant the tables for other gases than water. For example the table for Argon I found only had the densities and vapour enthalpy for given temperature and pressure. In case of water I have indeed every variable. If you have a source with better tables, can you please link it to me?
Are you really doing argon. If you cannot find the tables on a substance, you will have to create your own (or derive analytical expressions for the required saturated properties).

I suggest you do a sample calculation using water to see how this all plays out and what to expect.
Leopold89 said:
In the next step with the thermal inertia of the tank, I believe I would have to construct a system of differential equations, one for ##T_\mathrm{tank}(t)## based on the heat diff. equation with both the inside as well as the room temperature as external influence, then one for the inside ##T_\mathrm{inside}(p, t)## using the tables and lastly ##m(p,T)## similar to post #15, right?
Before modeling the problem with the thermal inertia included, you should first check in a model calculation without inertia to see if it would significant. This could be done by assuming that the tank attains the same temperature history as the gas and comparing the changes in internal energy.
 
  • #24
I have now a curve for ##\mathrm{CO}_2##, because the implementation was easier than water. But I had to set the initial value at a somewhat arbitrary value of 8kg.
 

Attachments

  • mT_curve.png
    mT_curve.png
    3.9 KB · Views: 15
  • #25
Leopold89 said:
I have now a curve for ##\mathrm{CO}_2##, because the implementation was easier than water. But I had to set the initial value at a somewhat arbitrary value of 8kg.
The mass and temperature are decreasing as the tank expels gas, not increasing. The curve you presented would be for an initial mass of ~40 kg (if it is correct).
 
  • #26
Chestermiller said:
The mass and temperature are decreasing as the tank expels gas, not increasing. The curve you presented would be for an initial mass of ~40 kg (if it is correct).
I implemented it with the python odeint and since my table is sorted with respect to temperature, my initial value is with respect to the lowest temperature. I have also plotted the 3D graph with temperature and pressure, where I observe what you said. As I release gas, or decrease pressure, the temperature and mass falls.
 

Attachments

  • mpT_curve.png
    mpT_curve.png
    13.7 KB · Views: 13
  • #27
Leopold89 said:
I implemented it with the python odeint and since my table is sorted with respect to temperature, my initial value is with respect to the lowest temperature. I have also plotted the 3D graph with temperature and pressure, where I observe what you said. As I release gas, or decrease pressure, the temperature and mass falls.
You should also show a plot of he mass fraction of vapor x as a function of temperature and or mass. Note that the mass fraction vapor in the tank is an initial condition for the calculation.
 
Last edited:
  • #28
Here is the plot for x in dependance of mass and temperature for ##\mathrm{CO}_2##. I had to play with my initial condition, because unfortunately I cannot measure it right now. So I adjusted it until x was between 0 and 1. The initial mass, as you can see, is now at 2kg instead of the previous 8kg, else I got negative x.
But all I learned from this is that it is "garbage in, garbage out".

But maybe you can give me realistic initial conditions for a water steam tank and then I do it with water.

xmT_plot.png
 
Last edited by a moderator:
  • #29
Leopold89 said:
Here is the plot for x in dependance of mass and temperature for ##\mathrm{CO}_2##. I had to play with my initial condition, because unfortunately I cannot measure it right now. So I adjusted it until x was between 0 and 1. The initial mass, as you can see, is now at 2kg instead of the previous 8kg, else I got negative x.
But all I learned from this is that it is "garbage in, garbage out".

But maybe you can give me realistic initial conditions for a water steam tank and then I do it with water.
You need to integrate in the negative m direction. In your integrator, make the final temperature less than the initial temperature.

For water, try an initial saturation pressure of 5 bars and an initial mass fraction vapor of 0.9.
 
  • #30
Here I have the solution for water with an initial pressure of 5 bars and ##x_0=0.9##, where I used the steam table here. I have also adjusted the integration to your direction.
I am rather sure that this is wrong, because I need an initial mass and a fixed volume.
 

Attachments

  • water_curve.png
    water_curve.png
    13.7 KB · Views: 12
Last edited:
  • #31
Leopold89 said:
Here I have the solution for water with an initial pressure of 5 bars and ##x_0=0.9##, where I used the steam table here. I have also adjusted the integration to your direction.
I am rather sure that this is wrong, because I need an initial mass and a fixed volume.
As I said in post #21, you don't need the mass and volume separately, only the mass divided by volume (the average density). You specified the initial state, so you know the initial mass fractions of liquid and vapor, the specific volumes of saturated liquid and gas, and thus the mass divided by tank volume. See Eqn. 3 of post #8.
 
Last edited:
  • #32
Here is the new curve for water. It looks plausible, since the more gas I release from the tank, the more vapour I expect.
 

Attachments

  • water_curve.png
    water_curve.png
    13.3 KB · Views: 17
  • Like
Likes Chestermiller
  • #33
Now I am actually more confused. I thought the vapour-liquid temperature will get in balance with room temperature after some time, but now I see that my solution above may not even be defined for a measured pressure at room temperature. Does this mean I have to measure x at these ##p,T## and solve the same differential equation but in two dimensions with my expanded steam table?

Can you show me the thermal inertia of the tank, too, please?
 
  • #34
Leopold89 said:
Now I am actually more confused. I thought the vapour-liquid temperature will get in balance with room temperature after some time, but now I see that my solution above may not even be defined for a measured pressure at room temperature.
What do you mean by this? Do you mean that it all turns to vapor or liquid at a certain point? What is happening that you say this?
Leopold89 said:
Does this mean I have to measure x at these ##p,T## and solve the same differential equation but in two dimensions with my expanded steam table?
No. please answer my previous question..
Leopold89 said:
Can you show me the thermal inertia of the tank, too, please?
The thermal inertia of the tank is its mass times its heat capacity.
 
  • #35
Chestermiller said:
What do you mean by this? Do you mean that it all turns to vapor or liquid at a certain point? What is happening that you say this?
No. What I mean is that I could for example measure a temperature of 25°C with a pressure of 10bar, then 26°C with a pressure of 8bar, 24°C with 4bar, 25°C with 2bar and so on. So what I mean is that my measurements may not be close to the line I calculated in post #32.
 

Similar threads

Back
Top