Skip to content

Commit

Permalink
Version 0.1.25 release
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebBell committed Feb 9, 2017
1 parent 3a0b141 commit 846f895
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions tests/test_eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
12 changes: 7 additions & 5 deletions tests/test_refractivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@
from numpy.testing import assert_allclose
import pytest
import pandas as pd
import numpy as np
from thermo.refractivity import *

def test_refractivity_CRC():
assert_allclose(CRC_RI_organic['RI'].sum(), 6602.78821)
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))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ 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)
assert_allclose(T_converter(T, scale2, scale1), Ti, rtol=1e-6)

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)
Expand Down
2 changes: 1 addition & 1 deletion thermo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@
__all__.extend(volume.__all__)


__version__ = '0.1.24'
__version__ = '0.1.25'
12 changes: 5 additions & 7 deletions thermo/chemical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions thermo/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 846f895

Please sign in to comment.