Soave Redlich Kwong
In [1]:
Copied!
## Redlich_Kwong Equation - for Mixtures
import pandas as pd
import numpy as np
from pvtpy.compositional import Chromatography, Component, properties_df
from pvtpy.units import Pressure, Temperature
## Redlich_Kwong Equation - for Mixtures
import pandas as pd
import numpy as np
from pvtpy.compositional import Chromatography, Component, properties_df
from pvtpy.units import Pressure, Temperature
Liquid Hydrocarbon Mixture¶
In [2]:
Copied!
d1 = {
'comp': ['methane','ethane','propane','butane','pentane','n-hexane'],
'mole_fraction':[0.45,0.05,0.05,0.03,0.01,0.01]
}
c7_plus = Component(
name = 'C7+',
molecular_weight=215,
mole_fraction=0.4,
critical_pressure=285,
critical_pressure_unit='psi',
critical_temperature=700,
critical_temperature_unit='farenheit',
params={'acentric_factor':0.52}
)
ch1 = Chromatography()
ch1.from_df(pd.DataFrame(d1),name='comp')
ch1.plus_fraction = c7_plus
ch1.df(columns=['mole_fraction','acentric_factor'])
d1 = {
'comp': ['methane','ethane','propane','butane','pentane','n-hexane'],
'mole_fraction':[0.45,0.05,0.05,0.03,0.01,0.01]
}
c7_plus = Component(
name = 'C7+',
molecular_weight=215,
mole_fraction=0.4,
critical_pressure=285,
critical_pressure_unit='psi',
critical_temperature=700,
critical_temperature_unit='farenheit',
params={'acentric_factor':0.52}
)
ch1 = Chromatography()
ch1.from_df(pd.DataFrame(d1),name='comp')
ch1.plus_fraction = c7_plus
ch1.df(columns=['mole_fraction','acentric_factor'])
Out[2]:
mole_fraction | acentric_factor | |
---|---|---|
methane | 0.45 | 0.0115 |
ethane | 0.05 | 0.0995 |
propane | 0.05 | 0.1523 |
butane | 0.03 | 0.2002 |
pentane | 0.01 | 0.2515 |
n-hexane | 0.01 | 0.3013 |
C7+ | 0.40 | 0.5200 |
In [3]:
Copied!
p1 = Pressure(value = 4000, unit='psi')
t1 = Temperature(value = 160, unit='farenheit')
p1 = Pressure(value = 4000, unit='psi')
t1 = Temperature(value = 160, unit='farenheit')
In [4]:
Copied!
ch1.soave_redlich_kwong_components_coef(t1)
ch1.df(columns=['mole_fraction','srk_a','srk_b','srk_alpha', 'acentric_factor'])
ch1.soave_redlich_kwong_components_coef(t1)
ch1.df(columns=['mole_fraction','srk_a','srk_b','srk_alpha', 'acentric_factor'])
Out[4]:
mole_fraction | srk_a | srk_b | srk_alpha | acentric_factor | |
---|---|---|---|---|---|
methane | 0.45 | 8688.770713 | 0.478495 | 0.686593 | 0.0115 |
ethane | 0.05 | 21041.202832 | 0.723177 | 0.923015 | 0.0995 |
propane | 0.05 | 35409.568072 | 1.004698 | 1.051035 | 0.1523 |
butane | 0.03 | 52350.514587 | 1.292135 | 1.164088 | 0.2002 |
pentane | 0.01 | 72002.574726 | 1.608655 | 1.264327 | 0.2515 |
n-hexane | 0.01 | 93955.330354 | 1.943280 | 1.358148 | 0.3013 |
C7+ | 0.40 | 232235.747155 | 3.782751 | 1.489631 | 0.5200 |
In [5]:
Copied!
ch1.soave_redlich_kwong_mix_coef()
ch1.soave_redlich_kwong_mix_coef()
Out[5]:
(90381.12778928163, 1.8891001828303455)
In [6]:
Copied!
ma = ch1.apparent_molecular_weight()
ma
ma = ch1.apparent_molecular_weight()
ma
Out[6]:
100.264435
In [7]:
Copied!
ch1.soave_redlich_kwong.alpha
ch1.soave_redlich_kwong.alpha
In [8]:
Copied!
A,B = ch1.soave_redlich_kwong.coef_AB(p1,t1)
print(A,B)
A,B = ch1.soave_redlich_kwong.coef_AB(p1,t1)
print(A,B)
8.177439904015678 1.1364616583602605
In [ ]:
Copied!
In [9]:
Copied!
poly = ch1.soave_redlich_kwong.cubic_poly(p1,t1)
print(type(poly))
print(poly)
poly = ch1.soave_redlich_kwong.cubic_poly(p1,t1)
print(type(poly))
print(poly)
<class 'numpy.polynomial.polynomial.Polynomial'> -9.293346914459027 + 5.749433144732464·x¹ - 1.0·x² + 1.0·x³
In [10]:
Copied!
roots = poly.roots()
print(roots)
roots[np.isreal(roots)].real
roots = poly.roots()
print(roots)
roots[np.isreal(roots)].real
[-0.22557549-2.52056284j -0.22557549+2.52056284j 1.45115098+0.j ]
Out[10]:
array([1.45115098])
In [11]:
Copied!
ch1.soave_redlich_kwong.estimate_densities(p1,t1, ma)
ch1.soave_redlich_kwong.estimate_densities(p1,t1, ma)
Out[11]:
{'rho': array([41.56560542])}
Gas Hydrocarbon Mixture¶
In [12]:
Copied!
d2 = {
'comp': ['methane','ethane','propane','butane','pentane','n-hexane'],
'mole_fraction':[0.86,0.05,0.05,0.02,0.01,0.005]
}
c7_plus2 = Component(
name = 'C7+',
molecular_weight=215,
mole_fraction=0.0005,
critical_pressure=285,
critical_pressure_unit='psi',
critical_temperature=700,
critical_temperature_unit='farenheit',
params={'acentric_factor':0.52}
)
ch2 = Chromatography()
ch2.from_df(pd.DataFrame(d2),name='comp')
ch2.plus_fraction = c7_plus2
ch2.df(columns=['mole_fraction'], normalize=True)
d2 = {
'comp': ['methane','ethane','propane','butane','pentane','n-hexane'],
'mole_fraction':[0.86,0.05,0.05,0.02,0.01,0.005]
}
c7_plus2 = Component(
name = 'C7+',
molecular_weight=215,
mole_fraction=0.0005,
critical_pressure=285,
critical_pressure_unit='psi',
critical_temperature=700,
critical_temperature_unit='farenheit',
params={'acentric_factor':0.52}
)
ch2 = Chromatography()
ch2.from_df(pd.DataFrame(d2),name='comp')
ch2.plus_fraction = c7_plus2
ch2.df(columns=['mole_fraction'], normalize=True)
Out[12]:
mole_fraction | |
---|---|
methane | 0.863887 |
ethane | 0.050226 |
propane | 0.050226 |
butane | 0.020090 |
pentane | 0.010045 |
n-hexane | 0.005023 |
C7+ | 0.000502 |
In [13]:
Copied!
ch2.soave_redlich_kwong_components_coef(t1)
ch2.df(columns=['mole_fraction','srk_a','srk_b'])
ch2.soave_redlich_kwong_components_coef(t1)
ch2.df(columns=['mole_fraction','srk_a','srk_b'])
Out[13]:
mole_fraction | srk_a | srk_b | |
---|---|---|---|
methane | 0.863887 | 8688.770713 | 0.478495 |
ethane | 0.050226 | 21041.202832 | 0.723177 |
propane | 0.050226 | 35409.568072 | 1.004698 |
butane | 0.020090 | 52350.514587 | 1.292135 |
pentane | 0.010045 | 72002.574726 | 1.608655 |
n-hexane | 0.005023 | 93955.330354 | 1.943280 |
C7+ | 0.000502 | 232235.747155 | 3.782751 |
In [14]:
Copied!
ma2 = ch2.apparent_molecular_weight()
ma2
ma2 = ch2.apparent_molecular_weight()
ma2
Out[14]:
20.027368156705165
In [15]:
Copied!
ch2.soave_redlich_kwong_mix_coef()
ch2.soave_redlich_kwong_mix_coef()
Out[15]:
(8741.036982505435, 0.5539290826470736)
In [16]:
Copied!
A,B = ch2.soave_redlich_kwong.coef_AB(p1,t1)
print(A,B)
A,B = ch2.soave_redlich_kwong.coef_AB(p1,t1)
print(A,B)
0.7908653761199639 0.3332375750109206
In [17]:
Copied!
poly = ch2.soave_redlich_kwong.cubic_poly(p1,t1)
print(type(poly))
print(poly)
poly = ch2.soave_redlich_kwong.cubic_poly(p1,t1)
print(type(poly))
print(poly)
<class 'numpy.polynomial.polynomial.Polynomial'> -0.2635460600983164 + 0.34658051970988435·x¹ - 1.0·x² + 1.0·x³
In [18]:
Copied!
poly.roots()
poly.roots()
Out[18]:
array([0.03418411-0.53077109j, 0.03418411+0.53077109j, 0.93163177+0.j ])
In [19]:
Copied!
p2 = Pressure(value = 4000, unit='psi')
t2 = Temperature(value = 160, unit='farenheit')
ch2.soave_redlich_kwong.estimate_densities(p2,t2, ma2)
p2 = Pressure(value = 4000, unit='psi')
t2 = Temperature(value = 160, unit='farenheit')
ch2.soave_redlich_kwong.estimate_densities(p2,t2, ma2)
Out[19]:
{'rho': array([12.93240769])}
In [ ]:
Copied!