Skip to content

Commit

Permalink
Added IAPWS Permittivity formulation; and CoolProp dependency in setu…
Browse files Browse the repository at this point in the history
…p.py.
  • Loading branch information
CalebBell committed Jul 18, 2016
1 parent 4b0bc7e commit 125454a
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 17 deletions.
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@
name = 'thermo',
packages = ['thermo'],
license='MIT',
version = '0.1.11',
version = '0.1.12',
description = 'Chemical properties component of Chemical Engineering Design Library (ChEDL)',
author = 'Caleb Bell',
install_requires=['fluids', 'scipy', 'pandas', 'matplotlib'],
install_requires=['fluids', 'scipy', 'pandas', 'matplotlib', 'coolprop'],
extras_require = {
'Coverage documentation': ['wsgiref>=0.1.2', 'coverage>=4.0.3']
},
long_description=open('README.rst').read(),
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.11',
download_url = 'https://github.com/CalebBell/thermo/tarball/0.1.12',
keywords = ['chemical engineering', 'chemistry', 'mechanical engineering',
'thermodynamics', 'databases', 'cheminformatics'],
classifiers = classifiers,
Expand Down
8 changes: 8 additions & 0 deletions tests/test_permittivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ def test_Permittivity_class():
assert_allclose(w.T_dependent_property(200.), 115.79462395999997)
w.tabular_extrapolation_permitted = False
assert None == w.T_dependent_property(200.)


def test_permittivity_IAPWS():
Ts = [238., 256., 273., 273., 323., 323., 373., 373., 510., 523., 614., 647., 673., 673., 773., 773., 873.]
rhos = [975.06, 995.25, 999.83, 1180., 988.10, 1258., 958.46, 1110., 15.832, 900., 94.29, 358., 100., 900., 100., 900., 450.]
permittivity_calc = [permittivity_IAPWS(T, rho) for T, rho in zip(Ts, rhos)]
permittivity_exp = [106.31159697963018, 95.19633650530638, 87.96431108641572, 107.06291112337524, 69.96455480833566, 97.7606839686273, 55.56584297721836, 67.73206302035597, 1.1224589212024803, 32.23229227177932, 1.7702660877662086, 6.194373838662447, 1.7541419715602131, 23.59653593827129, 1.6554135047590008, 20.160449425540186, 6.283091796558804]
assert_allclose(permittivity_calc, permittivity_exp)
22 changes: 11 additions & 11 deletions thermo/dippr.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def EQ100(T, A=0, B=0, C=0, D=0, E=0, F=0, G=0):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -81,7 +81,7 @@ def EQ101(T, A, B, C, D, E):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -117,7 +117,7 @@ def EQ102(T, A, B, C, D):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -152,7 +152,7 @@ def EQ104(T, A, B, C, D, E):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -187,7 +187,7 @@ def EQ105(T, A, B, C, D):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -227,7 +227,7 @@ def EQ106(T, Tc, A, B, C=0, D=0, E=0):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -264,7 +264,7 @@ def EQ107(T, A=0, B=0, C=0, D=0, E=0):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -309,7 +309,7 @@ def EQ114(T, Tc, A, B, C, D):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -345,7 +345,7 @@ def EQ115(T, A, B, C=0, D=0, E=0):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -381,7 +381,7 @@ def EQ116(T, Tc, A, B, C, D, E):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down Expand Up @@ -421,7 +421,7 @@ def EQ127(T, A, B, C, D, E, F, G):
Returns
-------
Y: float
Y : float
Property [constant-specific]
Examples
Expand Down
8 changes: 5 additions & 3 deletions thermo/heat_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ class HeatCapacityGas(TDependentProperty):
property_min = 0
'''Heat capacities have a minimum value of 0 at 0 K.'''
property_max = 1E4
'''Maximum valid of Heat capacity; arbitrarily set.'''
'''Maximum valid of Heat capacity; arbitrarily set. For fluids very near
the critical point, this value can be obscenely high.'''


ranked_methods = [TRCIG, POLING, COOLPROP, LASTOVKA_SHAW, CRCSTD, POLING_CONST, VDI_TABULAR]
Expand Down Expand Up @@ -967,8 +968,9 @@ class HeatCapacityLiquid(TDependentProperty):
property_min = 1
'''Allow very low heat capacities; arbitrarily set; liquid heat capacity
should always be somewhat substantial.'''
property_max = 1E4
'''Maximum valid of Heat capacity; arbitrarily set.'''
property_max = 1E4 # Originally 1E4
'''Maximum valid of Heat capacity; arbitrarily set. For fluids very near
the critical point, this value can be obscenely high.'''


ranked_methods = [ZABRANSKY_SPLINE, ZABRANSKY_QUASIPOLYNOMIAL,
Expand Down
86 changes: 86 additions & 0 deletions thermo/permittivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from __future__ import division
import os
import numpy as np
from scipy.constants import N_A, epsilon_0, k
import pandas as pd
from thermo.utils import TDependentProperty

Expand All @@ -34,6 +35,91 @@
_CRC_Permittivity_data_values = CRC_Permittivity_data.values


def permittivity_IAPWS(T, rho):
r'''Calculate the relative permittivity of pure water as a function of.
temperature and density. Assumes the 1997 IAPWS [1]_ formulation.
.. math::
\epsilon(\rho, T) =\frac{1 + A + 5B + (9 + 2A + 18B + A^2 + 10AB +
9B^2)^{0.5}}{4(1-B)}
A(\rho, T) = \frac{N_A\mu^2\rho g}{M\epsilon_0 kT}
B(\rho) = \frac{N_A\alpha\rho}{3M\epsilon_0}
g(\delta,\tau) = 1 + \sum_{i=1}^{11}n_i\delta^{I_i}\tau^{J_i}
+ n_{12}\delta\left(\frac{647.096}{228}\tau^{-1} - 1\right)^{-1.2}
\delta = \rho/(322 \text{ kg/m}^3)
\tau = T/647.096\text{K}
Parameters
----------
T : float
Temperature of water [K]
rho : float
Mass density of water at T and P [kg/m^3]
Returns
-------
epsilon : float
Relative permittivity of water at T and rho, [-]
Notes
-----
Validity:
273.15 < T < 323.15 K for 0 < P < iceVI melting pressure at T or 1000 MPa,
whichever is smaller.
323.15 < T < 873.15 K 0 < p < 600 MPa.
Coefficients:
ih = [1, 1, 1, 2, 3, 3, 4, 5, 6, 7, 10];
jh = [0.25, 1, 2.5, 1.5, 1.5, 2.5, 2, 2, 5, 0.5, 10];
Nh = [0.978224486826, -0.957771379375, 0.237511794148, 0.714692244396,
-0.298217036956, -0.108863472196, 0.949327488264E-1,
-.980469816509E-2, 0.165167634970E-4, 0.937359795772E-4,
-0.12317921872E-9];
polarizability = 1.636E-40
dipole = 6.138E-30
Examples
--------
>>> permittivity_IAPWS(373., 958.46)
55.56584297721836
References
----------
.. [1] IAPWS. 1997. Release on the Static Dielectric Constant of Ordinary
Water Substance for Temperatures from 238 K to 873 K and Pressures up
to 1000 MPa.
'''
dipole = 6.138E-30 # actual molecular dipole moment of water, in C*m
polarizability = 1.636E-40 # actual mean molecular polarizability of water, C^2/J*m^2
MW = 0.018015268 # molecular weight of water, kg/mol
ih = [1, 1, 1, 2, 3, 3, 4, 5, 6, 7, 10]
jh = [0.25, 1, 2.5, 1.5, 1.5, 2.5, 2, 2, 5, 0.5, 10]
Nh = [0.978224486826, -0.957771379375, 0.237511794148, 0.714692244396,
-0.298217036956, -0.108863472196, 0.949327488264E-1,
-.980469816509E-2, 0.165167634970E-4, 0.937359795772E-4,
-0.12317921872E-9]

delta = rho/322.
tau = 647.096/T

g = (1 + sum([Nh[h]*delta**ih[h]*tau**jh[h] for h in range(11)])
+ 0.196096504426E-2*delta*(T/228. - 1)**-1.2)

A = N_A*dipole**2*(rho/MW)*g/epsilon_0/k/T
B = N_A*polarizability*(rho/MW)/3./epsilon_0
epsilon = (1. + A + 5.*B + (9. + 2.*A + 18.*B + A**2 + 10.*A*B + 9.*B**2
)**0.5)/(4. - 4.*B)
return epsilon


CRC = 'CRC Handbook polynomials'
CRC_CONSTANT = 'CRC Handbook constant'
permittivity_methods = [CRC, CRC_CONSTANT]
Expand Down

0 comments on commit 125454a

Please sign in to comment.