Skip to content

Commit

Permalink
Finally re-wrote the Parachor function to be funny SI-compliant.
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebBell committed Jan 15, 2017
1 parent 9be28d1 commit 8e8cbab
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 68 deletions.
4 changes: 2 additions & 2 deletions tests/test_chemical.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_Chemical_properties_T_dependent():
assert_allclose(w.Prg, 0.9803087814815961)

assert_allclose(w.solubility_parameter, 47863.51384219548)
assert_allclose(w.Parachor, 52.656339998350205)
assert_allclose(w.Parachor, 9.363768522707514e-06)

def test_Chemical_properties_T_phase():
# T-only dependent properties (always or at the moment)
Expand All @@ -190,7 +190,7 @@ def test_Chemical_properties_T_phase():
assert_allclose(w.Z, 0.0007247422467681115)

assert_allclose(w.isobaric_expansion, 0.00027479530461365189, rtol=1E-3)
assert_allclose(w.JT, -2.2029508371866032e-07)
assert_allclose(w.JT, -2.2029508371866032e-07, rtol=1E-3)

assert_allclose(w.mu, 0.0008537426062537152)
assert_allclose(w.k, 0.6094991151038377)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ def test_isentropic_exponent():
k = isentropic_exponent(33.6, 25.27)
assert_allclose(k, 1.329639889196676)


def test_Parachor():
# TODO: replace with a test for a new function
P = Parachor(0.02117, 114.22852, 700.03, 5.2609)
assert_allclose(P, 352.66655018657565)
P = Parachor(100.15888, 800.8088185536124, 4.97865317223119, 0.02672166960656005)
assert_allclose(P, 5.088443542210164e-05)


def test_phase_select_property():
assert 150 == phase_select_property(phase='s', s=150, l=10)
Expand Down
35 changes: 33 additions & 2 deletions thermo/chemical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,14 +1619,45 @@ def Prg(self):

@property
def solubility_parameter(self):
r'''Solubility parameter of the chemical at its
current temperature and pressure, in units of Pa^0.5.
.. math::
\delta = \sqrt{\frac{\Delta H_{vap} - RT}{V_m}}
Calculated based on enthalpy of vaporization and molar volume.
Normally calculated at STP. For uses of this property, see
:obj:`thermo.solubility.solubility_parameter`.
Examples
--------
>>> Chemical('NH3').solubility_parameter
24766.329043856073
'''
return solubility_parameter(T=self.T, Hvapm=self.Hvapm, Vml=self.Vml,
Method=self.solubility_parameter_method,
CASRN=self.CAS)

@property
def Parachor(self):
if all((self.sigma, self.MW, self.rhol, self.rhog)):
return Parachor(sigma=self.sigma, MW=self.MW, rhol=self.rhol, rhog=self.rhog)
r'''Parachor of the chemical at its
current temperature and pressure, in units of N^0.25*m^2.75/mol.
.. math::
P = \frac{\sigma^{0.25} MW}{\rho_L - \rho_V}
Calculated based on surface tension, density of the liquid and gas
phase, and molecular weight. For uses of this property, see
:obj:`thermo.utils.Parachor`.
Examples
--------
>>> Chemical('octane').Parachor
6.291693072841486e-05
'''
sigma, rhol, rhog = self.sigma, self.rhol, self.rhog
if all((sigma, rhol, rhog, self.MW)):
return Parachor(sigma=sigma, MW=self.MW, rhol=rhol, rhog=rhog)
return None

### Single-phase properties
Expand Down
2 changes: 1 addition & 1 deletion thermo/thermal_conductivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def DIPPR9I(ws, ks):
----------
.. [1] Reid, Robert C.; Prausnitz, John M.; Poling, Bruce E. The
Properties of Gases and Liquids. McGraw-Hill Companies, 1987.
.. [2] Danner, Ronald P, and Design Institute for Physical Property Data.
.. [2] Danner, Ronald P, and Design Institute for Physical Property Data.
Manual for Predicting Chemical Process Design Data. New York, N.Y, 1982.
'''
if not none_and_length_check([ks, ws]): # check same-length inputs
Expand Down
116 changes: 56 additions & 60 deletions thermo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,70 +216,66 @@ def int2CAS(i):
return i[:-3]+'-'+i[-3:-1]+'-'+i[-1]


def Parachor(MW, rhol, rhog, sigma):
r'''Calculate Parachor for a pure species, using its density in the
liquid and gas phases, surface tension, and molecular weight.
.. math::
P = \frac{\sigma^{0.25} MW}{\rho_L - \rho_V}
Parameters
----------
MW : float
Molecular weight, [g/mol]
rhol : float
Liquid density [kg/m^3]
rhog : float
Gas density [kg/m^3]
sigma : float
Surface tension, [N/m]
def Parachor(sigma, MW, rhol, rhog):
'''Calculates a Chemical's Parachor according to DIPPR Method.
Returns
-------
P : float
Parachor, [N^0.25*m^2.75/mol]
>>> Parachor(0.02117, 114.22852, 700.03, 5.2609) # Octane; DIPPR: 350.6
352.66655018657565
Notes
-----
To convert the output of this function to units of [mN^0.25*m^2.75/kmol],
multiply by 5623.4132519.
Values in group contribution tables for Parachor are often listed as
dimensionless, in which they are multiplied by 5623413 and the appropriate
units to make them dimensionless.
Examples
--------
Calculating Parachor from a known surface tension for methyl isobutyl
ketone at 293.15 K
>>> Parachor(100.15888, 800.8088185536124, 4.97865317223119, 0.02672166960656005)
5.088443542210164e-05
Converting to the `dimensionless` form:
>>> 5623413*5.088443542210164e-05
286.14419565030687
Compared to 274.9 according to a group contribution method described in
[3]_.
References
----------
.. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
New York: McGraw-Hill Professional, 2000.
.. [2] Green, Don, and Robert Perry. Perry's Chemical Engineers' Handbook,
8E. McGraw-Hill Professional, 2007.
.. [3] Danner, Ronald P, and Design Institute for Physical Property Data.
Manual for Predicting Chemical Process Design Data. New York, N.Y, 1982.
'''
rhol, rhog = rhol/1000., rhog/1000.
sigma = sigma*1000
P = sigma**0.25*MW/(rhol-rhog)
return P


#def Parachor2(sigma, Vml, Vmg):
# r'''Calculate Parachor for a pure species, using its molar volumes in
# liquid and vapor form, and surface tension.
#
# .. math::
# P = \frac{ \sigma^{0.25} MW}{\rho_L - \rho_V}=\sigma^{0.25} (V_L - V_V)
#
# Parameters
# ----------
# sigma : float
# Surface tension, [N/m]
# Vml : float
# Liquid molar volume [m^3/mol]
# Vmg : float
# Gas molar volume [m^3/mol]
#
# Returns
# -------
# P : float
# Parachor, [-]
#
# Notes
# -----
# Parachor is normally specified in units of [], in which molar volumes must
# be converted to mL/mol, and surface tension in mN/m. Pure SI units are:
#
# .. math::
# \frac{\text{kg}^{0.25}\cdot\text{meter}^3}
# {\text{mole}\cdot \text{second}^{0.5}}
#
# The conversion to pure SI is to multiply by 1.77828e-7.
#
# Examples
# --------
# Example 12.1 in [1]_.
#
# >>> Parachor(sigma=0.02119, Vml=9.6525097e-05, Vmg=0)
# 207.09660808998868
#
# References
# ----------
# .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
# New York: McGraw-Hill Professional, 2000.
# '''
# Vml, Vmg = Vml*1E6, Vmg*1E6
# sigma = sigma*1000
# P = sigma**0.25/(Vmg-Vml)
# return P

#print([Parachor2(sigma=0.02119, Vml=9.6525097e-05, Vmg=0)])
rhol, rhog = rhol*1000., rhog*1000. # Convert kg/m^3 to g/m^3
return sigma**0.25*MW/(rhol-rhog) # (N/m)**0.25*g/mol/(g/m^3)


def property_molar_to_mass(A_molar, MW): # pragma: no cover
if A_molar is None:
Expand Down

0 comments on commit 8e8cbab

Please sign in to comment.