You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
As of now the real density is calculated this way $\rho = \frac{P \cdot T_n}{P_n \cdot T \cdot Z}$, however the correct formula is this one: $\rho = \frac{P \cdot T_n \cdot \boldsymbol Z_n}{P_n \cdot T \cdot Z}$, where $Z_n$ is a compressibility factor taken at normal conditions ($P_n = 101325 \ Pa$ and $T = 273.15 \ K$)
Reasoning
Compressibility factor is $Z = \frac{P \cdot V}{n \cdot R \cdot T} \Rightarrow 1 = \frac{P \cdot V}{n \cdot R \cdot T \cdot Z}$, which should hold true for any $P$, $V$, $T$ and $Z$ of the same medium.
Let's consider 2 states: state 1 is at given conditions and state 2 is at normal conditions. Then:
$$\frac{P_1 \cdot V_1}{n \cdot R \cdot T_1 \cdot Z_1} = \frac{P_2 \cdot V_2}{n \cdot R \cdot T_2 \cdot Z_2} \xRightarrow[\text{cancelling out n, R and m}]{V=\frac{m}{\rho}} \frac{P_1}{T_1 \cdot Z_1 \cdot \rho_1} = \frac{P_2}{T_2 \cdot Z_2 \cdot \rho_2} \xRightarrow[]{} \rho_1 = \rho_2 \frac{P_1 \cdot T_2 \cdot Z_2}{P_2 \cdot T_1 \cdot Z_1} = \rho_n \frac{P \cdot T_n \cdot Z_n}{P_n \cdot T \cdot Z}$$
So basically, for state 2 we're using a real gas, instead of ideal gas, which $Z = 1$
Data-driven proof
Calculate real density for Methane
Using NIST webbook
Let $P_n = 101325\ Pa$, $T_n = 273.15\ K$
Obtain $V_n = 0.022361\ m^3/mol$ and $\rho_n = 44.722\ mol/m^3$ at given conditions via: webbook link
Calculate $Z_n = 0.997631$ using $Z = \frac{P \cdot V}{n \cdot R \cdot T}$
Let $P = 60 \cdot P_n \ Pa$, $T = 320\ K$
Obtain $V = 0.00040562\ m^3/mol$ and $\rho = 2465.3 mol/m^3$ at given conditions via: webbook link
importCoolProp.CoolProp# create equation of state for Methaneeos=CoolProp.AbstractState("HEOS", "Methane")
pn=101325# Patn=273.15# Keos.update(CoolProp.PT_INPUTS, pn, tn) # update internal state to be at given conditionsrhon=eos.rhomolar() # 44.721543 mol/m^3, obtained through link[1]zn=eos.compressibility_factor() # 0.997613p=60*pn# Pat=320# Keos.update(CoolProp.PT_INPUTS, p, t) # update internal state to be at given conditionsrho=eos.rhomolar() # 2465.335806 mol/m^3, obtained through link[2]z=eos.compressibility_factor() # 0.926841wrong_rho=rhon* (p*tn) / (pn*t*z) # 2471.235416 mol/m^3right_rho=wrong_rho*zn# 2465.335806 mol/m^3rel_err=lambdaorig, approx: abs(approx-orig) /origprint(f"{rel_err(rho, wrong_rho):.5%}") # 0.23930 %print(f"{rel_err(rho, right_rho):.5%}") # 0.00000 %
The text was updated successfully, but these errors were encountered:
Describe the bug$\rho = \frac{P \cdot T_n}{P_n \cdot T \cdot Z}$ , however the correct formula is this one: $\rho = \frac{P \cdot T_n \cdot \boldsymbol Z_n}{P_n \cdot T \cdot Z}$ , where $Z_n$ is a compressibility factor taken at normal conditions ($P_n = 101325 \ Pa$ and $T = 273.15 \ K$ )
As of now the real density is calculated this way
Reasoning$Z = \frac{P \cdot V}{n \cdot R \cdot T} \Rightarrow 1 = \frac{P \cdot V}{n \cdot R \cdot T \cdot Z}$ , which should hold true for any $P$ , $V$ , $T$ and $Z$ of the same medium.
Compressibility factor is
Let's consider 2 states: state 1 is at given conditions and state 2 is at normal conditions. Then:
So basically, for state 2 we're using a real gas, instead of ideal gas, which$Z = 1$
Data-driven proof
Calculate real density for Methane
Using NIST webbook
Copy-pastable python script
Using CoolProp library
The text was updated successfully, but these errors were encountered: