Skip to content

Commit

Permalink
Add two new estimation methods for critical properties
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebBell committed Mar 19, 2022
1 parent 6e683ed commit 765131d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 14 deletions.
59 changes: 48 additions & 11 deletions chemicals/critical.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
PD = 'PD'
YAWS = 'YAWS'
PINAMARTINES = 'PINAMARTINES'
FEDORS = 'FEDORS'
WILSON_JASPERSON = 'WILSON_JASPERSON'

### Register data sources and lazy load them

Expand All @@ -140,6 +142,8 @@ def _add_Zc_to_df(df):
register_df_source(folder, 'PassutDanner1973.tsv')
register_df_source(folder, 'Yaws Collection.tsv', postload=_add_Zc_to_df)
register_df_source(folder, 'DIPPRPinaMartines.tsv', postload=_add_Zc_to_df)
register_df_source(folder, 'wilson_jasperson_Tc_Pc_predictions.tsv', int_CAS=True)
register_df_source(folder, 'fedors_Vc_predictions.tsv', int_CAS=True)
_critical_data_loaded = False
@mark_numba_incompatible
def _load_critical_data():
Expand All @@ -154,6 +158,8 @@ def _load_critical_data():
critical_data_Yaws = data_source('Yaws Collection.tsv')
critical_data_PassutDanner = data_source('PassutDanner1973.tsv')
critical_data_PinaMartines = data_source('DIPPRPinaMartines.tsv')
critical_data_WilsonJasperson = data_source('wilson_jasperson_Tc_Pc_predictions.tsv')
critical_data_Fedors = data_source('fedors_Vc_predictions.tsv')
_critical_data_loaded = True
Tc_sources = {
IUPAC: critical_data_IUPAC,
Expand All @@ -165,18 +171,35 @@ def _load_critical_data():
PINAMARTINES: critical_data_PinaMartines,
YAWS: critical_data_Yaws,
miscdata.JOBACK: miscdata.joback_predictions,
WILSON_JASPERSON: critical_data_WilsonJasperson,
}

_add_Zc_to_df(miscdata.joback_predictions)
_add_Zc_to_df(miscdata.webbook_data)

# Create copies just incase new dfs need to be added later
Pc_sources = Tc_sources.copy()
Vc_sources = Tc_sources.copy()

# The Passut Danner tsv file doesn't have Vc, so its not included
del Vc_sources['PD']
Zc_sources = Vc_sources.copy()
Vc_sources = {
IUPAC: critical_data_IUPAC,
MATTHEWS: critical_data_Matthews,
CRC: critical_data_CRC,
PSRK: critical_data_PSRKR4,
miscdata.WEBBOOK: miscdata.webbook_data,
PINAMARTINES: critical_data_PinaMartines,
YAWS: critical_data_Yaws,
miscdata.JOBACK: miscdata.joback_predictions,
FEDORS: critical_data_Fedors,
}
Zc_sources = {
IUPAC: critical_data_IUPAC,
MATTHEWS: critical_data_Matthews,
CRC: critical_data_CRC,
PSRK: critical_data_PSRKR4,
miscdata.WEBBOOK: miscdata.webbook_data,
PINAMARTINES: critical_data_PinaMartines,
YAWS: critical_data_Yaws,
miscdata.JOBACK: miscdata.joback_predictions,
}

omega_sources = {
PSRK: critical_data_PSRKR4,
Expand All @@ -190,6 +213,7 @@ def __getattr__(name):
'critical_data_CRC', 'critical_data_PSRKR4',
'critical_data_Yaws', 'critical_data_PassutDanner',
'critical_data_PinaMartines',
'critical_data_WilsonJasperson', 'critical_data_Fedors',
'Tc_sources', 'Pc_sources', 'Vc_sources', 'Zc_sources',
'omega_sources'):
_load_critical_data()
Expand All @@ -201,7 +225,7 @@ def __getattr__(name):

### Critical point functions

Tc_all_methods = (IUPAC, MATTHEWS, CRC, PD, miscdata.WEBBOOK, PSRK, PINAMARTINES, YAWS, miscdata.JOBACK)
Tc_all_methods = (IUPAC, MATTHEWS, CRC, PD, miscdata.WEBBOOK, PSRK, PINAMARTINES, YAWS, WILSON_JASPERSON, miscdata.JOBACK)
'''Tuple of method name keys. See the `Tc` for the actual references'''

@mark_numba_incompatible
Expand Down Expand Up @@ -249,7 +273,8 @@ def Tc(CASRN, method=None):
----------------
method : string, optional
The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS', 'CRC',
'PD', 'WEBBOOK', 'PSRK', 'PINAMARTINES', 'YAWS', 'JOBACK'.
'PD', 'WEBBOOK', 'PSRK', 'PINAMARTINES', 'YAWS', 'WILSON_JASPERSON',
'JOBACK'.
All valid values are also held in the list `Tc_all_methods`.
Notes
Expand All @@ -272,6 +297,7 @@ def Tc(CASRN, method=None):
* 'WEBBOOK', a NIST resource [18]_ containing mostly experimental
and averaged values
* 'JOBACK', an estimation method for organic substances in [19]_
* 'WILSON_JASPERSON', an estimation method in [21]_
* 'PINAMARTINES', a series of values in the supporting material of [20]_
Examples
Expand Down Expand Up @@ -366,14 +392,17 @@ def Tc(CASRN, method=None):
Performance of Four Cubic Equations of State: SRK, PR, Tc-RK, and
Tc-PR." AIChE Journal n/a, no. n/a (n.d.): e17518.
https://doi.org/10.1002/aic.17518.
.. [21] Wilson, G. M., and L. V. Jasperson. "Critical Constants Tc, Pc,
Estimation Based on Zero, First and Second Order Methods." In
Proceedings of the AIChE Spring Meeting, 21, 1996.
'''
if not _critical_data_loaded: _load_critical_data()
if method:
return retrieve_from_df_dict(Tc_sources, CASRN, 'Tc', method)
else:
return retrieve_any_from_df_dict(Tc_sources, CASRN, 'Tc')

Pc_all_methods = (IUPAC, MATTHEWS, CRC, PD, miscdata.WEBBOOK, PSRK, PINAMARTINES, YAWS, miscdata.JOBACK)
Pc_all_methods = (IUPAC, MATTHEWS, CRC, PD, miscdata.WEBBOOK, PSRK, PINAMARTINES, YAWS, WILSON_JASPERSON, miscdata.JOBACK)
'''Tuple of method name keys. See the `Pc` for the actual references'''

@mark_numba_incompatible
Expand Down Expand Up @@ -425,7 +454,8 @@ def Pc(CASRN, method=None):
----------------
method : string, optional
The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS', 'CRC',
'PD', 'WEBBOOK', 'PSRK', 'PINAMARTINES', 'YAWS', 'JOBACK'.
'PD', 'WEBBOOK', 'PSRK', 'PINAMARTINES', 'YAWS', 'WILSON_JASPERSON',
'JOBACK'.
All valid values are also held in the list `Pc_all_methods`.
Notes
Expand All @@ -449,6 +479,7 @@ def Pc(CASRN, method=None):
and averaged values
* 'JOBACK', an estimation method for organic substances in [19]_
* 'PINAMARTINES', a series of values in the supporting material of [20]_
* 'WILSON_JASPERSON', an estimation method in [21]_
See Also
--------
Expand Down Expand Up @@ -537,14 +568,17 @@ def Pc(CASRN, method=None):
Performance of Four Cubic Equations of State: SRK, PR, Tc-RK, and
Tc-PR." AIChE Journal n/a, no. n/a (n.d.): e17518.
https://doi.org/10.1002/aic.17518.
.. [21] Wilson, G. M., and L. V. Jasperson. "Critical Constants Tc, Pc,
Estimation Based on Zero, First and Second Order Methods." In
Proceedings of the AIChE Spring Meeting, 21, 1996.
'''
if not _critical_data_loaded: _load_critical_data()
if method:
return retrieve_from_df_dict(Pc_sources, CASRN, 'Pc', method)
else:
return retrieve_any_from_df_dict(Pc_sources, CASRN, 'Pc')

Vc_all_methods = (IUPAC, MATTHEWS, CRC, miscdata.WEBBOOK, PSRK, PINAMARTINES, YAWS, miscdata.JOBACK)
Vc_all_methods = (IUPAC, MATTHEWS, CRC, miscdata.WEBBOOK, PSRK, PINAMARTINES, YAWS, FEDORS, miscdata.JOBACK)
'''Tuple of method name keys. See the `Vc` for the actual references'''

@mark_numba_incompatible
Expand Down Expand Up @@ -598,7 +632,7 @@ def Vc(CASRN, method=None):
----------------
method : string, optional
The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS', 'CRC',
'WEBBOOK', 'PSRK', 'PINAMARTINES', 'YAWS', 'JOBACK'.
'WEBBOOK', 'PSRK', 'PINAMARTINES', 'YAWS', 'FEDORS', 'JOBACK'.
All valid values are also held in the list `Vc_all_methods`.
Notes
Expand All @@ -619,6 +653,7 @@ def Vc(CASRN, method=None):
* 'WEBBOOK', a NIST resource [17]_ containing mostly experimental
and averaged values
* 'JOBACK', an estimation method for organic substances in [18]_
* 'FEDORS', an estimation methid in [20]_
* 'PINAMARTINES', a series of values in the supporting material of [19]_
See Also
Expand Down Expand Up @@ -704,6 +739,8 @@ def Vc(CASRN, method=None):
Performance of Four Cubic Equations of State: SRK, PR, Tc-RK, and
Tc-PR." AIChE Journal n/a, no. n/a (n.d.): e17518.
https://doi.org/10.1002/aic.17518.
.. [20] Fedors, R. F. "A Method to Estimate Critical Volumes." AIChE
Journal 25, no. 1 (1979): 202-202. https://doi.org/10.1002/aic.690250129.
'''
if not _critical_data_loaded: _load_critical_data()
if method:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_critical.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test_Tc():
assert_close(126.2, Tc(CASRN='7727-37-9', method='MATTHEWS'))

methods = Tc_methods(CASRN='98-01-1')
assert methods == ['IUPAC', 'PSRK', 'WEBBOOK', 'PINAMARTINES', 'YAWS']
assert methods == ['IUPAC', 'PSRK', 'WEBBOOK', 'PINAMARTINES', 'YAWS', 'WILSON_JASPERSON']

# Error handling
assert Tc(CASRN='BADCAS') is None
Expand All @@ -232,7 +232,7 @@ def test_Pc():
assert_close(3394387.5, Pc(CASRN='7727-37-9', method='MATTHEWS'))

methods = Pc_methods(CASRN='98-01-1')
assert methods == ['IUPAC', 'PSRK', 'WEBBOOK', 'PINAMARTINES', 'YAWS']
assert methods == ['IUPAC', 'PSRK', 'WEBBOOK', 'PINAMARTINES', 'YAWS', 'WILSON_JASPERSON']

# Error handling
assert None == Pc(CASRN='BADCAS')
Expand Down Expand Up @@ -264,7 +264,7 @@ def test_Vc():
assert_close(8.950e-05, Vc(CASRN='7727-37-9', method='MATTHEWS'))

methods = Vc_methods(CASRN='98-01-1')
assert methods == ['PSRK', 'PINAMARTINES', 'YAWS']
assert methods == ['PSRK', 'PINAMARTINES', 'YAWS', 'FEDORS']

# Error handling
assert None == Vc(CASRN='BADCAS')
Expand Down

0 comments on commit 765131d

Please sign in to comment.