diff --git a/setup.py b/setup.py index 724b6fab..ff778b59 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ name = 'thermo', packages = ['thermo'], license='MIT', - version = '0.1.24', + version = '0.1.25', description = 'Chemical properties component of Chemical Engineering Design Library (ChEDL)', author = 'Caleb Bell', install_requires=['fluids', 'scipy', 'pandas', 'coolprop'], @@ -64,7 +64,7 @@ platforms=["Windows", "Linux", "Mac OS", "Unix"], author_email = 'Caleb.Andrew.Bell@gmail.com', url = 'https://github.com/CalebBell/thermo', - download_url = 'https://github.com/CalebBell/thermo/tarball/0.1.24', + download_url = 'https://github.com/CalebBell/thermo/tarball/0.1.25', keywords = ['chemical engineering', 'chemistry', 'mechanical engineering', 'thermodynamics', 'databases', 'cheminformatics'], classifiers = classifiers, diff --git a/tests/test_eos.py b/tests/test_eos.py index 7f588f87..d0f8efbe 100644 --- a/tests/test_eos.py +++ b/tests/test_eos.py @@ -853,6 +853,7 @@ def dV_dP(P, T, eos, order=0, phase=True, Tc=507.6, Pc=3025000., omega=0.2975): assert allclose_variable(x, y, limits=[.02, .04, .04, .05, .15, .45, .95], rtols=[1E-2, 1E-3, 1E-4, 1E-5, 1E-6, 1E-7, 1E-9]) +@pytest.mark.slow def test_fuzz_Psat(): from thermo import eos eos_list = list(eos.__all__); eos_list.remove('GCEOS') @@ -878,20 +879,21 @@ def test_fuzz_Psat(): rerr = (e.fugacity_l - e.fugacity_g)/e.fugacity_g x.append(rerr) - # Assert the average error is under 0.01% + # Assert the average error is under 0.04% assert sum(abs(np.array(x)))/len(x) < 1E-4 # Test Polish is working, and that its values are close to the polynomials Psats_solved = [] Psats_poly = [] for eos in range(len(eos_list)): - for T in np.linspace(0.4*Tc, Tc*.99, 30): + for T in np.linspace(0.4*Tc, Tc*.99, 50): e = globals()[eos_list[eos]](Tc=Tc, Pc=Pc, omega=omega, T=T, P=1E5) Psats_poly.append(e.Psat(T)) Psats_solved.append(e.Psat(T, polish=True)) assert_allclose(Psats_solved, Psats_poly, rtol=1E-4) - + +@pytest.mark.slow def test_fuzz_dPsat_dT(): from thermo import eos eos_list = list(eos.__all__); eos_list.remove('GCEOS') diff --git a/tests/test_refractivity.py b/tests/test_refractivity.py index bd564715..cf7dd4ee 100644 --- a/tests/test_refractivity.py +++ b/tests/test_refractivity.py @@ -23,6 +23,7 @@ from numpy.testing import assert_allclose import pytest import pandas as pd +import numpy as np from thermo.refractivity import * def test_refractivity_CRC(): @@ -30,11 +31,12 @@ def test_refractivity_CRC(): assert_allclose(CRC_RI_organic['RIT'].sum(), 1304152.35) def test_refractivity_general(): - tot = sum([refractive_index(i)[0] for i in CRC_RI_organic.index.values]) - assert_allclose(tot, 6602.78821) - - tot = pd.DataFrame([refractive_index(i)[1] for i in CRC_RI_organic.index.values])[0].sum() - assert_allclose(tot, 1304152.35) + mat = np.array([refractive_index(i) for i in CRC_RI_organic.index.values]) + Ts = mat[:,1] + # Test refractive index sum + assert_allclose(mat[:,0].sum(), 6602.78821) + # Test temperature sum + assert_allclose(Ts[~np.isnan(Ts)].sum(), 1304152.35) vals = refractive_index(CASRN='64-17-5') assert_allclose(vals, (1.3611, 293.15)) diff --git a/tests/test_temperature.py b/tests/test_temperature.py index 3f83e23f..6f0a3ea0 100644 --- a/tests/test_temperature.py +++ b/tests/test_temperature.py @@ -47,7 +47,7 @@ def test_conversion(): mid_scales = ['ITS-90', 'ITS-68', 'ITS-48'] - for Ti in range(100, 1000, 10): + for Ti in range(100, 1000, 200): for scale1 in mid_scales: for scale2 in mid_scales: T = T_converter(Ti, scale1, scale2) @@ -55,7 +55,7 @@ def test_conversion(): low_scales = ['ITS-90', 'ITS-68', 'ITS-76'] - for Ti in range(15, 27, 1): + for Ti in range(15, 27, 2): for scale1 in low_scales: for scale2 in low_scales: T = T_converter(Ti, scale1, scale2) diff --git a/thermo/__init__.py b/thermo/__init__.py index b8cc5204..8dcd9198 100644 --- a/thermo/__init__.py +++ b/thermo/__init__.py @@ -136,4 +136,4 @@ __all__.extend(volume.__all__) -__version__ = '0.1.24' +__version__ = '0.1.25' diff --git a/thermo/chemical.py b/thermo/chemical.py index 3f1dad62..43da2e39 100644 --- a/thermo/chemical.py +++ b/thermo/chemical.py @@ -635,14 +635,12 @@ def set_constants(self): self.conductivity, self.conductivityT = conductivity(CASRN=self.CAS, Method=self.conductivity_source) def set_eos(self, T, P, eos=PR): - if all((self.Tc, self.Pc, self.omega)): - try: - self.eos = eos(T=T, P=P, Tc=self.Tc, Pc=self.Pc, omega=self.omega) - except: - # Handle overflow errors and so on - self.eos = GCEOS_DUMMY(T=T, P=P) - else: + try: + self.eos = eos(T=T, P=P, Tc=self.Tc, Pc=self.Pc, omega=self.omega) + except: + # Handle overflow errors and so on self.eos = GCEOS_DUMMY(T=T, P=P) + @property def eos(self): r'''Equation of state object held by the chemical; used to calculate diff --git a/thermo/eos.py b/thermo/eos.py index eb9b1e4b..84b0908f 100644 --- a/thermo/eos.py +++ b/thermo/eos.py @@ -841,12 +841,12 @@ def to_TP(self, T, P): class GCEOS_DUMMY(GCEOS): + Tc = None + Pc = None + omega = None def __init__(self, T=None, P=None, **kwargs): self.T = T self.P = P - self.Tc = None - self.Pc = None - self.omega = None # No named parameters class ALPHA_FUNCTIONS(GCEOS):