Skip to content

Commit

Permalink
change rhor->V, add KVMXPC
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMVale committed Dec 3, 2023
1 parent 419316a commit ea5ca75
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@

## Examples

Estimate the residual thermal conductivity of ethylene at 350 K and 10 bar.
Estimate the residual thermal conductivity of ethylene at 350 K and 100 bar.

```python exec="on" source="console"
from polykin.properties.thermal_conductivity import KVPC_stiel_thodos

Vc = 130.4 # cm3/mol
V = 2.8e3 # cm3/mol, @ 350K, 10 bar
rhor = Vc/V
V = 1.8e-4 # m³/mol, @ 350K, 100 bar

k_residual = KVPC_stiel_thodos(rhor=rhor, M=28.05e-3,
k_residual = KVPC_stiel_thodos(V=V, M=28.05e-3,
Tc=282.4, Pc=50.4e5, Zc=0.280)

print(k_residual, "W/(m·K)")
Expand Down
43 changes: 11 additions & 32 deletions docs/tutorials/thermal_conductivity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@
"P = 100e5 # Pa\n",
"Vc = 130.4 # cm³/mol\n",
"Z = 0.62 # @ 350K, 100 bar using Lee-Kesler\n",
"V = Z*8.314*T/P # m³/mol\n",
"rhor = Vc/(V*1e6)"
"V = Z*8.314*T/P # m³/mol"
]
},
{
Expand All @@ -179,7 +178,7 @@
{
"data": {
"text/plain": [
"0.7227828469884234"
"0.017402376056515192"
]
},
"execution_count": 9,
Expand All @@ -188,27 +187,7 @@
}
],
"source": [
"rhor"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(0.01739392)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"KVPC_stiel_thodos(rhor=rhor, M=28.05e-3, Tc=282.4, Pc=50.4e5, Zc=0.280)"
"KVPC_stiel_thodos(V=V, M=28.05e-3, Tc=282.4, Pc=50.4e5, Zc=0.280)"
]
},
{
Expand All @@ -230,7 +209,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -239,7 +218,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -254,7 +233,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -285,7 +264,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -295,7 +274,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -318,7 +297,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -330,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand All @@ -339,7 +318,7 @@
"0.10808664126899359"
]
},
"execution_count": 17,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
91 changes: 80 additions & 11 deletions src/polykin/properties/thermal_conductivity/vapor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@
from scipy.constants import R, N_A

__all__ = ['KVPC_stiel_thodos',
'KVMXPC_stiel_thodos',
'KVMX2_wassilijewa']


@np.vectorize
def KVPC_stiel_thodos(rhor: float,
def KVPC_stiel_thodos(V: float,
M: float,
Tc: float,
Pc: float,
Zc: float
) -> float:
r"""Calculate the effect of pressure (or density) on gas thermal
conductivity using the method of Stiel and Thodos for nonpolar gases.
r"""Calculate the effect of pressure (or density) on the thermal
conductivity of pure gases using the method of Stiel and Thodos for
nonpolar gases.
$$ \left( k-k_0 \right) \Gamma Z_c^5 = f(\rho_r) $$
$$ \left( k-k^{\circ} \right) \Gamma Z_c^5 = f(\rho_r) $$
where $k$ is the dense gas thermal conductivity, $k^\circ$ is the
low-pressure thermal conductivtiy, $\Gamma$ is a group of constants, $Z_c$
is the critical compressibility factor, and
$\rho_r = \rho / \rho_c = V_c / V$ is the reduced gas density. This
equation is valid in the range $0 \leq \rho_r < 2.8$.
is the critical compressibility factor, and $\rho_r = V_c / V$ is the
reduced gas density. This equation is valid in the range
$0 \leq \rho_r < 2.8$.
Reference:
Expand All @@ -36,8 +37,8 @@ def KVPC_stiel_thodos(rhor: float,
Parameters
----------
rhor : float
Reduced gas density, $\rho_r$.
V : float
Gas molar volume. Unit = m³/mol.
M : float
Molar mass. Unit = kg/mol.
Tc : float
Expand All @@ -50,10 +51,12 @@ def KVPC_stiel_thodos(rhor: float,
Returns
-------
float
Residual thermal conductivity, $(k - k_0)$. Unit = W/(m·K).
Residual thermal conductivity, $(k - k^{\circ})$. Unit = W/(m·K).
"""

gamma = ((Tc * M**3 * N_A**2)/(R**5 * Pc**4))**(1/6)
Vc = Zc*R*Tc/Pc
rhor = Vc/V

if rhor < 0.5:
a = 1.22e-2*(np.exp(0.535*rhor) - 1)
Expand All @@ -67,6 +70,72 @@ def KVPC_stiel_thodos(rhor: float,
return a/(gamma * Zc**5)


def KVMXPC_stiel_thodos(V: float,
y: FloatVector,
M: FloatVector,
Tc: FloatVector,
Pc: FloatVector,
Zc: FloatVector,
w: FloatVector
) -> float:
r"""Calculate the effect of pressure (or density) on the thermal
conductivity of gas mixtures using the method of Stiel and Thodos for
nonpolar gases, combined with the mixing rules of Yorizane.
Reference:
* RC Reid, JM Prausniz, and BE Poling. The properties of gases & liquids
4th edition, 1986, p. 536.
Parameters
----------
V : float
Gas molar volume. Unit = m³/mol.
y : FloatVector
Mole fractions of all components. Unit = mol/mol.
M : FloatVector
Molar masses of all components. Unit = kg/mol.
Tc : FloatVector
Critical temperatures of all components. Unit = K.
Pc : FloatVector
Critical pressures of all components. Unit = Pa.
Zc : FloatVector
Critical compressibility factors of all components.
w : FloatVector
Acentric factors of all components.
Returns
-------
float
Residual thermal conductivity, $(k - k^{\circ})$. Unit = W/(m·K).
"""

Vc = Zc*R*Tc/Pc

N = len(y)
Vc_mix = 0.
Tc_mix = 0.
for i in range(N):
for j in range(N):
if i == j:
vc = Vc[i]
tc = Tc[i]
else:
vc = (1/8)*(Vc[i]**(1/3) + Vc[j]**(1/3))**3
tc = np.sqrt(Tc[i]*Tc[j])
term = y[i]*y[j]*vc
Vc_mix += term
Tc_mix += term*tc
Tc_mix /= Vc_mix

w_mix = np.dot(y, w)
Zc_mix = 0.291 - 0.08*w_mix
Pc_mix = Zc_mix*R*Tc_mix/Vc_mix
M_mix = np.dot(y, M)

return KVPC_stiel_thodos(V, M_mix, Tc_mix, Pc_mix, Zc_mix)


def KVMX2_wassilijewa(y: FloatVector,
k: FloatVector,
M: FloatVector
Expand Down
21 changes: 17 additions & 4 deletions tests/properties/test_thermal_conductivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright Hugo Vale 2023

from polykin.properties.thermal_conductivity import KLMX2_li, \
KVPC_stiel_thodos, KVMX2_wassilijewa
KVPC_stiel_thodos, KVMXPC_stiel_thodos, KVMX2_wassilijewa
import numpy as np


Expand All @@ -24,14 +24,27 @@ def test_KVPC_stiel_thodos():
"Example 10-3, p. 521, Reid-Prausnitz-Poling"
Tc = 309.6
Pc = 72.4e5
Vc = 97.4 # cm3/mol
Zc = 0.274
M = 44.013e-3
rhor = Vc/144
kpc = KVPC_stiel_thodos(rhor, M, Tc, Pc, Zc)
V = 144e-6
kpc = KVPC_stiel_thodos(V, M, Tc, Pc, Zc)
assert np.isclose(kpc, 1.78e-2, rtol=1e-2)


def test_KVMXPC_stiel_thodos():
"Example 10-6, p. 537, Reid-Prausnitz-Poling"
y1 = 0.755
V = 159e-6
y = np.array([y1, 1 - y1])
Zc = np.array([0.288, 0.274])
Pc = np.array([46.0e5, 73.8e5])
Tc = np.array([190.4, 304.1])
M = np.array([16.043e-3, 44.010e-3])
w = np.array([0.011, 0.239])
kpc = KVMXPC_stiel_thodos(V, y, M, Tc, Pc, Zc, w)
assert np.isclose(kpc, 1.50e-2, rtol=1e-2)


def test_KVMX2_wassilijewa():
"Example 10-5, p. 534, Reid-Prausnitz-Poling"
y1 = 0.25
Expand Down

0 comments on commit ea5ca75

Please sign in to comment.