Search is not available for this dataset
text stringlengths 75 104k |
|---|
def ionic_strength(mis, zis):
r'''Calculate the ionic strength of a solution in one of two ways,
depending on the inputs only. For Pitzer and Bromley models,
`mis` should be molalities of each component. For eNRTL models,
`mis` should be mole fractions of each electrolyte in the solution.
This will sum to be much less than 1.
.. math::
I = \frac{1}{2} \sum M_i z_i^2
I = \frac{1}{2} \sum x_i z_i^2
Parameters
----------
mis : list
Molalities of each ion, or mole fractions of each ion [mol/kg or -]
zis : list
Charges of each ion [-]
Returns
-------
I : float
ionic strength, [?]
Examples
--------
>>> ionic_strength([0.1393, 0.1393], [1, -1])
0.1393
References
----------
.. [1] Chen, Chau-Chyun, H. I. Britt, J. F. Boston, and L. B. Evans. "Local
Composition Model for Excess Gibbs Energy of Electrolyte Systems.
Part I: Single Solvent, Single Completely Dissociated Electrolyte
Systems." AIChE Journal 28, no. 4 (July 1, 1982): 588-96.
doi:10.1002/aic.690280410
.. [2] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation.
Weinheim, Germany: Wiley-VCH, 2012.
'''
return 0.5*sum([mi*zi*zi for mi, zi in zip(mis, zis)]) |
def Kweq_1981(T, rho_w):
r'''Calculates equilibrium constant for OH- and H+ in water, according to
[1]_. Second most recent formulation.
.. math::
\log_{10} K_w= A + B/T + C/T^2 + D/T^3 + (E+F/T+G/T^2)\log_{10} \rho_w
Parameters
----------
T : float
Temperature of fluid [K]
rho_w : float
Density of water, [kg/m^3]
Returns
-------
Kweq : float
Ionization constant of water, [-]
Notes
-----
Density is internally converted to units of g/cm^3.
A = -4.098;
B = -3245.2;
C = 2.2362E5;
D = -3.984E7;
E = 13.957;
F = -1262.3;
G = 8.5641E5
Examples
--------
>>> -1*log10(Kweq_1981(600, 700))
11.274522047458206
References
----------
.. [1] Marshall, William L., and E. U. Franck. "Ion Product of Water
Substance, 0-1000 degree C, 1010,000 Bars New International Formulation
and Its Background." Journal of Physical and Chemical Reference Data 10,
no. 2 (April 1, 1981): 295-304. doi:10.1063/1.555643.
'''
rho_w = rho_w/1000.
A = -4.098
B = -3245.2
C = 2.2362E5
D = -3.984E7
E = 13.957
F = -1262.3
G = 8.5641E5
return 10**(A + B/T + C/T**2 + D/T**3 + (E + F/T + G/T**2)*log10(rho_w)) |
def Kweq_IAPWS_gas(T):
r'''Calculates equilibrium constant for OH- and H+ in water vapor,
according to [1]_.
This is the most recent formulation available.
.. math::
-log_{10} K_w^G = \gamma_0 + \gamma_1 T^{-1} + \gamma_2 T^{-2} + \gamma_3 T^{-3}
Parameters
----------
T : float
Temperature of H2O [K]
Returns
-------
K_w_G : float
Notes
-----
gamma0 = 6.141500E-1;
gamma1 = 4.825133E4;
gamma2 = -6.770793E4;
gamma3 = 1.010210E7
Examples
--------
>>> Kweq_IAPWS_gas(800)
1.4379721554798815e-61
References
----------
.. [1] Bandura, Andrei V., and Serguei N. Lvov. "The Ionization Constant
of Water over Wide Ranges of Temperature and Density." Journal of Physical
and Chemical Reference Data 35, no. 1 (March 1, 2006): 15-30.
doi:10.1063/1.1928231
'''
gamma0 = 6.141500E-1
gamma1 = 4.825133E4
gamma2 = -6.770793E4
gamma3 = 1.010210E7
K_w_G = 10**(-1*(gamma0 + gamma1/T + gamma2/T**2 + gamma3/T**3))
return K_w_G |
def Kweq_IAPWS(T, rho_w):
r'''Calculates equilibrium constant for OH- and H+ in water, according to
[1]_.
This is the most recent formulation available.
.. math::
Q = \rho \exp(\alpha_0 + \alpha_1 T^{-1} + \alpha_2 T^{-2} \rho^{2/3})
- \log_{10} K_w = -2n \left[ \log_{10}(1+Q) - \frac{Q}{Q+1} \rho
(\beta_0 + \beta_1 T^{-1} + \beta_2 \rho) \right]
-\log_{10} K_w^G + 2 \log_{10} \frac{18.015268}{1000}
Parameters
----------
T : float
Temperature of water [K]
rho_w : float
Density of water at temperature and pressure [kg/m^3]
Returns
-------
Kweq : float
Ionization constant of water, [-]
Notes
-----
Formulation is in terms of density in g/cm^3; density
is converted internally.
n = 6;
alpha0 = -0.864671;
alpha1 = 8659.19;
alpha2 = -22786.2;
beta0 = 0.642044;
beta1 = -56.8534;
beta2 = -0.375754
Examples
--------
Example from IAPWS check:
>>> -1*log10(Kweq_IAPWS(600, 700))
11.203153057603775
References
----------
.. [1] Bandura, Andrei V., and Serguei N. Lvov. "The Ionization Constant
of Water over Wide Ranges of Temperature and Density." Journal of Physical
and Chemical Reference Data 35, no. 1 (March 1, 2006): 15-30.
doi:10.1063/1.1928231
'''
K_w_G = Kweq_IAPWS_gas(T)
rho_w = rho_w/1000.
n = 6
alpha0 = -0.864671
alpha1 = 8659.19
alpha2 = -22786.2
beta0 = 0.642044
beta1 = -56.8534
beta2 = -0.375754
Q = rho_w*exp(alpha0 + alpha1/T + alpha2/T**2*rho_w**(2/3.))
K_w = 10**(-1*(-2*n*(log10(1+Q)-Q/(Q+1) * rho_w *(beta0 + beta1/T + beta2*rho_w)) -
log10(K_w_G) + 2*log10(18.015268/1000) ))
return K_w |
def ion_balance_proportional(anion_charges, cation_charges, zs, n_anions,
n_cations, balance_error, method):
'''Helper method for balance_ions for the proportional family of methods.
See balance_ions for a description of the methods; parameters are fairly
obvious.
'''
anion_zs = zs[0:n_anions]
cation_zs = zs[n_anions:n_cations+n_anions]
anion_balance_error = sum([zi*ci for zi, ci in zip(anion_zs, anion_charges)])
cation_balance_error = sum([zi*ci for zi, ci in zip(cation_zs, cation_charges)])
if method == 'proportional insufficient ions increase':
if balance_error < 0:
multiplier = -anion_balance_error/cation_balance_error
cation_zs = [i*multiplier for i in cation_zs]
else:
multiplier = -cation_balance_error/anion_balance_error
anion_zs = [i*multiplier for i in anion_zs]
elif method == 'proportional excess ions decrease':
if balance_error < 0:
multiplier = -cation_balance_error/anion_balance_error
anion_zs = [i*multiplier for i in anion_zs]
else:
multiplier = -anion_balance_error/cation_balance_error
cation_zs = [i*multiplier for i in cation_zs]
elif method == 'proportional cation adjustment':
multiplier = -anion_balance_error/cation_balance_error
cation_zs = [i*multiplier for i in cation_zs]
elif method == 'proportional anion adjustment':
multiplier = -cation_balance_error/anion_balance_error
anion_zs = [i*multiplier for i in anion_zs]
else:
raise Exception('Allowable methods are %s' %charge_balance_methods)
z_water = 1. - sum(anion_zs) - sum(cation_zs)
return anion_zs, cation_zs, z_water |
def balance_ions(anions, cations, anion_zs=None, cation_zs=None,
anion_concs=None, cation_concs=None, rho_w=997.1,
method='increase dominant', selected_ion=None):
r'''Performs an ion balance to adjust measured experimental ion
compositions to electroneutrality. Can accept either the actual mole
fractions of the ions, or their concentrations in units of [mg/L] as well
for convinience.
The default method will locate the most prevalent ion in the type of
ion not in excess - and increase it until the two ion types balance.
Parameters
----------
anions : list(ChemicalMetadata)
List of all negatively charged ions measured as being in the solution;
ChemicalMetadata instances or simply objects with the attributes `MW`
and `charge`, [-]
cations : list(ChemicalMetadata)
List of all positively charged ions measured as being in the solution;
ChemicalMetadata instances or simply objects with the attributes `MW`
and `charge`, [-]
anion_zs : list, optional
Mole fractions of each anion as measured in the aqueous solution, [-]
cation_zs : list, optional
Mole fractions of each cation as measured in the aqueous solution, [-]
anion_concs : list, optional
Concentrations of each anion in the aqueous solution in the units often
reported (for convinience only) [mg/L]
cation_concs : list, optional
Concentrations of each cation in the aqueous solution in the units
often reported (for convinience only) [mg/L]
rho_w : float, optional
Density of the aqueous solutionr at the temperature and pressure the
anion and cation concentrations were measured (if specified), [kg/m^3]
method : str, optional
The method to use to balance the ionimbalance; one of 'dominant',
'decrease dominant', 'increase dominant',
'proportional insufficient ions increase',
'proportional excess ions decrease',
'proportional cation adjustment', 'proportional anion adjustment',
'Na or Cl increase', 'Na or Cl decrease', 'adjust', 'increase',
'decrease', 'makeup'].
selected_ion : ChemicalMetadata, optional
Some methods adjust only one user-specified ion; this is that input.
For the case of the 'makeup' method, this is a tuple of (anion, cation)
ChemicalMetadata instances and only the ion type not in excess will be
used.
Returns
-------
anions : list(ChemicalMetadata)
List of all negatively charged ions measured as being in the solution;
ChemicalMetadata instances after potentially adding in an ion which
was not present but specified by the user, [-]
cations : list(ChemicalMetadata)
List of all positively charged ions measured as being in the solution;
ChemicalMetadata instances after potentially adding in an ion which
was not present but specified by the user, [-]
anion_zs : list,
Mole fractions of each anion in the aqueous solution after the charge
balance, [-]
cation_zs : list
Mole fractions of each cation in the aqueous solution after the charge
balance, [-]
z_water : float
Mole fraction of the water in the solution, [-]
Notes
-----
The methods perform the charge balance as follows:
* 'dominant' : The ion with the largest mole fraction in solution has its
concentration adjusted up or down as necessary to balance the solution.
* 'decrease dominant' : The ion with the largest mole fraction in the type
of ion with *excess* charge has its own mole fraction decreased to balance
the solution.
* 'increase dominant' : The ion with the largest mole fraction in the type
of ion with *insufficient* charge has its own mole fraction decreased to
balance the solution.
* 'proportional insufficient ions increase' : The ion charge type which is
present insufficiently has each of the ions mole fractions *increased*
proportionally until the solution is balanced.
* 'proportional excess ions decrease' : The ion charge type which is
present in excess has each of the ions mole fractions *decreased*
proportionally until the solution is balanced.
* 'proportional cation adjustment' : All *cations* have their mole fractions
increased or decreased proportionally as necessary to balance the
solution.
* 'proportional anion adjustment' : All *anions* have their mole fractions
increased or decreased proportionally as necessary to balance the
solution.
* 'Na or Cl increase' : Either Na+ or Cl- is *added* to the solution until
the solution is balanced; the species will be added if they were not
present initially as well.
* 'Na or Cl decrease' : Either Na+ or Cl- is *removed* from the solution
until the solution is balanced; the species will be added if they were
not present initially as well.
* 'adjust' : An ion specified with the parameter `selected_ion` has its
mole fraction *increased or decreased* as necessary to balance the
solution. An exception is raised if the specified ion alone cannot
balance the solution.
* 'increase' : An ion specified with the parameter `selected_ion` has its
mole fraction *increased* as necessary to balance the
solution. An exception is raised if the specified ion alone cannot
balance the solution.
* 'decrease' : An ion specified with the parameter `selected_ion` has its
mole fraction *decreased* as necessary to balance the
solution. An exception is raised if the specified ion alone cannot
balance the solution.
* 'makeup' : Two ions ase specified as a tuple with the parameter
`selected_ion`. Whichever ion type is present in the solution
insufficiently is added; i.e. if the ions were Mg+2 and Cl-, and there
was too much negative charge in the solution, Mg+2 would be added until
the solution was balanced.
Examples
--------
>>> anions_n = ['Cl-', 'HCO3-', 'SO4-2']
>>> cations_n = ['Na+', 'K+', 'Ca+2', 'Mg+2']
>>> cations = [pubchem_db.search_name(i) for i in cations_n]
>>> anions = [pubchem_db.search_name(i) for i in anions_n]
>>> an_res, cat_res, an_zs, cat_zs, z_water = balance_ions(anions, cations,
... anion_zs=[0.02557, 0.00039, 0.00026], cation_zs=[0.0233, 0.00075,
... 0.00262, 0.00119], method='proportional excess ions decrease')
>>> an_zs
[0.02557, 0.00039, 0.00026]
>>> cat_zs
[0.01948165456267761, 0.0006270918850647299, 0.0021906409851594564, 0.0009949857909693717]
>>> z_water
0.9504856267761288
References
----------
'''
anions = list(anions)
cations = list(cations)
n_anions = len(anions)
n_cations = len(cations)
ions = anions + cations
anion_charges = [i.charge for i in anions]
cation_charges = [i.charge for i in cations]
charges = anion_charges + cation_charges + [0]
MW_water = [18.01528]
rho_w = rho_w/1000 # Convert to kg/liter
if anion_concs is not None and cation_concs is not None:
anion_ws = [i*1E-6/rho_w for i in anion_concs]
cation_ws = [i*1E-6/rho_w for i in cation_concs]
w_water = 1 - sum(anion_ws) - sum(cation_ws)
anion_MWs = [i.MW for i in anions]
cation_MWs = [i.MW for i in cations]
MWs = anion_MWs + cation_MWs + MW_water
zs = ws_to_zs(anion_ws + cation_ws + [w_water], MWs)
else:
if anion_zs is None or cation_zs is None:
raise Exception('Either both of anion_concs and cation_concs or '
'anion_zs and cation_zs must be specified.')
else:
zs = anion_zs + cation_zs
zs = zs + [1 - sum(zs)]
impacts = [zi*ci for zi, ci in zip(zs, charges)]
balance_error = sum(impacts)
if abs(balance_error) < 1E-7:
anion_zs = zs[0:n_anions]
cation_zs = zs[n_anions:n_cations+n_anions]
z_water = zs[-1]
return anions, cations, anion_zs, cation_zs, z_water
if 'dominant' in method:
anion_zs, cation_zs, z_water = ion_balance_dominant(impacts,
balance_error, charges, zs, n_anions, n_cations, method)
return anions, cations, anion_zs, cation_zs, z_water
elif 'proportional' in method:
anion_zs, cation_zs, z_water = ion_balance_proportional(
anion_charges, cation_charges, zs, n_anions, n_cations,
balance_error, method)
return anions, cations, anion_zs, cation_zs, z_water
elif method == 'Na or Cl increase':
increase = True
if balance_error < 0:
selected_ion = pubchem_db.search_name('Na+')
else:
selected_ion = pubchem_db.search_name('Cl-')
elif method == 'Na or Cl decrease':
increase = False
if balance_error > 0:
selected_ion = pubchem_db.search_name('Na+')
else:
selected_ion = pubchem_db.search_name('Cl-')
# All of the below work with the variable selected_ion
elif method == 'adjust':
# A single ion will be increase or decreased to fix the balance automatically
increase = None
elif method == 'increase':
increase = True
# Raise exception if approach doesn't work
elif method == 'decrease':
increase = False
# Raise exception if approach doesn't work
elif method == 'makeup':
# selected ion starts out as a tuple in this case; always adding the compound
increase = True
if balance_error < 0:
selected_ion = selected_ion[1]
else:
selected_ion = selected_ion[0]
else:
raise Exception('Method not recognized')
if selected_ion is None:
raise Exception("For methods 'adjust', 'increase', 'decrease', and "
"'makeup', an ion must be specified with the "
"`selected_ion` parameter")
anion_zs, cation_zs, z_water = ion_balance_adjust_wrapper(charges, zs, n_anions, n_cations,
anions, cations, selected_ion, increase=increase)
return anions, cations, anion_zs, cation_zs, z_water |
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 |
def load_all_methods(self):
r'''Method which picks out coefficients for the specified chemical
from the various dictionaries and DataFrames storing it. All data is
stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`,
and :obj:`all_methods` as a set of methods for which the data exists for.
Called on initialization only. See the source code for the variables at
which the coefficients are stored. The coefficients can safely be
altered once the class is initialized. This method can be called again
to reset the parameters.
'''
methods = []
Tmins, Tmaxs = [], []
if self.CASRN in CRC_Permittivity_data.index:
methods.append(CRC_CONSTANT)
_, self.CRC_CONSTANT_T, self.CRC_permittivity, A, B, C, D, Tmin, Tmax = _CRC_Permittivity_data_values[CRC_Permittivity_data.index.get_loc(self.CASRN)].tolist()
self.CRC_Tmin = Tmin
self.CRC_Tmax = Tmax
self.CRC_coeffs = [0 if np.isnan(x) else x for x in [A, B, C, D] ]
if not np.isnan(Tmin):
Tmins.append(Tmin); Tmaxs.append(Tmax)
if self.CRC_coeffs[0]:
methods.append(CRC)
self.all_methods = set(methods)
if Tmins and Tmaxs:
self.Tmin = min(Tmins)
self.Tmax = max(Tmaxs) |
def calculate(self, T, method):
r'''Method to calculate permittivity of a liquid at temperature `T`
with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature at which to calculate relative permittivity, [K]
method : str
Name of the method to use
Returns
-------
epsilon : float
Relative permittivity of the liquid at T, [-]
'''
if method == CRC:
A, B, C, D = self.CRC_coeffs
epsilon = A + B*T + C*T**2 + D*T**3
elif method == CRC_CONSTANT:
epsilon = self.CRC_permittivity
elif method in self.tabular_data:
epsilon = self.interpolate(T, method)
return epsilon |
def Hcombustion(atoms, Hf=None, HfH2O=-285825, HfCO2=-393474,
HfSO2=-296800, HfBr2=30880, HfI2=62417, HfHCl=-92173,
HfHF=-272711, HfP4O10=-3009940, HfO2=0, HfN2=0):
'''Calculates the heat of combustion, in J/mol.
Value non-hydrocarbons is not correct, but still calculable.
Parameters
----------
atoms : dict
Dictionary of atoms and their counts, []
Hf : float
Heat of formation of given chemical, [J/mol]
HfH2O : float, optional
Heat of formation of water, [J/mol]
HfCO2 : float, optional
Heat of formation of carbon dioxide, [J/mol]
HfSO2 : float, optional
Heat of formation of sulfur dioxide, [J/mol]
HfBr2 : float, optional
Heat of formation of bromine, [J/mol]
HfI2 : float, optional
Heat of formation of iodine, [J/mol]
HfHCl : float, optional
Heat of formation of chlorine, [J/mol]
HfHF : float, optional
Heat of formation of hydrogen fluoride, [J/mol]
HfP4O10 : float, optional
Heat of formation of phosphorus pentoxide, [J/mol]
HfO2 : float, optional
Heat of formation of oxygen, [J/mol]
HfN2 : float, optional
Heat of formation of nitrogen, [J/mol]
Returns
-------
Hc : float
Heat of combustion of chemical, [J/mol]
Notes
-----
Default heats of formation for chemicals are at 298 K, 1 atm.
Examples
--------
Liquid methanol burning
>>> Hcombustion({'H': 4, 'C': 1, 'O': 1}, Hf=-239100)
-726024.0
'''
if not Hf or not atoms:
return None
nC, nH, nN, nO, nS, nBr, nI, nCl, nF, nP = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
if 'C' in atoms and atoms['C'] != 0:
nC = atoms['C']
else:
return None # C is necessary for this formula
if 'H' in atoms:
nH = atoms['H']
if 'N' in atoms:
nN = atoms['N']
if 'O' in atoms:
nO = atoms['O']
if 'S' in atoms:
nS = atoms['S']
if 'Br' in atoms:
nBr = atoms['Br']
if 'I' in atoms:
nI = atoms['I']
if 'Cl' in atoms:
nCl = atoms['Cl']
if 'F' in atoms:
nF = atoms['F']
if 'P' in atoms:
nP = atoms['P']
nO2_req = nC + nS + nH/4. + 5*nP/4. - (nCl + nF)/4. - nO/2.
nCO2 = nC
nBr2 = nBr/2.
nI2 = nI/2.
nHCl = nCl
nHF = nF
nSO2 = nS
nN2 = nN/2.
nP4O10 = nP/4.
nH2O = (nH - nCl - nF)/2.
Hc = (nBr2*HfBr2 + nI2*HfI2) + (nHCl*HfHCl + nHF*HfHF) + nSO2*HfSO2 + \
nN2*HfN2 + nP4O10*HfP4O10 + nH2O*HfH2O - nO2_req*HfO2 + nCO2*HfCO2 - Hf
return Hc |
def REFPROP(T, Tc, sigma0, n0, sigma1=0, n1=0, sigma2=0, n2=0):
r'''Calculates air-liquid surface tension using the REFPROP [1]_
regression-based method. Relatively recent, and most accurate.
.. math::
\sigma(T)=\sigma_0\left(1-\frac{T}{T_c}\right)^{n_0}+
\sigma_1\left(1-\frac{T}{T_c}\right)^{n_1}+
\sigma_2\left(1-\frac{T}{T_c}\right)^{n_2}
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
sigma0 : float
First emperical coefficient of a fluid
n0 : float
First emperical exponent of a fluid
sigma1 : float, optional
Second emperical coefficient of a fluid.
n1 : float, optional
Second emperical exponent of a fluid.
sigma1 : float, optional
Third emperical coefficient of a fluid.
n2 : float, optional
Third emperical exponent of a fluid.
Returns
-------
sigma : float
Liquid surface tension, N/m
Notes
-----
Function as implemented in [1]_. No example necessary; results match
literature values perfectly.
Form of function returns imaginary results when T > Tc; None is returned
if this is the case.
Examples
--------
Parameters for water at 298.15 K
>>> REFPROP(298.15, 647.096, -0.1306, 2.471, 0.2151, 1.233)
0.07205503890847453
References
----------
.. [1] Diky, Vladimir, Robert D. Chirico, Chris D. Muzny, Andrei F.
Kazakov, Kenneth Kroenlein, Joseph W. Magee, Ilmutdin Abdulagatov, and
Michael Frenkel. "ThermoData Engine (TDE): Software Implementation of
the Dynamic Data Evaluation Concept." Journal of Chemical Information
and Modeling 53, no. 12 (2013): 3418-30. doi:10.1021/ci4005699.
'''
Tr = T/Tc
sigma = sigma0*(1.-Tr)**n0 + sigma1*(1.-Tr)**n1 + sigma2*(1.-Tr)**n2
return sigma |
def Somayajulu(T, Tc, A, B, C):
r'''Calculates air-water surface tension using the [1]_
emperical (parameter-regressed) method. Well regressed, no recent data.
.. math::
\sigma=aX^{5/4}+bX^{9/4}+cX^{13/4}
X=(T_c-T)/T_c
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
A : float
Regression parameter
B : float
Regression parameter
C : float
Regression parameter
Returns
-------
sigma : float
Liquid surface tension, N/m
Notes
-----
Presently untested, but matches expected values. Internal units are mN/m.
Form of function returns imaginary results when T > Tc; None is returned
if this is the case. Function is claimed valid from the triple to the
critical point. Results can be evaluated beneath the triple point.
Examples
--------
Water at 300 K
>>> Somayajulu(300, 647.126, 232.713514, -140.18645, -4.890098)
0.07166386387996757
References
----------
.. [1] Somayajulu, G. R. "A Generalized Equation for Surface Tension from
the Triple Point to the Critical Point." International Journal of
Thermophysics 9, no. 4 (July 1988): 559-66. doi:10.1007/BF00503154.
'''
X = (Tc-T)/Tc
sigma = (A*X**1.25 + B*X**2.25 + C*X**3.25)/1000.
return sigma |
def Brock_Bird(T, Tb, Tc, Pc):
r'''Calculates air-water surface tension using the [1]_
emperical method. Old and tested.
.. math::
\sigma = P_c^{2/3}T_c^{1/3}Q(1-T_r)^{11/9}
Q = 0.1196 \left[ 1 + \frac{T_{br}\ln (P_c/1.01325)}{1-T_{br}}\right]-0.279
Parameters
----------
T : float
Temperature of fluid [K]
Tb : float
Boiling temperature of the fluid [K]
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
Returns
-------
sigma : float
Liquid surface tension, N/m
Notes
-----
Numerous arrangements of this equation are available.
This is DIPPR Procedure 7A: Method for the Surface Tension of Pure,
Nonpolar, Nonhydrocarbon Liquids
The exact equation is not in the original paper.
If the equation yields a negative result, return None.
Examples
--------
p-dichloribenzene at 412.15 K, from DIPPR; value differs due to a slight
difference in method.
>>> Brock_Bird(412.15, 447.3, 685, 3.952E6)
0.02208448325192495
Chlorobenzene from Poling, as compared with a % error value at 293 K.
>>> Brock_Bird(293.15, 404.75, 633.0, 4530000.0)
0.032985686413713036
References
----------
.. [1] Brock, James R., and R. Byron Bird. "Surface Tension and the
Principle of Corresponding States." AIChE Journal 1, no. 2
(June 1, 1955): 174-77. doi:10.1002/aic.690010208
'''
Tbr = Tb/Tc
Tr = T/Tc
Pc = Pc/1E5 # Convert to bar
Q = 0.1196*(1 + Tbr*log(Pc/1.01325)/(1-Tbr))-0.279
sigma = (Pc)**(2/3.)*Tc**(1/3.)*Q*(1-Tr)**(11/9.)
sigma = sigma/1000 # convert to N/m
return sigma |
def Pitzer(T, Tc, Pc, omega):
r'''Calculates air-water surface tension using the correlation derived
by [1]_ from the works of [2]_ and [3]_. Based on critical property CSP
methods.
.. math::
\sigma = P_c^{2/3}T_c^{1/3}\frac{1.86 + 1.18\omega}{19.05}
\left[ \frac{3.75 + 0.91 \omega}{0.291 - 0.08 \omega}\right]^{2/3} (1-T_r)^{11/9}
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
omega : float
Acentric factor for fluid, [-]
Returns
-------
sigma : float
Liquid surface tension, N/m
Notes
-----
The source of this equation has not been reviewed.
Internal units of presure are bar, surface tension of mN/m.
Examples
--------
Chlorobenzene from Poling, as compared with a % error value at 293 K.
>>> Pitzer(293., 633.0, 4530000.0, 0.249)
0.03458453513446387
References
----------
.. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
New York: McGraw-Hill Professional, 2000.
.. [2] Curl, R. F., and Kenneth Pitzer. "Volumetric and Thermodynamic
Properties of Fluids-Enthalpy, Free Energy, and Entropy." Industrial &
Engineering Chemistry 50, no. 2 (February 1, 1958): 265-74.
doi:10.1021/ie50578a047
.. [3] Pitzer, K. S.: Thermodynamics, 3d ed., New York, McGraw-Hill,
1995, p. 521.
'''
Tr = T/Tc
Pc = Pc/1E5 # Convert to bar
sigma = Pc**(2/3.0)*Tc**(1/3.0)*(1.86+1.18*omega)/19.05 * (
(3.75+0.91*omega)/(0.291-0.08*omega))**(2/3.0)*(1-Tr)**(11/9.0)
sigma = sigma/1000 # N/m, please
return sigma |
def Sastri_Rao(T, Tb, Tc, Pc, chemicaltype=None):
r'''Calculates air-water surface tension using the correlation derived by
[1]_ based on critical property CSP methods and chemical classes.
.. math::
\sigma = K P_c^xT_b^y T_c^z\left[\frac{1-T_r}{1-T_{br}}\right]^m
Parameters
----------
T : float
Temperature of fluid [K]
Tb : float
Boiling temperature of the fluid [K]
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
Returns
-------
sigma : float
Liquid surface tension, N/m
Notes
-----
The source of this equation has not been reviewed.
Internal units of presure are bar, surface tension of mN/m.
Examples
--------
Chlorobenzene from Poling, as compared with a % error value at 293 K.
>>> Sastri_Rao(293.15, 404.75, 633.0, 4530000.0)
0.03234567739694441
References
----------
.. [1] Sastri, S. R. S., and K. K. Rao. "A Simple Method to Predict
Surface Tension of Organic Liquids." The Chemical Engineering Journal
and the Biochemical Engineering Journal 59, no. 2 (October 1995): 181-86.
doi:10.1016/0923-0467(94)02946-6.
'''
if chemicaltype == 'alcohol':
k, x, y, z, m = 2.28, 0.25, 0.175, 0, 0.8
elif chemicaltype == 'acid':
k, x, y, z, m = 0.125, 0.50, -1.5, 1.85, 11/9.0
else:
k, x, y, z, m = 0.158, 0.50, -1.5, 1.85, 11/9.0
Tr = T/Tc
Tbr = Tb/Tc
Pc = Pc/1E5 # Convert to bar
sigma = k*Pc**x*Tb**y*Tc**z*((1 - Tr)/(1 - Tbr))**m
sigma = sigma/1000 # N/m
return sigma |
def Zuo_Stenby(T, Tc, Pc, omega):
r'''Calculates air-water surface tension using the reference fluids
methods of [1]_.
.. math::
\sigma^{(1)} = 40.520(1-T_r)^{1.287}
\sigma^{(2)} = 52.095(1-T_r)^{1.21548}
\sigma_r = \sigma_r^{(1)}+ \frac{\omega - \omega^{(1)}}
{\omega^{(2)}-\omega^{(1)}} (\sigma_r^{(2)}-\sigma_r^{(1)})
\sigma = T_c^{1/3}P_c^{2/3}[\exp{(\sigma_r)} -1]
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
omega : float
Acentric factor for fluid, [-]
Returns
-------
sigma : float
Liquid surface tension, N/m
Notes
-----
Presently untested. Have not personally checked the sources.
I strongly believe it is broken.
The reference values for methane and n-octane are from the DIPPR database.
Examples
--------
Chlorobenzene
>>> Zuo_Stenby(293., 633.0, 4530000.0, 0.249)
0.03345569011871088
References
----------
.. [1] Zuo, You-Xiang, and Erling H. Stenby. "Corresponding-States and
Parachor Models for the Calculation of Interfacial Tensions." The
Canadian Journal of Chemical Engineering 75, no. 6 (December 1, 1997):
1130-37. doi:10.1002/cjce.5450750617
'''
Tc_1, Pc_1, omega_1 = 190.56, 4599000.0/1E5, 0.012
Tc_2, Pc_2, omega_2 = 568.7, 2490000.0/1E5, 0.4
Pc = Pc/1E5
def ST_r(ST, Tc, Pc):
return log(1 + ST/(Tc**(1/3.0)*Pc**(2/3.0)))
ST_1 = 40.520*(1 - T/Tc)**1.287 # Methane
ST_2 = 52.095*(1 - T/Tc)**1.21548 # n-octane
ST_r_1, ST_r_2 = ST_r(ST_1, Tc_1, Pc_1), ST_r(ST_2, Tc_2, Pc_2)
sigma_r = ST_r_1 + (omega-omega_1)/(omega_2 - omega_1)*(ST_r_2-ST_r_1)
sigma = Tc**(1/3.0)*Pc**(2/3.0)*(exp(sigma_r)-1)
sigma = sigma/1000 # N/m, please
return sigma |
def Hakim_Steinberg_Stiel(T, Tc, Pc, omega, StielPolar=0):
r'''Calculates air-water surface tension using the reference fluids methods
of [1]_.
.. math::
\sigma = 4.60104\times 10^{-7} P_c^{2/3}T_c^{1/3}Q_p \left(\frac{1-T_r}{0.4}\right)^m
Q_p = 0.1574+0.359\omega-1.769\chi-13.69\chi^2-0.51\omega^2+1.298\omega\chi
m = 1.21+0.5385\omega-14.61\chi-32.07\chi^2-1.65\omega^2+22.03\omega\chi
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
omega : float
Acentric factor for fluid, [-]
StielPolar : float, optional
Stiel Polar Factor, [-]
Returns
-------
sigma : float
Liquid surface tension, N/m
Notes
-----
Original equation for m and Q are used. Internal units are atm and mN/m.
Examples
--------
1-butanol, as compared to value in CRC Handbook of 0.02493.
>>> Hakim_Steinberg_Stiel(298.15, 563.0, 4414000.0, 0.59, StielPolar=-0.07872)
0.021907902575190447
References
----------
.. [1] Hakim, D. I., David Steinberg, and L. I. Stiel. "Generalized
Relationship for the Surface Tension of Polar Fluids." Industrial &
Engineering Chemistry Fundamentals 10, no. 1 (February 1, 1971): 174-75.
doi:10.1021/i160037a032.
'''
Q = (0.1574 + 0.359*omega - 1.769*StielPolar - 13.69*StielPolar**2
- 0.510*omega**2 + 1.298*StielPolar*omega)
m = (1.210 + 0.5385*omega - 14.61*StielPolar - 32.07*StielPolar**2
- 1.656*omega**2 + 22.03*StielPolar*omega)
Tr = T/Tc
Pc = Pc/101325.
sigma = Pc**(2/3.)*Tc**(1/3.)*Q*((1 - Tr)/0.4)**m
sigma = sigma/1000. # convert to N/m
return sigma |
def Miqueu(T, Tc, Vc, omega):
r'''Calculates air-water surface tension using the methods of [1]_.
.. math::
\sigma = k T_c \left( \frac{N_a}{V_c}\right)^{2/3}
(4.35 + 4.14 \omega)t^{1.26}(1+0.19t^{0.5} - 0.487t)
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
Vc : float
Critical volume of fluid [m^3/mol]
omega : float
Acentric factor for fluid, [-]
Returns
-------
sigma : float
Liquid surface tension, N/m
Notes
-----
Uses Avogadro's constant and the Boltsman constant.
Internal units of volume are mL/mol and mN/m. However, either a typo
is in the article or author's work, or my value of k is off by 10; this is
corrected nonetheless.
Created with 31 normal fluids, none polar or hydrogen bonded. Has an
AARD of 3.5%.
Examples
--------
Bromotrifluoromethane, 2.45 mN/m
>>> Miqueu(300., 340.1, 0.000199, 0.1687)
0.003474099603581931
References
----------
.. [1] Miqueu, C, D Broseta, J Satherley, B Mendiboure, J Lachaise, and
A Graciaa. "An Extended Scaled Equation for the Temperature Dependence
of the Surface Tension of Pure Compounds Inferred from an Analysis of
Experimental Data." Fluid Phase Equilibria 172, no. 2 (July 5, 2000):
169-82. doi:10.1016/S0378-3812(00)00384-8.
'''
Vc = Vc*1E6
t = 1.-T/Tc
sigma = k*Tc*(N_A/Vc)**(2/3.)*(4.35 + 4.14*omega)*t**1.26*(1+0.19*t**0.5 - 0.25*t)*10000
return sigma |
def Aleem(T, MW, Tb, rhol, Hvap_Tb, Cpl):
r'''Calculates vapor-liquid surface tension using the correlation derived by
[1]_ based on critical property CSP methods.
.. math::
\sigma = \phi \frac{MW^{1/3}} {6N_A^{1/3}}\rho_l^{2/3}\left[H_{vap}
+ C_{p,l}(T_b-T)\right]
\phi = 1 - 0.0047MW + 6.8\times 10^{-6} MW^2
Parameters
----------
T : float
Temperature of fluid [K]
MW : float
Molecular weight [g/mol]
Tb : float
Boiling temperature of the fluid [K]
rhol : float
Liquid density at T and P [kg/m^3]
Hvap_Tb : float
Mass enthalpy of vaporization at the normal boiling point [kg/m^3]
Cpl : float
Liquid heat capacity of the chemical at T [J/kg/K]
Returns
-------
sigma : float
Liquid-vapor surface tension [N/m]
Notes
-----
Internal units of molecuar weight are kg/mol. This model is dimensionally
consistent.
This model does not use the critical temperature. After it predicts a
surface tension of 0 at a sufficiently high temperature, it returns
negative results. The temperature at which this occurs (the "predicted"
critical temperature) can be calculated as follows:
.. math::
\sigma = 0 \to T_{c,predicted} \text{ at } T_b + \frac{H_{vap}}{Cp_l}
Because of its dependence on density, it has the potential to model the
effect of pressure on surface tension.
Claims AAD of 4.3%. Developed for normal alkanes. Total of 472 data points.
Behaves worse for higher alkanes. Behaves very poorly overall.
Examples
--------
Methane at 90 K
>>> Aleem(T=90, MW=16.04246, Tb=111.6, rhol=458.7, Hvap_Tb=510870.,
... Cpl=2465.)
0.01669970221165325
References
----------
.. [1] Aleem, W., N. Mellon, S. Sufian, M. I. A. Mutalib, and D. Subbarao.
"A Model for the Estimation of Surface Tension of Pure Hydrocarbon
Liquids." Petroleum Science and Technology 33, no. 23-24 (December 17,
2015): 1908-15. doi:10.1080/10916466.2015.1110593.
'''
MW = MW/1000. # Use kg/mol for consistency with the other units
sphericity = 1. - 0.0047*MW + 6.8E-6*MW*MW
return sphericity*MW**(1/3.)/(6.*N_A**(1/3.))*rhol**(2/3.)*(Hvap_Tb + Cpl*(Tb-T)) |
def Mersmann_Kind_surface_tension(T, Tm, Tb, Tc, Pc, n_associated=1):
r'''Estimates the surface tension of organic liquid substances
according to the method of [1]_.
.. math::
\sigma^* = \frac{\sigma n_{ass}^{1/3}} {(kT_c)^{1/3} T_{rm}P_c^{2/3}}
\sigma^* = \left(\frac{T_b - T_m}{T_m}\right)^{1/3}
\left[6.25(1-T_r) + 31.3(1-T_r)^{4/3}\right]
Parameters
----------
T : float
Temperature of the fluid [K]
Tm : float
Melting temperature [K]
Tb : float
Boiling temperature of the fluid [K]
Tc : float
Critical temperature of the fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
n_associated : float
Number of associated molecules in a cluster (2 for alcohols, 1
otherwise), [-]
Returns
-------
sigma : float
Liquid-vapor surface tension [N/m]
Notes
-----
In the equation, all quantities must be in SI units. `k` is the boltzman
constant.
Examples
--------
MTBE at STP (the actual value is 0.0181):
>>> Mersmann_Kind_surface_tension(298.15, 164.15, 328.25, 497.1, 3430000.0)
0.016744309508833335
References
----------
.. [1] Mersmann, Alfons, and Matthias Kind. "Prediction of Mechanical and
Thermal Properties of Pure Liquids, of Critical Data, and of Vapor
Pressure." Industrial & Engineering Chemistry Research, January 31,
2017. https://doi.org/10.1021/acs.iecr.6b04323.
'''
Tr = T/Tc
sigma_star = ((Tb - Tm)/Tm)**(1/3.)*(6.25*(1. - Tr) + 31.3*(1. - Tr)**(4/3.))
sigma = sigma_star*(k*Tc)**(1/3.)*(Tm/Tc)*Pc**(2/3.)*n_associated**(-1/3.)
return sigma |
def Winterfeld_Scriven_Davis(xs, sigmas, rhoms):
r'''Calculates surface tension of a liquid mixture according to
mixing rules in [1]_ and also in [2]_.
.. math::
\sigma_M = \sum_i \sum_j \frac{1}{V_L^{L2}}\left(x_i V_i \right)
\left( x_jV_j\right)\sqrt{\sigma_i\cdot \sigma_j}
Parameters
----------
xs : array-like
Mole fractions of all components, [-]
sigmas : array-like
Surface tensions of all components, [N/m]
rhoms : array-like
Molar densities of all components, [mol/m^3]
Returns
-------
sigma : float
Air-liquid surface tension of mixture, [N/m]
Notes
-----
DIPPR Procedure 7C: Method for the Surface Tension of Nonaqueous Liquid
Mixtures
Becomes less accurate as liquid-liquid critical solution temperature is
approached. DIPPR Evaluation: 3-4% AARD, from 107 nonaqueous binary
systems, 1284 points. Internally, densities are converted to kmol/m^3. The
Amgat function is used to obtain liquid mixture density in this equation.
Raises a ZeroDivisionError if either molar volume are zero, and a
ValueError if a surface tensions of a pure component is negative.
Examples
--------
>>> Winterfeld_Scriven_Davis([0.1606, 0.8394], [0.01547, 0.02877],
... [8610., 15530.])
0.024967388450439824
References
----------
.. [1] Winterfeld, P. H., L. E. Scriven, and H. T. Davis. "An Approximate
Theory of Interfacial Tensions of Multicomponent Systems: Applications
to Binary Liquid-Vapor Tensions." AIChE Journal 24, no. 6
(November 1, 1978): 1010-14. doi:10.1002/aic.690240610.
.. [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([xs, sigmas, rhoms]):
raise Exception('Function inputs are incorrect format')
rhoms = [i*1E-3 for i in rhoms]
Vms = [1./i for i in rhoms]
rho = 1./mixing_simple(xs, Vms)
cmps = range(len(xs))
rho2 = rho*rho
return sum([rho2*xs[i]/rhoms[i]*xs[j]/rhoms[j]*(sigmas[j]*sigmas[i])**0.5
for i in cmps for j in cmps]) |
def Diguilio_Teja(T, xs, sigmas_Tb, Tbs, Tcs):
r'''Calculates surface tension of a liquid mixture according to
mixing rules in [1]_.
.. math::
\sigma = 1.002855(T^*)^{1.118091} \frac{T}{T_b} \sigma_r
T^* = \frac{(T_c/T)-1}{(T_c/T_b)-1}
\sigma_r = \sum x_i \sigma_i
T_b = \sum x_i T_{b,i}
T_c = \sum x_i T_{c,i}
Parameters
----------
T : float
Temperature of fluid [K]
xs : array-like
Mole fractions of all components
sigmas_Tb : array-like
Surface tensions of all components at the boiling point, [N/m]
Tbs : array-like
Boiling temperatures of all components, [K]
Tcs : array-like
Critical temperatures of all components, [K]
Returns
-------
sigma : float
Air-liquid surface tension of mixture, [N/m]
Notes
-----
Simple model, however it has 0 citations. Gives similar results to the
`Winterfeld_Scriven_Davis` model.
Raises a ValueError if temperature is greater than the mixture's critical
temperature or if the given temperature is negative, or if the mixture's
boiling temperature is higher than its critical temperature.
[1]_ claims a 4.63 percent average absolute error on 21 binary and 4
ternary non-aqueous systems. [1]_ also considered Van der Waals mixing
rules for `Tc`, but found it provided a higher error of 5.58%
Examples
--------
>>> Diguilio_Teja(T=298.15, xs=[0.1606, 0.8394],
... sigmas_Tb=[0.01424, 0.02530], Tbs=[309.21, 312.95], Tcs=[469.7, 508.0])
0.025716823875045505
References
----------
.. [1] Diguilio, Ralph, and Amyn S. Teja. "Correlation and Prediction of
the Surface Tensions of Mixtures." The Chemical Engineering Journal 38,
no. 3 (July 1988): 205-8. doi:10.1016/0300-9467(88)80079-0.
'''
if not none_and_length_check([xs, sigmas_Tb, Tbs, Tcs]):
raise Exception('Function inputs are incorrect format')
Tc = mixing_simple(xs, Tcs)
if T > Tc:
raise ValueError('T > Tc according to Kays rule - model is not valid in this range.')
Tb = mixing_simple(xs, Tbs)
sigmar = mixing_simple(xs, sigmas_Tb)
Tst = (Tc/T - 1.)/(Tc/Tb - 1)
return 1.002855*Tst**1.118091*(T/Tb)*sigmar |
def load_all_methods(self):
r'''Method which picks out coefficients for the specified chemical
from the various dictionaries and DataFrames storing it. All data is
stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`,
and :obj:`all_methods` as a set of methods for which the data exists for.
Called on initialization only. See the source code for the variables at
which the coefficients are stored. The coefficients can safely be
altered once the class is initialized. This method can be called again
to reset the parameters.
'''
methods = []
Tmins, Tmaxs = [], []
if self.CASRN in Mulero_Cachadina_data.index:
methods.append(STREFPROP)
_, sigma0, n0, sigma1, n1, sigma2, n2, Tc, self.STREFPROP_Tmin, self.STREFPROP_Tmax = _Mulero_Cachadina_data_values[Mulero_Cachadina_data.index.get_loc(self.CASRN)].tolist()
self.STREFPROP_coeffs = [sigma0, n0, sigma1, n1, sigma2, n2, Tc]
Tmins.append(self.STREFPROP_Tmin); Tmaxs.append(self.STREFPROP_Tmax)
if self.CASRN in Somayajulu_data_2.index:
methods.append(SOMAYAJULU2)
_, self.SOMAYAJULU2_Tt, self.SOMAYAJULU2_Tc, A, B, C = _Somayajulu_data_2_values[Somayajulu_data_2.index.get_loc(self.CASRN)].tolist()
self.SOMAYAJULU2_coeffs = [A, B, C]
Tmins.append(self.SOMAYAJULU2_Tt); Tmaxs.append(self.SOMAYAJULU2_Tc)
if self.CASRN in Somayajulu_data.index:
methods.append(SOMAYAJULU)
_, self.SOMAYAJULU_Tt, self.SOMAYAJULU_Tc, A, B, C = _Somayajulu_data_values[Somayajulu_data.index.get_loc(self.CASRN)].tolist()
self.SOMAYAJULU_coeffs = [A, B, C]
Tmins.append(self.SOMAYAJULU_Tt); Tmaxs.append(self.SOMAYAJULU_Tc)
if self.CASRN in _VDISaturationDict:
methods.append(VDI_TABULAR)
Ts, props = VDI_tabular_data(self.CASRN, 'sigma')
self.VDI_Tmin = Ts[0]
self.VDI_Tmax = Ts[-1]
self.tabular_data[VDI_TABULAR] = (Ts, props)
Tmins.append(self.VDI_Tmin); Tmaxs.append(self.VDI_Tmax)
if self.CASRN in Jasper_Lange_data.index:
methods.append(JASPER)
_, a, b, self.JASPER_Tmin, self.JASPER_Tmax= _Jasper_Lange_data_values[Jasper_Lange_data.index.get_loc(self.CASRN)].tolist()
self.JASPER_coeffs = [a, b]
Tmins.append(self.JASPER_Tmin); Tmaxs.append(self.JASPER_Tmax)
if all((self.Tc, self.Vc, self.omega)):
methods.append(MIQUEU)
Tmins.append(0.0); Tmaxs.append(self.Tc)
if all((self.Tb, self.Tc, self.Pc)):
methods.append(BROCK_BIRD)
methods.append(SASTRI_RAO)
Tmins.append(0.0); Tmaxs.append(self.Tc)
if all((self.Tc, self.Pc, self.omega)):
methods.append(PITZER)
methods.append(ZUO_STENBY)
Tmins.append(0.0); Tmaxs.append(self.Tc)
if self.CASRN in VDI_PPDS_11.index:
_, Tm, Tc, A, B, C, D, E = _VDI_PPDS_11_values[VDI_PPDS_11.index.get_loc(self.CASRN)].tolist()
self.VDI_PPDS_coeffs = [A, B, C, D, E]
self.VDI_PPDS_Tc = Tc
self.VDI_PPDS_Tm = Tm
methods.append(VDI_PPDS)
Tmins.append(self.VDI_PPDS_Tm) ; Tmaxs.append(self.VDI_PPDS_Tc);
if all((self.Tb, self.Hvap_Tb, self.MW)):
# Cache Cpl at Tb for ease of calculation of Tmax
self.Cpl_Tb = self.Cpl(self.Tb) if hasattr(self.Cpl, '__call__') else self.Cpl
if self.Cpl_Tb:
methods.append(ALEEM)
# Tmin and Tmax for this method is known
Tmax_possible = self.Tb + self.Hvap_Tb/self.Cpl_Tb
# This method will ruin solve_prop as it is typically valid
# well above Tc. If Tc is available, limit it to that.
if self.Tc:
Tmax_possible = min(self.Tc, Tmax_possible)
Tmins.append(0.0); Tmaxs.append(Tmax_possible)
self.all_methods = set(methods)
if Tmins and Tmaxs:
# Note: All methods work right down to 0 K.
self.Tmin = min(Tmins)
self.Tmax = max(Tmaxs) |
def calculate(self, T, method):
r'''Method to calculate surface tension of a liquid at temperature `T`
with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature at which to calculate surface tension, [K]
method : str
Name of the method to use
Returns
-------
sigma : float
Surface tension of the liquid at T, [N/m]
'''
if method == STREFPROP:
sigma0, n0, sigma1, n1, sigma2, n2, Tc = self.STREFPROP_coeffs
sigma = REFPROP(T, Tc=Tc, sigma0=sigma0, n0=n0, sigma1=sigma1, n1=n1,
sigma2=sigma2, n2=n2)
elif method == VDI_PPDS:
sigma = EQ106(T, self.VDI_PPDS_Tc, *self.VDI_PPDS_coeffs)
elif method == SOMAYAJULU2:
A, B, C = self.SOMAYAJULU2_coeffs
sigma = Somayajulu(T, Tc=self.SOMAYAJULU2_Tc, A=A, B=B, C=C)
elif method == SOMAYAJULU:
A, B, C = self.SOMAYAJULU_coeffs
sigma = Somayajulu(T, Tc=self.SOMAYAJULU_Tc, A=A, B=B, C=C)
elif method == JASPER:
sigma = Jasper(T, a=self.JASPER_coeffs[0], b=self.JASPER_coeffs[1])
elif method == BROCK_BIRD:
sigma = Brock_Bird(T, self.Tb, self.Tc, self.Pc)
elif method == SASTRI_RAO:
sigma = Sastri_Rao(T, self.Tb, self.Tc, self.Pc)
elif method == PITZER:
sigma = Pitzer(T, self.Tc, self.Pc, self.omega)
elif method == ZUO_STENBY:
sigma = Zuo_Stenby(T, self.Tc, self.Pc, self.omega)
elif method == MIQUEU:
sigma = Miqueu(T, self.Tc, self.Vc, self.omega)
elif method == ALEEM:
Cpl = self.Cpl(T) if hasattr(self.Cpl, '__call__') else self.Cpl
Vml = self.Vml(T) if hasattr(self.Vml, '__call__') else self.Vml
rhol = Vm_to_rho(Vml, self.MW)
sigma = Aleem(T=T, MW=self.MW, Tb=self.Tb, rhol=rhol, Hvap_Tb=self.Hvap_Tb, Cpl=Cpl)
elif method in self.tabular_data:
sigma = self.interpolate(T, method)
return sigma |
def load_all_methods(self):
r'''Method to initialize the object by precomputing any values which
may be used repeatedly and by retrieving mixture-specific variables.
All data are stored as attributes. This method also sets :obj:`Tmin`,
:obj:`Tmax`, and :obj:`all_methods` as a set of methods which should
work to calculate the property.
Called on initialization only. See the source code for the variables at
which the coefficients are stored. The coefficients can safely be
altered once the class is initialized. This method can be called again
to reset the parameters.
'''
methods = []
methods.append(SIMPLE) # Needs sigma
methods.append(WINTERFELDSCRIVENDAVIS) # Nothing to load, needs rhoms, sigma
if none_and_length_check((self.Tbs, self.Tcs)):
self.sigmas_Tb = [i(Tb) for i, Tb in zip(self.SurfaceTensions, self.Tbs)]
if none_and_length_check([self.sigmas_Tb]):
methods.append(DIGUILIOTEJA)
self.all_methods = set(methods) |
def calculate(self, T, P, zs, ws, method):
r'''Method to calculate surface tension of a liquid mixture at
temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
`ws` with a given method.
This method has no exception handling; see `mixture_property`
for that.
Parameters
----------
T : float
Temperature at which to calculate the property, [K]
P : float
Pressure at which to calculate the property, [Pa]
zs : list[float]
Mole fractions of all species in the mixture, [-]
ws : list[float]
Weight fractions of all species in the mixture, [-]
method : str
Name of the method to use
Returns
-------
sigma : float
Surface tension of the liquid at given conditions, [N/m]
'''
if method == SIMPLE:
sigmas = [i(T) for i in self.SurfaceTensions]
return mixing_simple(zs, sigmas)
elif method == DIGUILIOTEJA:
return Diguilio_Teja(T=T, xs=zs, sigmas_Tb=self.sigmas_Tb,
Tbs=self.Tbs, Tcs=self.Tcs)
elif method == WINTERFELDSCRIVENDAVIS:
sigmas = [i(T) for i in self.SurfaceTensions]
rhoms = [1./i(T, P) for i in self.VolumeLiquids]
return Winterfeld_Scriven_Davis(zs, sigmas, rhoms)
else:
raise Exception('Method not valid') |
def load_group_assignments_DDBST():
'''Data is stored in the format
InChI key\tbool bool bool \tsubgroup count ...\tsubgroup count \tsubgroup count...
where the bools refer to whether or not the original UNIFAC, modified
UNIFAC, and PSRK group assignments were completed correctly.
The subgroups and their count have an indefinite length.
'''
# Do not allow running multiple times
if DDBST_UNIFAC_assignments:
return None
with open(os.path.join(folder, 'DDBST UNIFAC assignments.tsv')) as f:
_group_assignments = [DDBST_UNIFAC_assignments, DDBST_MODIFIED_UNIFAC_assignments, DDBST_PSRK_assignments]
for line in f.readlines():
key, valids, original, modified, PSRK = line.split('\t')
# list of whether or not each method was correctly identified or not
valids = [True if i == '1' else False for i in valids.split(' ')]
for groups, storage, valid in zip([original, modified, PSRK], _group_assignments, valids):
if valid:
groups = groups.rstrip().split(' ')
d_data = {}
for i in range(int(len(groups)/2)):
d_data[int(groups[i*2])] = int(groups[i*2+1])
storage[key] = d_data |
def UNIFAC_RQ(groups, subgroup_data=None):
r'''Calculates UNIFAC parameters R and Q for a chemical, given a dictionary
of its groups, as shown in [1]_. Most UNIFAC methods use the same subgroup
values; however, a dictionary of `UNIFAC_subgroup` instances may be
specified as an optional second parameter.
.. math::
r_i = \sum_{k=1}^{n} \nu_k R_k
q_i = \sum_{k=1}^{n}\nu_k Q_k
Parameters
----------
groups : dict[count]
Dictionary of numeric subgroup IDs : their counts
subgroup_data : None or dict[UNIFAC_subgroup]
Optional replacement for standard subgroups; leave as None to use the
original UNIFAC subgroup r and q values.
Returns
-------
R : float
R UNIFAC parameter (normalized Van der Waals Volume) [-]
Q : float
Q UNIFAC parameter (normalized Van der Waals Area) [-]
Notes
-----
These parameters have some predictive value for other chemical properties.
Examples
--------
Hexane
>>> UNIFAC_RQ({1:2, 2:4})
(4.4998000000000005, 3.856)
References
----------
.. [1] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation.
Weinheim, Germany: Wiley-VCH, 2012.
'''
if subgroup_data is not None:
subgroups = subgroup_data
else:
subgroups = UFSG
ri = 0.
qi = 0.
for group, count in groups.items():
ri += subgroups[group].R*count
qi += subgroups[group].Q*count
return ri, qi |
def UNIFAC_psi(T, subgroup1, subgroup2, subgroup_data, interaction_data,
modified=False):
r'''Calculates the interaction parameter psi(m, n) for two UNIFAC
subgroups, given the system temperature, the UNIFAC subgroups considered
for the variant of UNIFAC used, the interaction parameters for the
variant of UNIFAC used, and whether or not the temperature dependence is
modified from the original form, as shown below.
Original temperature dependence:
.. math::
\Psi_{mn} = \exp\left(\frac{-a_{mn}}{T}\right)
Modified temperature dependence:
.. math::
\Psi_{mn} = \exp\left(\frac{-a_{mn} - b_{mn}T - c_{mn}T^2}{T}\right)
Parameters
----------
T : float
Temperature of the system, [K]
subgroup1 : int
First UNIFAC subgroup for identifier, [-]
subgroup2 : int
Second UNIFAC subgroup for identifier, [-]
subgroup_data : dict[UNIFAC_subgroup]
Normally provided as inputs to `UNIFAC`.
interaction_data : dict[dict[tuple(a_mn, b_mn, c_mn)]]
Normally provided as inputs to `UNIFAC`.
modified : bool
True if the modified temperature dependence is used by the interaction
parameters, otherwise False
Returns
-------
psi : float
UNIFAC interaction parameter term, [-]
Notes
-----
UNIFAC interaction parameters are asymmetric. No warning is raised if an
interaction parameter is missing.
Examples
--------
>>> from thermo.unifac import UFSG, UFIP, DOUFSG, DOUFIP2006
>>> UNIFAC_psi(307, 18, 1, UFSG, UFIP)
0.9165248264184787
>>> UNIFAC_psi(373.15, 9, 78, DOUFSG, DOUFIP2006, modified=True)
1.3703140538273264
References
----------
.. [1] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation.
Weinheim, Germany: Wiley-VCH, 2012.
.. [2] Fredenslund, Aage, Russell L. Jones, and John M. Prausnitz. "Group
Contribution Estimation of Activity Coefficients in Nonideal Liquid
Mixtures." AIChE Journal 21, no. 6 (November 1, 1975): 1086-99.
doi:10.1002/aic.690210607.
'''
main1 = subgroup_data[subgroup1].main_group_id
main2 = subgroup_data[subgroup2].main_group_id
if modified:
try:
a, b, c = interaction_data[main1][main2]
except:
return 1.
return exp((-a/T -b - c*T))
else:
try:
return exp(-interaction_data[main1][main2]/T)
except:
return 1. |
def UNIFAC(T, xs, chemgroups, cached=None, subgroup_data=None,
interaction_data=None, modified=False):
r'''Calculates activity coefficients using the UNIFAC model (optionally
modified), given a mixture's temperature, liquid mole fractions,
and optionally the subgroup data and interaction parameter data of your
choice. The default is to use the original UNIFAC model, with the latest
parameters published by DDBST. The model supports modified forms (Dortmund,
NIST) when the `modified` parameter is True.
Parameters
----------
T : float
Temperature of the system, [K]
xs : list[float]
Mole fractions of all species in the system in the liquid phase, [-]
chemgroups : list[dict]
List of dictionaries of subgroup IDs and their counts for all species
in the mixture, [-]
subgroup_data : dict[UNIFAC_subgroup]
UNIFAC subgroup data; available dictionaries in this module are UFSG
(original), DOUFSG (Dortmund), or NISTUFSG ([4]_).
interaction_data : dict[dict[tuple(a_mn, b_mn, c_mn)]]
UNIFAC interaction parameter data; available dictionaries in this
module are UFIP (original), DOUFIP2006 (Dortmund parameters as
published by 2006), DOUFIP2016 (Dortmund parameters as published by
2016), and NISTUFIP ([4]_).
modified : bool
True if using the modified form and temperature dependence, otherwise
False.
Returns
-------
gammas : list[float]
Activity coefficients of all species in the mixture, [-]
Notes
-----
The actual implementation of UNIFAC is formulated slightly different than
the formulas above for computational efficiency. DDBST switched to using
the more efficient forms in their publication, but the numerical results
are identical.
The model is as follows:
.. math::
\ln \gamma_i = \ln \gamma_i^c + \ln \gamma_i^r
**Combinatorial component**
.. math::
\ln \gamma_i^c = \ln \frac{\phi_i}{x_i} + \frac{z}{2} q_i
\ln\frac{\theta_i}{\phi_i} + L_i - \frac{\phi_i}{x_i}
\sum_{j=1}^{n} x_j L_j
\theta_i = \frac{x_i q_i}{\sum_{j=1}^{n} x_j q_j}
\phi_i = \frac{x_i r_i}{\sum_{j=1}^{n} x_j r_j}
L_i = 5(r_i - q_i)-(r_i-1)
**Residual component**
.. math::
\ln \gamma_i^r = \sum_{k}^n \nu_k^{(i)} \left[ \ln \Gamma_k
- \ln \Gamma_k^{(i)} \right]
\ln \Gamma_k = Q_k \left[1 - \ln \sum_m \Theta_m \Psi_{mk} - \sum_m
\frac{\Theta_m \Psi_{km}}{\sum_n \Theta_n \Psi_{nm}}\right]
\Theta_m = \frac{Q_m X_m}{\sum_{n} Q_n X_n}
X_m = \frac{ \sum_j \nu^j_m x_j}{\sum_j \sum_n \nu_n^j x_j}
**R and Q**
.. math::
r_i = \sum_{k=1}^{n} \nu_k R_k
q_i = \sum_{k=1}^{n}\nu_k Q_k
The newer forms of UNIFAC (Dortmund, NIST) calculate the combinatorial
part slightly differently:
.. math::
\ln \gamma_i^c = 1 - {V'}_i + \ln({V'}_i) - 5q_i \left(1
- \frac{V_i}{F_i}+ \ln\left(\frac{V_i}{F_i}\right)\right)
V'_i = \frac{r_i^{3/4}}{\sum_j r_j^{3/4}x_j}
This is more clear when looking at the full rearranged form as in [3]_.
Examples
--------
>>> UNIFAC(T=333.15, xs=[0.5, 0.5], chemgroups=[{1:2, 2:4}, {1:1, 2:1, 18:1}])
[1.4276025835624173, 1.3646545010104225]
>>> UNIFAC(373.15, [0.2, 0.3, 0.2, 0.2],
... [{9:6}, {78:6}, {1:1, 18:1}, {1:1, 2:1, 14:1}],
... subgroup_data=DOUFSG, interaction_data=DOUFIP2006, modified=True)
[1.186431113706829, 1.440280133911197, 1.204479833499608, 1.9720706090299824]
References
----------
.. [1] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation.
Weinheim, Germany: Wiley-VCH, 2012.
.. [2] Fredenslund, Aage, Russell L. Jones, and John M. Prausnitz. "Group
Contribution Estimation of Activity Coefficients in Nonideal Liquid
Mixtures." AIChE Journal 21, no. 6 (November 1, 1975): 1086-99.
doi:10.1002/aic.690210607.
.. [3] Jakob, Antje, Hans Grensemann, Jürgen Lohmann, and Jürgen Gmehling.
"Further Development of Modified UNIFAC (Dortmund): Revision and
Extension 5." Industrial & Engineering Chemistry Research 45, no. 23
(November 1, 2006): 7924-33. doi:10.1021/ie060355c.
.. [4] Kang, Jeong Won, Vladimir Diky, and Michael Frenkel. "New Modified
UNIFAC Parameters Using Critically Evaluated Phase Equilibrium Data."
Fluid Phase Equilibria 388 (February 25, 2015): 128-41.
doi:10.1016/j.fluid.2014.12.042.
'''
cmps = range(len(xs))
if subgroup_data is None:
subgroups = UFSG
else:
subgroups = subgroup_data
if interaction_data is None:
interactions = UFIP
else:
interactions = interaction_data
# Obtain r and q values using the subgroup values
if not cached:
rs = []
qs = []
for groups in chemgroups:
ri = 0.
qi = 0.
for group, count in groups.items():
ri += subgroups[group].R*count
qi += subgroups[group].Q*count
rs.append(ri)
qs.append(qi)
group_counts = {}
for groups in chemgroups:
for group, count in groups.items():
if group in group_counts:
group_counts[group] += count
else:
group_counts[group] = count
else:
rs, qs, group_counts = cached
# Sum the denominator for calculating Xs
group_sum = sum(count*xs[i] for i in cmps for count in chemgroups[i].values())
# Caclulate each numerator for calculating Xs
group_count_xs = {}
for group in group_counts:
tot_numerator = sum(chemgroups[i][group]*xs[i] for i in cmps if group in chemgroups[i])
group_count_xs[group] = tot_numerator/group_sum
rsxs = sum([rs[i]*xs[i] for i in cmps])
Vis = [rs[i]/rsxs for i in cmps]
qsxs = sum([qs[i]*xs[i] for i in cmps])
Fis = [qs[i]/qsxs for i in cmps]
if modified:
rsxs2 = sum([rs[i]**0.75*xs[i] for i in cmps])
Vis2 = [rs[i]**0.75/rsxs2 for i in cmps]
loggammacs = [1. - Vis2[i] + log(Vis2[i]) - 5.*qs[i]*(1. - Vis[i]/Fis[i]
+ log(Vis[i]/Fis[i])) for i in cmps]
else:
loggammacs = [1. - Vis[i] + log(Vis[i]) - 5.*qs[i]*(1. - Vis[i]/Fis[i]
+ log(Vis[i]/Fis[i])) for i in cmps]
Q_sum_term = sum([subgroups[group].Q*group_count_xs[group] for group in group_counts])
area_fractions = {group: subgroups[group].Q*group_count_xs[group]/Q_sum_term
for group in group_counts.keys()}
UNIFAC_psis = {k: {m:(UNIFAC_psi(T, m, k, subgroups, interactions, modified=modified))
for m in group_counts} for k in group_counts}
loggamma_groups = {}
for k in group_counts:
sum1, sum2 = 0., 0.
for m in group_counts:
sum1 += area_fractions[m]*UNIFAC_psis[k][m]
sum3 = sum(area_fractions[n]*UNIFAC_psis[m][n] for n in group_counts)
sum2 -= area_fractions[m]*UNIFAC_psis[m][k]/sum3
loggamma_groups[k] = subgroups[k].Q*(1. - log(sum1) + sum2)
loggammars = []
for groups in chemgroups:
chem_loggamma_groups = {}
chem_group_sum = sum(groups.values())
chem_group_count_xs = {group: count/chem_group_sum for group, count in groups.items()}
Q_sum_term = sum([subgroups[group].Q*chem_group_count_xs[group] for group in groups])
chem_area_fractions = {group: subgroups[group].Q*chem_group_count_xs[group]/Q_sum_term
for group in groups.keys()}
for k in groups:
sum1, sum2 = 0., 0.
for m in groups:
sum1 += chem_area_fractions[m]*UNIFAC_psis[k][m]
sum3 = sum(chem_area_fractions[n]*UNIFAC_psis[m][n] for n in groups)
sum2 -= chem_area_fractions[m]*UNIFAC_psis[m][k]/sum3
chem_loggamma_groups[k] = subgroups[k].Q*(1. - log(sum1) + sum2)
tot = sum([count*(loggamma_groups[group] - chem_loggamma_groups[group])
for group, count in groups.items()])
loggammars.append(tot)
return [exp(loggammacs[i]+loggammars[i]) for i in cmps] |
def dipole_moment(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval of a chemical's dipole moment.
Lookup is based on CASRNs. Will automatically select a data source to use
if no Method is provided; returns None if the data is not available.
Prefered source is 'CCCBDB'. Considerable variation in reported data has
found.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
dipole : float
Dipole moment, [debye]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain dipole moment with the
given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Accepted methods are 'CCCBDB', 'MULLER', or
'POLING'. All valid values are also held in the list `dipole_methods`.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the dipole moment for the desired chemical, and will return methods
instead of the dipole moment
Notes
-----
A total of three sources are available for this function. They are:
* 'CCCBDB', a series of critically evaluated data for compounds in
[1]_, intended for use in predictive modeling.
* 'MULLER', a collection of data in a
group-contribution scheme in [2]_.
* 'POLING', in the appendix in [3].
This function returns dipole moment in units of Debye. This is actually
a non-SI unit; to convert to SI, multiply by 3.33564095198e-30 and its
units will be in ampere*second^2 or equivalently and more commonly given,
coulomb*second. The constant is the result of 1E-21/c, where c is the
speed of light.
Examples
--------
>>> dipole_moment(CASRN='64-17-5')
1.44
References
----------
.. [1] NIST Computational Chemistry Comparison and Benchmark Database
NIST Standard Reference Database Number 101 Release 17b, September 2015,
Editor: Russell D. Johnson III http://cccbdb.nist.gov/
.. [2] Muller, Karsten, Liudmila Mokrushina, and Wolfgang Arlt. "Second-
Order Group Contribution Method for the Determination of the Dipole
Moment." Journal of Chemical & Engineering Data 57, no. 4 (April 12,
2012): 1231-36. doi:10.1021/je2013395.
.. [3] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
New York: McGraw-Hill Professional, 2000.
'''
def list_methods():
methods = []
if CASRN in _dipole_CCDB.index and not np.isnan(_dipole_CCDB.at[CASRN, 'Dipole']):
methods.append(CCCBDB)
if CASRN in _dipole_Muller.index and not np.isnan(_dipole_Muller.at[CASRN, 'Dipole']):
methods.append(MULLER)
if CASRN in _dipole_Poling.index and not np.isnan(_dipole_Poling.at[CASRN, 'Dipole']):
methods.append(POLING)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == CCCBDB:
_dipole = float(_dipole_CCDB.at[CASRN, 'Dipole'])
elif Method == MULLER:
_dipole = float(_dipole_Muller.at[CASRN, 'Dipole'])
elif Method == POLING:
_dipole = float(_dipole_Poling.at[CASRN, 'Dipole'])
elif Method == NONE:
_dipole = None
else:
raise Exception('Failure in in function')
return _dipole |
def Pc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[SURF]):
r'''This function handles the retrieval of a chemical's critical
pressure. Lookup is based on CASRNs. Will automatically select a data
source to use if no Method is provided; returns None if the data is not
available.
Prefered sources are 'IUPAC' for organic chemicals, and 'MATTHEWS' for
inorganic chemicals. Function has data for approximately 1000 chemicals.
Examples
--------
>>> Pc(CASRN='64-17-5')
6137000.0
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Pc : float
Critical pressure, [Pa]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Pc with the given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS',
'CRC', 'PSRK', 'PD', 'YAWS', and 'SURF'. All valid values are also held
in the list `Pc_methods`.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Pc for the desired chemical, and will return methods instead of Pc
IgnoreMethods : list, optional
A list of methods to ignore in obtaining the full list of methods,
useful for for performance reasons and ignoring inaccurate methods
Notes
-----
A total of seven sources are available for this function. They are:
* 'IUPAC', a series of critically evaluated
experimental datum for organic compounds in [1]_, [2]_, [3]_, [4]_,
[5]_, [6]_, [7]_, [8]_, [9]_, [10]_, [11]_, and [12]_.
* 'MATTHEWS', a series of critically
evaluated data for inorganic compounds in [13]_.
* 'CRC', a compillation of critically
evaluated data by the TRC as published in [14]_.
* 'PSRK', a compillation of experimental and
estimated data published in [15]_.
* 'PD', an older compillation of
data published in [16]_
* 'YAWS', a large compillation of data from a
variety of sources; no data points are sourced in the work of [17]_.
* SURF', an estimation method using a
simple quadratic method for estimating Pc from Tc and Vc. This is
ignored and not returned as a method by default.
References
----------
.. [1] Ambrose, Douglas, and Colin L. Young. "Vapor-Liquid Critical
Properties of Elements and Compounds. 1. An Introductory Survey."
Journal of Chemical & Engineering Data 41, no. 1 (January 1, 1996):
154-154. doi:10.1021/je950378q.
.. [2] Ambrose, Douglas, and Constantine Tsonopoulos. "Vapor-Liquid
Critical Properties of Elements and Compounds. 2. Normal Alkanes."
Journal of Chemical & Engineering Data 40, no. 3 (May 1, 1995): 531-46.
doi:10.1021/je00019a001.
.. [3] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 3. Aromatic
Hydrocarbons." Journal of Chemical & Engineering Data 40, no. 3
(May 1, 1995): 547-58. doi:10.1021/je00019a002.
.. [4] Gude, Michael, and Amyn S. Teja. "Vapor-Liquid Critical Properties
of Elements and Compounds. 4. Aliphatic Alkanols." Journal of Chemical
& Engineering Data 40, no. 5 (September 1, 1995): 1025-36.
doi:10.1021/je00021a001.
.. [5] Daubert, Thomas E. "Vapor-Liquid Critical Properties of Elements
and Compounds. 5. Branched Alkanes and Cycloalkanes." Journal of
Chemical & Engineering Data 41, no. 3 (January 1, 1996): 365-72.
doi:10.1021/je9501548.
.. [6] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 6. Unsaturated Aliphatic
Hydrocarbons." Journal of Chemical & Engineering Data 41, no. 4
(January 1, 1996): 645-56. doi:10.1021/je9501999.
.. [7] Kudchadker, Arvind P., Douglas Ambrose, and Constantine Tsonopoulos.
"Vapor-Liquid Critical Properties of Elements and Compounds. 7. Oxygen
Compounds Other Than Alkanols and Cycloalkanols." Journal of Chemical &
Engineering Data 46, no. 3 (May 1, 2001): 457-79. doi:10.1021/je0001680.
.. [8] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 8. Organic Sulfur,
Silicon, and Tin Compounds (C + H + S, Si, and Sn)." Journal of Chemical
& Engineering Data 46, no. 3 (May 1, 2001): 480-85.
doi:10.1021/je000210r.
.. [9] Marsh, Kenneth N., Colin L. Young, David W. Morton, Douglas Ambrose,
and Constantine Tsonopoulos. "Vapor-Liquid Critical Properties of
Elements and Compounds. 9. Organic Compounds Containing Nitrogen."
Journal of Chemical & Engineering Data 51, no. 2 (March 1, 2006):
305-14. doi:10.1021/je050221q.
.. [10] Marsh, Kenneth N., Alan Abramson, Douglas Ambrose, David W. Morton,
Eugene Nikitin, Constantine Tsonopoulos, and Colin L. Young.
"Vapor-Liquid Critical Properties of Elements and Compounds. 10. Organic
Compounds Containing Halogens." Journal of Chemical & Engineering Data
52, no. 5 (September 1, 2007): 1509-38. doi:10.1021/je700336g.
.. [11] Ambrose, Douglas, Constantine Tsonopoulos, and Eugene D. Nikitin.
"Vapor-Liquid Critical Properties of Elements and Compounds. 11. Organic
Compounds Containing B + O; Halogens + N, + O, + O + S, + S, + Si;
N + O; and O + S, + Si." Journal of Chemical & Engineering Data 54,
no. 3 (March 12, 2009): 669-89. doi:10.1021/je800580z.
.. [12] Ambrose, Douglas, Constantine Tsonopoulos, Eugene D. Nikitin, David
W. Morton, and Kenneth N. Marsh. "Vapor-Liquid Critical Properties of
Elements and Compounds. 12. Review of Recent Data for Hydrocarbons and
Non-Hydrocarbons." Journal of Chemical & Engineering Data, October 5,
2015, 151005081500002. doi:10.1021/acs.jced.5b00571.
.. [13] Mathews, Joseph F. "Critical Constants of Inorganic Substances."
Chemical Reviews 72, no. 1 (February 1, 1972): 71-100.
doi:10.1021/cr60275a004.
.. [14] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.
.. [15] Horstmann, Sven, Anna Jabłoniec, Jörg Krafczyk, Kai Fischer, and
Jürgen Gmehling. "PSRK Group Contribution Equation of State:
Comprehensive Revision and Extension IV, Including Critical Constants
and Α-Function Parameters for 1000 Components." Fluid Phase Equilibria
227, no. 2 (January 25, 2005): 157-64. doi:10.1016/j.fluid.2004.11.002.
.. [16] Passut, Charles A., and Ronald P. Danner. "Acentric Factor. A
Valuable Correlating Parameter for the Properties of Hydrocarbons."
Industrial & Engineering Chemistry Process Design and Development 12,
no. 3 (July 1, 1973): 365–68. doi:10.1021/i260047a026.
.. [17] Yaws, Carl L. Thermophysical Properties of Chemicals and
Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
Publishing, 2014.
'''
def list_methods():
methods = []
if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, 'Pc']):
methods.append(IUPAC)
if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, 'Pc']):
methods.append(MATTHEWS)
if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, 'Pc']):
methods.append(CRC)
if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'Pc']):
methods.append(PSRK)
if CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, 'Pc']):
methods.append(PD)
if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'Pc']):
methods.append(YAWS)
if CASRN:
methods.append(SURF)
if IgnoreMethods:
for Method in IgnoreMethods:
if Method in methods:
methods.remove(Method)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == IUPAC:
_Pc = float(_crit_IUPAC.at[CASRN, 'Pc'])
elif Method == MATTHEWS:
_Pc = float(_crit_Matthews.at[CASRN, 'Pc'])
elif Method == CRC:
_Pc = float(_crit_CRC.at[CASRN, 'Pc'])
elif Method == PSRK:
_Pc = float(_crit_PSRKR4.at[CASRN, 'Pc'])
elif Method == PD:
_Pc = float(_crit_PassutDanner.at[CASRN, 'Pc'])
elif Method == YAWS:
_Pc = float(_crit_Yaws.at[CASRN, 'Pc'])
elif Method == SURF:
_Pc = third_property(CASRN=CASRN, P=True)
elif Method == NONE:
return None
else:
raise Exception('Failure in in function')
return _Pc |
def Vc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[SURF]):
r'''This function handles the retrieval of a chemical's critical
volume. Lookup is based on CASRNs. Will automatically select a data
source to use if no Method is provided; returns None if the data is not
available.
Prefered sources are 'IUPAC' for organic chemicals, and 'MATTHEWS' for
inorganic chemicals. Function has data for approximately 1000 chemicals.
Examples
--------
>>> Vc(CASRN='64-17-5')
0.000168
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Vc : float
Critical volume, [m^3/mol]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Vc with the given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS',
'CRC', 'PSRK', 'YAWS', and 'SURF'. All valid values are also held
in the list `Vc_methods`.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Vc for the desired chemical, and will return methods instead of Vc
IgnoreMethods : list, optional
A list of methods to ignore in obtaining the full list of methods,
useful for for performance reasons and ignoring inaccurate methods
Notes
-----
A total of six sources are available for this function. They are:
* 'IUPAC', a series of critically evaluated
experimental datum for organic compounds in [1]_, [2]_, [3]_, [4]_,
[5]_, [6]_, [7]_, [8]_, [9]_, [10]_, [11]_, and [12]_.
* 'MATTHEWS', a series of critically
evaluated data for inorganic compounds in [13]_.
* 'CRC', a compillation of critically
evaluated data by the TRC as published in [14]_.
* 'PSRK', a compillation of experimental and
estimated data published in [15]_.
* 'YAWS', a large compillation of data from a
variety of sources; no data points are sourced in the work of [16]_.
* 'SURF', an estimation method using a
simple quadratic method for estimating Pc from Tc and Vc. This is
ignored and not returned as a method by default
References
----------
.. [1] Ambrose, Douglas, and Colin L. Young. "Vapor-Liquid Critical
Properties of Elements and Compounds. 1. An Introductory Survey."
Journal of Chemical & Engineering Data 41, no. 1 (January 1, 1996):
154-154. doi:10.1021/je950378q.
.. [2] Ambrose, Douglas, and Constantine Tsonopoulos. "Vapor-Liquid
Critical Properties of Elements and Compounds. 2. Normal Alkanes."
Journal of Chemical & Engineering Data 40, no. 3 (May 1, 1995): 531-46.
doi:10.1021/je00019a001.
.. [3] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 3. Aromatic
Hydrocarbons." Journal of Chemical & Engineering Data 40, no. 3
(May 1, 1995): 547-58. doi:10.1021/je00019a002.
.. [4] Gude, Michael, and Amyn S. Teja. "Vapor-Liquid Critical Properties
of Elements and Compounds. 4. Aliphatic Alkanols." Journal of Chemical
& Engineering Data 40, no. 5 (September 1, 1995): 1025-36.
doi:10.1021/je00021a001.
.. [5] Daubert, Thomas E. "Vapor-Liquid Critical Properties of Elements
and Compounds. 5. Branched Alkanes and Cycloalkanes." Journal of
Chemical & Engineering Data 41, no. 3 (January 1, 1996): 365-72.
doi:10.1021/je9501548.
.. [6] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 6. Unsaturated Aliphatic
Hydrocarbons." Journal of Chemical & Engineering Data 41, no. 4
(January 1, 1996): 645-56. doi:10.1021/je9501999.
.. [7] Kudchadker, Arvind P., Douglas Ambrose, and Constantine Tsonopoulos.
"Vapor-Liquid Critical Properties of Elements and Compounds. 7. Oxygen
Compounds Other Than Alkanols and Cycloalkanols." Journal of Chemical &
Engineering Data 46, no. 3 (May 1, 2001): 457-79. doi:10.1021/je0001680.
.. [8] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 8. Organic Sulfur,
Silicon, and Tin Compounds (C + H + S, Si, and Sn)." Journal of Chemical
& Engineering Data 46, no. 3 (May 1, 2001): 480-85.
doi:10.1021/je000210r.
.. [9] Marsh, Kenneth N., Colin L. Young, David W. Morton, Douglas Ambrose,
and Constantine Tsonopoulos. "Vapor-Liquid Critical Properties of
Elements and Compounds. 9. Organic Compounds Containing Nitrogen."
Journal of Chemical & Engineering Data 51, no. 2 (March 1, 2006):
305-14. doi:10.1021/je050221q.
.. [10] Marsh, Kenneth N., Alan Abramson, Douglas Ambrose, David W. Morton,
Eugene Nikitin, Constantine Tsonopoulos, and Colin L. Young.
"Vapor-Liquid Critical Properties of Elements and Compounds. 10. Organic
Compounds Containing Halogens." Journal of Chemical & Engineering Data
52, no. 5 (September 1, 2007): 1509-38. doi:10.1021/je700336g.
.. [11] Ambrose, Douglas, Constantine Tsonopoulos, and Eugene D. Nikitin.
"Vapor-Liquid Critical Properties of Elements and Compounds. 11. Organic
Compounds Containing B + O; Halogens + N, + O, + O + S, + S, + Si;
N + O; and O + S, + Si." Journal of Chemical & Engineering Data 54,
no. 3 (March 12, 2009): 669-89. doi:10.1021/je800580z.
.. [12] Ambrose, Douglas, Constantine Tsonopoulos, Eugene D. Nikitin, David
W. Morton, and Kenneth N. Marsh. "Vapor-Liquid Critical Properties of
Elements and Compounds. 12. Review of Recent Data for Hydrocarbons and
Non-Hydrocarbons." Journal of Chemical & Engineering Data, October 5,
2015, 151005081500002. doi:10.1021/acs.jced.5b00571.
.. [13] Mathews, Joseph F. "Critical Constants of Inorganic Substances."
Chemical Reviews 72, no. 1 (February 1, 1972): 71-100.
doi:10.1021/cr60275a004.
.. [14] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.
.. [15] Horstmann, Sven, Anna Jabłoniec, Jörg Krafczyk, Kai Fischer, and
Jürgen Gmehling. "PSRK Group Contribution Equation of State:
Comprehensive Revision and Extension IV, Including Critical Constants
and Α-Function Parameters for 1000 Components." Fluid Phase Equilibria
227, no. 2 (January 25, 2005): 157-64. doi:10.1016/j.fluid.2004.11.002.
.. [16] Yaws, Carl L. Thermophysical Properties of Chemicals and
Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
Publishing, 2014.
'''
def list_methods():
methods = []
if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, 'Vc']):
methods.append(IUPAC)
if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, 'Vc']):
methods.append(MATTHEWS)
if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, 'Vc']):
methods.append(CRC)
if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'Vc']):
methods.append(PSRK)
if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'Vc']):
methods.append(YAWS)
if CASRN:
methods.append(SURF)
if IgnoreMethods:
for Method in IgnoreMethods:
if Method in methods:
methods.remove(Method)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == IUPAC:
_Vc = float(_crit_IUPAC.at[CASRN, 'Vc'])
elif Method == PSRK:
_Vc = float(_crit_PSRKR4.at[CASRN, 'Vc'])
elif Method == MATTHEWS:
_Vc = float(_crit_Matthews.at[CASRN, 'Vc'])
elif Method == CRC:
_Vc = float(_crit_CRC.at[CASRN, 'Vc'])
elif Method == YAWS:
_Vc = float(_crit_Yaws.at[CASRN, 'Vc'])
elif Method == SURF:
_Vc = third_property(CASRN=CASRN, V=True)
elif Method == NONE:
return None
else:
raise Exception('Failure in in function')
return _Vc |
def Zc(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[COMBINED]):
r'''This function handles the retrieval of a chemical's critical
compressibility. Lookup is based on CASRNs. Will automatically select a
data source to use if no Method is provided; returns None if the data is
not available.
Prefered sources are 'IUPAC' for organic chemicals, and 'MATTHEWS' for
inorganic chemicals. Function has data for approximately 1000 chemicals.
Examples
--------
>>> Zc(CASRN='64-17-5')
0.24100000000000002
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Zc : float
Critical compressibility, [-]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Vc with the given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Accepted methods are 'IUPAC', 'MATTHEWS',
'CRC', 'PSRK', 'YAWS', and 'COMBINED'. All valid values are also held
in `Zc_methods`.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Zc for the desired chemical, and will return methods instead of Zc
IgnoreMethods : list, optional
A list of methods to ignore in obtaining the full list of methods,
useful for for performance reasons and ignoring inaccurate methods
Notes
-----
A total of five sources are available for this function. They are:
* 'IUPAC', a series of critically evaluated
experimental datum for organic compounds in [1]_, [2]_, [3]_, [4]_,
[5]_, [6]_, [7]_, [8]_, [9]_, [10]_, [11]_, and [12]_.
* 'MATTHEWS', a series of critically
evaluated data for inorganic compounds in [13]_.
* 'CRC', a compillation of critically
evaluated data by the TRC as published in [14]_.
* 'PSRK', a compillation of experimental and
estimated data published in [15]_.
* 'YAWS', a large compillation of data from a
variety of sources; no data points are sourced in the work of [16]_.
References
----------
.. [1] Ambrose, Douglas, and Colin L. Young. "Vapor-Liquid Critical
Properties of Elements and Compounds. 1. An Introductory Survey."
Journal of Chemical & Engineering Data 41, no. 1 (January 1, 1996):
154-154. doi:10.1021/je950378q.
.. [2] Ambrose, Douglas, and Constantine Tsonopoulos. "Vapor-Liquid
Critical Properties of Elements and Compounds. 2. Normal Alkanes."
Journal of Chemical & Engineering Data 40, no. 3 (May 1, 1995): 531-46.
doi:10.1021/je00019a001.
.. [3] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 3. Aromatic
Hydrocarbons." Journal of Chemical & Engineering Data 40, no. 3
(May 1, 1995): 547-58. doi:10.1021/je00019a002.
.. [4] Gude, Michael, and Amyn S. Teja. "Vapor-Liquid Critical Properties
of Elements and Compounds. 4. Aliphatic Alkanols." Journal of Chemical
& Engineering Data 40, no. 5 (September 1, 1995): 1025-36.
doi:10.1021/je00021a001.
.. [5] Daubert, Thomas E. "Vapor-Liquid Critical Properties of Elements
and Compounds. 5. Branched Alkanes and Cycloalkanes." Journal of
Chemical & Engineering Data 41, no. 3 (January 1, 1996): 365-72.
doi:10.1021/je9501548.
.. [6] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 6. Unsaturated Aliphatic
Hydrocarbons." Journal of Chemical & Engineering Data 41, no. 4
(January 1, 1996): 645-56. doi:10.1021/je9501999.
.. [7] Kudchadker, Arvind P., Douglas Ambrose, and Constantine Tsonopoulos.
"Vapor-Liquid Critical Properties of Elements and Compounds. 7. Oxygen
Compounds Other Than Alkanols and Cycloalkanols." Journal of Chemical &
Engineering Data 46, no. 3 (May 1, 2001): 457-79. doi:10.1021/je0001680.
.. [8] Tsonopoulos, Constantine, and Douglas Ambrose. "Vapor-Liquid
Critical Properties of Elements and Compounds. 8. Organic Sulfur,
Silicon, and Tin Compounds (C + H + S, Si, and Sn)." Journal of Chemical
& Engineering Data 46, no. 3 (May 1, 2001): 480-85.
doi:10.1021/je000210r.
.. [9] Marsh, Kenneth N., Colin L. Young, David W. Morton, Douglas Ambrose,
and Constantine Tsonopoulos. "Vapor-Liquid Critical Properties of
Elements and Compounds. 9. Organic Compounds Containing Nitrogen."
Journal of Chemical & Engineering Data 51, no. 2 (March 1, 2006):
305-14. doi:10.1021/je050221q.
.. [10] Marsh, Kenneth N., Alan Abramson, Douglas Ambrose, David W. Morton,
Eugene Nikitin, Constantine Tsonopoulos, and Colin L. Young.
"Vapor-Liquid Critical Properties of Elements and Compounds. 10. Organic
Compounds Containing Halogens." Journal of Chemical & Engineering Data
52, no. 5 (September 1, 2007): 1509-38. doi:10.1021/je700336g.
.. [11] Ambrose, Douglas, Constantine Tsonopoulos, and Eugene D. Nikitin.
"Vapor-Liquid Critical Properties of Elements and Compounds. 11. Organic
Compounds Containing B + O; Halogens + N, + O, + O + S, + S, + Si;
N + O; and O + S, + Si." Journal of Chemical & Engineering Data 54,
no. 3 (March 12, 2009): 669-89. doi:10.1021/je800580z.
.. [12] Ambrose, Douglas, Constantine Tsonopoulos, Eugene D. Nikitin, David
W. Morton, and Kenneth N. Marsh. "Vapor-Liquid Critical Properties of
Elements and Compounds. 12. Review of Recent Data for Hydrocarbons and
Non-Hydrocarbons." Journal of Chemical & Engineering Data, October 5,
2015, 151005081500002. doi:10.1021/acs.jced.5b00571.
.. [13] Mathews, Joseph F. "Critical Constants of Inorganic Substances."
Chemical Reviews 72, no. 1 (February 1, 1972): 71-100.
doi:10.1021/cr60275a004.
.. [14] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.
.. [15] Horstmann, Sven, Anna Jabłoniec, Jörg Krafczyk, Kai Fischer, and
Jürgen Gmehling. "PSRK Group Contribution Equation of State:
Comprehensive Revision and Extension IV, Including Critical Constants
and Α-Function Parameters for 1000 Components." Fluid Phase Equilibria
227, no. 2 (January 25, 2005): 157-64. doi:10.1016/j.fluid.2004.11.002.
.. [16] Yaws, Carl L. Thermophysical Properties of Chemicals and
Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
Publishing, 2014.
'''
def list_methods():
methods = []
if CASRN in _crit_IUPAC.index and not np.isnan(_crit_IUPAC.at[CASRN, 'Zc']):
methods.append(IUPAC)
if CASRN in _crit_Matthews.index and not np.isnan(_crit_Matthews.at[CASRN, 'Zc']):
methods.append(MATTHEWS)
if CASRN in _crit_CRC.index and not np.isnan(_crit_CRC.at[CASRN, 'Zc']):
methods.append(CRC)
if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'Zc']):
methods.append(PSRK)
if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'Zc']):
methods.append(YAWS)
if Tc(CASRN) and Vc(CASRN) and Pc(CASRN):
methods.append(COMBINED)
if IgnoreMethods:
for Method in IgnoreMethods:
if Method in methods:
methods.remove(Method)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
# This is the calculate, given the method section
if Method == IUPAC:
_Zc = float(_crit_IUPAC.at[CASRN, 'Zc'])
elif Method == PSRK:
_Zc = float(_crit_PSRKR4.at[CASRN, 'Zc'])
elif Method == MATTHEWS:
_Zc = float(_crit_Matthews.at[CASRN, 'Zc'])
elif Method == CRC:
_Zc = float(_crit_CRC.at[CASRN, 'Zc'])
elif Method == YAWS:
_Zc = float(_crit_Yaws.at[CASRN, 'Zc'])
elif Method == COMBINED:
_Zc = Vc(CASRN)*Pc(CASRN)/Tc(CASRN)/R
elif Method == NONE:
return None
else:
raise Exception('Failure in in function')
return _Zc |
def Mersmann_Kind_predictor(atoms, coeff=3.645, power=0.5,
covalent_radii=rcovs_Mersmann_Kind):
r'''Predicts the critical molar volume of a chemical based only on its
atomic composition according to [1]_ and [2]_. This is a crude approach,
but provides very reasonable
estimates in practice. Optionally, the `coeff` used and the `power` in the
fraction as well as the atomic contributions can be adjusted; this method
is general and atomic contributions can be regressed to predict other
properties with this routine.
.. math::
\frac{\left(\frac{V_c}{n_a N_A}\right)^{1/3}}{d_a}
= \frac{3.645}{\left(\frac{r_a}{r_H}\right)^{1/2}}
r_a = d_a/2
d_a = 2 \frac{\sum_i (n_i r_i)}{n_a}
In the above equations, :math:`n_i` is the number of atoms of species i in
the molecule, :math:`r_i` is the covalent atomic radius of the atom, and
:math:`n_a` is the total number of atoms in the molecule.
Parameters
----------
atoms : dict
Dictionary of atoms and their counts, [-]
coeff : float, optional
Coefficient used in the relationship, [m^2]
power : float, optional
Power applied to the relative atomic radius, [-]
covalent_radii : dict or indexable, optional
Object which can be indexed to atomic contrinbutions (by symbol), [-]
Returns
-------
Vc : float
Predicted critical volume of the chemical, [m^3/mol]
Notes
-----
Using the :obj:`thermo.elements.periodic_table` covalent radii (from RDKit),
the coefficient and power should be 4.261206523632586 and 0.5597281770786228
respectively for best results.
Examples
--------
Prediction of critical volume of decane:
>>> Mersmann_Kind_predictor({'C': 10, 'H': 22})
0.0005851859052024729
This is compared against the experimental value, 0.000624 (a 6.2% relative
error)
Using custom fitted coefficients we can do a bit better:
>>> from thermo.critical import rcovs_regressed
>>> Mersmann_Kind_predictor({'C': 10, 'H': 22}, coeff=4.261206523632586,
... power=0.5597281770786228, covalent_radii=rcovs_regressed)
0.0005956871011923075
The relative error is only 4.5% now. This is compared to an experimental
uncertainty of 5.6%.
Evaluating 1321 critical volumes in the database, the average relative
error is 5.0%; standard deviation 6.8%; and worst value of 79% relative
error for phosphorus.
References
----------
.. [1] Mersmann, Alfons, and Matthias Kind. "Correlation for the Prediction
of Critical Molar Volume." Industrial & Engineering Chemistry Research,
October 16, 2017. https://doi.org/10.1021/acs.iecr.7b03171.
.. [2] Mersmann, Alfons, and Matthias Kind. "Prediction of Mechanical and
Thermal Properties of Pure Liquids, of Critical Data, and of Vapor
Pressure." Industrial & Engineering Chemistry Research, January 31,
2017. https://doi.org/10.1021/acs.iecr.6b04323.
'''
H_RADIUS_COV = covalent_radii['H']
tot = 0
atom_count = 0
for atom, count in atoms.items():
if atom not in covalent_radii:
raise Exception('Atom %s is not supported by the supplied dictionary' %atom)
tot += count*covalent_radii[atom]
atom_count += count
da = 2.*tot/atom_count
ra = da/2.
da_SI = da*1e-10 # Convert from angstrom to m
return ((coeff/(ra/H_RADIUS_COV)**power)*da_SI)**3*N_A*atom_count |
def Ihmels(Tc=None, Pc=None, Vc=None):
r'''Most recent, and most recommended method of estimating critical
properties from each other. Two of the three properties are required.
This model uses the "critical surface", a general plot of Tc vs Pc vs Vc.
The model used 421 organic compounds to derive equation.
The general equation is in [1]_:
.. math::
P_c = -0.025 + 2.215 \frac{T_c}{V_c}
Parameters
----------
Tc : float
Critical temperature of fluid (optional) [K]
Pc : float
Critical pressure of fluid (optional) [Pa]
Vc : float
Critical volume of fluid (optional) [m^3/mol]
Returns
-------
Tc, Pc or Vc : float
Critical property of fluid [K], [Pa], or [m^3/mol]
Notes
-----
The prediction of Tc from Pc and Vc is not tested, as this is not necessary
anywhere, but it is implemented.
Internal units are MPa, cm^3/mol, and K. A slight error occurs when
Pa, cm^3/mol and K are used instead, on the order of <0.2%.
Their equation was also compared with 56 inorganic and elements.
Devations of 20% for <200K or >1000K points.
Examples
--------a
Succinic acid [110-15-6]
>>> Ihmels(Tc=851.0, Vc=0.000308)
6095016.233766234
References
----------
.. [1] Ihmels, E. Christian. "The Critical Surface." Journal of Chemical
& Engineering Data 55, no. 9 (September 9, 2010): 3474-80.
doi:10.1021/je100167w.
'''
if Tc and Vc:
Vc = Vc*1E6 # m^3/mol to cm^3/mol
Pc = -0.025+2.215*Tc/Vc
Pc = Pc*1E6 # MPa to Pa
return Pc
elif Tc and Pc:
Pc = Pc/1E6 # Pa to MPa
Vc = 443*Tc/(200*Pc+5)
Vc = Vc/1E6 # cm^3/mol to m^3/mol
return Vc
elif Pc and Vc:
Pc = Pc/1E6 # Pa to MPa
Vc = Vc*1E6 # m^3/mol to cm^3/mol
Tc = 5.0/443*(40*Pc*Vc + Vc)
return Tc
else:
raise Exception('Two of Tc, Pc, and Vc must be provided') |
def Meissner(Tc=None, Pc=None, Vc=None):
r'''Old (1942) relationship for estimating critical
properties from each other. Two of the three properties are required.
This model uses the "critical surface", a general plot of Tc vs Pc vs Vc.
The model used 42 organic and inorganic compounds to derive the equation.
The general equation is in [1]_:
.. math::
P_c = \frac{2.08 T_c}{V_c-8}
Parameters
----------
Tc : float, optional
Critical temperature of fluid [K]
Pc : float, optional
Critical pressure of fluid [Pa]
Vc : float, optional
Critical volume of fluid [m^3/mol]
Returns
-------
Tc, Pc or Vc : float
Critical property of fluid [K], [Pa], or [m^3/mol]
Notes
-----
The prediction of Tc from Pc and Vc is not tested, as this is not necessary
anywhere, but it is implemented.
Internal units are atm, cm^3/mol, and K. A slight error occurs when
Pa, cm^3/mol and K are used instead, on the order of <0.2%.
This equation is less accurate than that of Ihmels, but surprisingly close.
The author also proposed means of estimated properties independently.
Examples
--------
Succinic acid [110-15-6]
>>> Meissner(Tc=851.0, Vc=0.000308)
5978445.199999999
References
----------
.. [1] Meissner, H. P., and E. M. Redding. "Prediction of Critical
Constants." Industrial & Engineering Chemistry 34, no. 5
(May 1, 1942): 521-26. doi:10.1021/ie50389a003.
'''
if Tc and Vc:
Vc = Vc*1E6
Pc = 20.8*Tc/(Vc-8)
Pc = 101325*Pc # atm to Pa
return Pc
elif Tc and Pc:
Pc = Pc/101325. # Pa to atm
Vc = 104/5.0*Tc/Pc+8
Vc = Vc/1E6 # cm^3/mol to m^3/mol
return Vc
elif Pc and Vc:
Pc = Pc/101325. # Pa to atm
Vc = Vc*1E6 # m^3/mol to cm^3/mol
Tc = 5./104.0*Pc*(Vc-8)
return Tc
else:
raise Exception('Two of Tc, Pc, and Vc must be provided') |
def Grigoras(Tc=None, Pc=None, Vc=None):
r'''Relatively recent (1990) relationship for estimating critical
properties from each other. Two of the three properties are required.
This model uses the "critical surface", a general plot of Tc vs Pc vs Vc.
The model used 137 organic and inorganic compounds to derive the equation.
The general equation is in [1]_:
.. math::
P_c = 2.9 + 20.2 \frac{T_c}{V_c}
Parameters
----------
Tc : float
Critical temperature of fluid (optional) [K]
Pc : float
Critical pressure of fluid (optional) [Pa]
Vc : float
Critical volume of fluid (optional) [m^3/mol]
Returns
-------
Tc, Pc or Vc : float
Critical property of fluid [K], [Pa], or [m^3/mol]
Notes
-----
The prediction of Tc from Pc and Vc is not tested, as this is not necessary
anywhere, but it is implemented.
Internal units are bar, cm^3/mol, and K. A slight error occurs when
Pa, cm^3/mol and K are used instead, on the order of <0.2%.
This equation is less accurate than that of Ihmels, but surprisingly close.
The author also investigated an early QSPR model.
Examples
--------
Succinic acid [110-15-6]
>>> Grigoras(Tc=851.0, Vc=0.000308)
5871233.766233766
References
----------
.. [1] Grigoras, Stelian. "A Structural Approach to Calculate Physical
Properties of Pure Organic Substances: The Critical Temperature,
Critical Volume and Related Properties." Journal of Computational
Chemistry 11, no. 4 (May 1, 1990): 493-510.
doi:10.1002/jcc.540110408
'''
if Tc and Vc:
Vc = Vc*1E6 # m^3/mol to cm^3/mol
Pc = 2.9 + 20.2*Tc/Vc
Pc = Pc*1E5 # bar to Pa
return Pc
elif Tc and Pc:
Pc = Pc/1E5 # Pa to bar
Vc = 202.0*Tc/(10*Pc-29.0)
Vc = Vc/1E6 # cm^3/mol to m^3/mol
return Vc
elif Pc and Vc:
Pc = Pc/1E5 # Pa to bar
Vc = Vc*1E6 # m^3/mol to cm^3/mol
Tc = 1.0/202*(10*Pc-29.0)*Vc
return Tc
else:
raise Exception('Two of Tc, Pc, and Vc must be provided') |
def critical_surface(Tc=None, Pc=None, Vc=None, AvailableMethods=False,
Method=None):
r'''Function for calculating a critical property of a substance from its
other two critical properties. Calls functions Ihmels, Meissner, and
Grigoras, each of which use a general 'Critical surface' type of equation.
Limited accuracy is expected due to very limited theoretical backing.
Parameters
----------
Tc : float
Critical temperature of fluid (optional) [K]
Pc : float
Critical pressure of fluid (optional) [Pa]
Vc : float
Critical volume of fluid (optional) [m^3/mol]
AvailableMethods : bool
Request available methods for given parameters
Method : string
Request calculation uses the requested method
Returns
-------
Tc, Pc or Vc : float
Critical property of fluid [K], [Pa], or [m^3/mol]
Notes
-----
Examples
--------
Decamethyltetrasiloxane [141-62-8]
>>> critical_surface(Tc=599.4, Pc=1.19E6, Method='IHMELS')
0.0010927333333333334
'''
def list_methods():
methods = []
if (Tc and Pc) or (Tc and Vc) or (Pc and Vc):
methods.append(IHMELS)
methods.append(MEISSNER)
methods.append(GRIGORAS)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
# This is the calculate, given the method section
if Method == IHMELS:
Third = Ihmels(Tc=Tc, Pc=Pc, Vc=Vc)
elif Method == MEISSNER:
Third = Meissner(Tc=Tc, Pc=Pc, Vc=Vc)
elif Method == GRIGORAS:
Third = Grigoras(Tc=Tc, Pc=Pc, Vc=Vc)
elif Method == NONE:
Third = None
else:
raise Exception('Failure in in function')
return Third |
def third_property(CASRN=None, T=False, P=False, V=False):
r'''Function for calculating a critical property of a substance from its
other two critical properties, but retrieving the actual other critical
values for convenient calculation.
Calls functions Ihmels, Meissner, and
Grigoras, each of which use a general 'Critical surface' type of equation.
Limited accuracy is expected due to very limited theoretical backing.
Parameters
----------
CASRN : string
The CAS number of the desired chemical
T : bool
Estimate critical temperature
P : bool
Estimate critical pressure
V : bool
Estimate critical volume
Returns
-------
Tc, Pc or Vc : float
Critical property of fluid [K], [Pa], or [m^3/mol]
Notes
-----
Avoids recursion only by eliminating the None and critical surface options
for calculating each critical property. So long as it never calls itself.
Note that when used by Tc, Pc or Vc, this function results in said function
calling the other functions (to determine methods) and (with method specified)
Examples
--------
>>> # Decamethyltetrasiloxane [141-62-8]
>>> third_property('141-62-8', V=True)
0.0010920041152263375
>>> # Succinic acid 110-15-6
>>> third_property('110-15-6', P=True)
6095016.233766234
'''
Third = None
if V:
Tc_methods = Tc(CASRN, AvailableMethods=True)[0:-2]
Pc_methods = Pc(CASRN, AvailableMethods=True)[0:-2]
if Tc_methods and Pc_methods:
_Tc = Tc(CASRN=CASRN, Method=Tc_methods[0])
_Pc = Pc(CASRN=CASRN, Method=Pc_methods[0])
Third = critical_surface(Tc=_Tc, Pc=_Pc, Vc=None)
elif P:
Tc_methods = Tc(CASRN, AvailableMethods=True)[0:-2]
Vc_methods = Vc(CASRN, AvailableMethods=True)[0:-2]
if Tc_methods and Vc_methods:
_Tc = Tc(CASRN=CASRN, Method=Tc_methods[0])
_Vc = Vc(CASRN=CASRN, Method=Vc_methods[0])
Third = critical_surface(Tc=_Tc, Vc=_Vc, Pc=None)
elif T:
Pc_methods = Pc(CASRN, AvailableMethods=True)[0:-2]
Vc_methods = Vc(CASRN, AvailableMethods=True)[0:-2]
if Pc_methods and Vc_methods:
_Pc = Pc(CASRN=CASRN, Method=Pc_methods[0])
_Vc = Vc(CASRN=CASRN, Method=Vc_methods[0])
Third = critical_surface(Pc=_Pc, Vc=_Vc, Tc=None)
else:
raise Exception('Error in function')
if not Third:
return None
return Third |
def Li(zs, Tcs, Vcs):
r'''Calculates critical temperature of a mixture according to
mixing rules in [1]_. Better than simple mixing rules.
.. math::
T_{cm} = \sum_{i=1}^n \Phi_i T_{ci}\\
\Phi = \frac{x_i V_{ci}}{\sum_{j=1}^n x_j V_{cj}}
Parameters
----------
zs : array-like
Mole fractions of all components
Tcs : array-like
Critical temperatures of all components, [K]
Vcs : array-like
Critical volumes of all components, [m^3/mol]
Returns
-------
Tcm : float
Critical temperatures of the mixture, [K]
Notes
-----
Reviewed in many papers on critical mixture temperature.
Second example is from Najafi (2015), for ethylene, Benzene, ethylbenzene.
This is similar to but not identical to the result from the article. The
experimental point is 486.9 K.
2rd example is from Najafi (2015), for:
butane/pentane/hexane 0.6449/0.2359/0.1192 mixture, exp: 450.22 K.
Its result is identical to that calculated in the article.
Examples
--------
Nitrogen-Argon 50/50 mixture
>>> Li([0.5, 0.5], [126.2, 150.8], [8.95e-05, 7.49e-05])
137.40766423357667
butane/pentane/hexane 0.6449/0.2359/0.1192 mixture, exp: 450.22 K.
>>> Li([0.6449, 0.2359, 0.1192], [425.12, 469.7, 507.6],
... [0.000255, 0.000313, 0.000371])
449.68261498555444
References
----------
.. [1] Li, C. C. "Critical Temperature Estimation for Simple Mixtures."
The Canadian Journal of Chemical Engineering 49, no. 5
(October 1, 1971): 709-10. doi:10.1002/cjce.5450490529.
'''
if not none_and_length_check([zs, Tcs, Vcs]):
raise Exception('Function inputs are incorrect format')
denominator = sum(zs[i]*Vcs[i] for i in range(len(zs)))
Tcm = 0
for i in range(len(zs)):
Tcm += zs[i]*Vcs[i]*Tcs[i]/denominator
return Tcm |
def Chueh_Prausnitz_Tc(zs, Tcs, Vcs, taus):
r'''Calculates critical temperature of a mixture according to
mixing rules in [1]_.
.. math::
T_{cm} = \sum_i^n \theta_i Tc_i + \sum_i^n\sum_j^n(\theta_i \theta_j
\tau_{ij})T_{ref}
\theta = \frac{x_i V_{ci}^{2/3}}{\sum_{j=1}^n x_j V_{cj}^{2/3}}
For a binary mxiture, this simplifies to:
.. math::
T_{cm} = \theta_1T_{c1} + \theta_2T_{c2} + 2\theta_1\theta_2\tau_{12}
Parameters
----------
zs : array-like
Mole fractions of all components
Tcs : array-like
Critical temperatures of all components, [K]
Vcs : array-like
Critical volumes of all components, [m^3/mol]
taus : array-like of shape `zs` by `zs`
Interaction parameters
Returns
-------
Tcm : float
Critical temperatures of the mixture, [K]
Notes
-----
All parameters, even if zero, must be given to this function.
Examples
--------
butane/pentane/hexane 0.6449/0.2359/0.1192 mixture, exp: 450.22 K.
>>> Chueh_Prausnitz_Tc([0.6449, 0.2359, 0.1192], [425.12, 469.7, 507.6],
... [0.000255, 0.000313, 0.000371], [[0, 1.92681, 6.80358],
... [1.92681, 0, 1.89312], [ 6.80358, 1.89312, 0]])
450.1225764723492
References
----------
.. [1] Chueh, P. L., and J. M. Prausnitz. "Vapor-Liquid Equilibria at High
Pressures: Calculation of Critical Temperatures, Volumes, and Pressures
of Nonpolar Mixtures." AIChE Journal 13, no. 6 (November 1, 1967):
1107-13. doi:10.1002/aic.690130613.
.. [2] Najafi, Hamidreza, Babak Maghbooli, and Mohammad Amin Sobati.
"Prediction of True Critical Temperature of Multi-Component Mixtures:
Extending Fast Estimation Methods." Fluid Phase Equilibria 392
(April 25, 2015): 104-26. doi:10.1016/j.fluid.2015.02.001.
'''
if not none_and_length_check([zs, Tcs, Vcs]):
raise Exception('Function inputs are incorrect format')
denominator = sum(zs[i]*Vcs[i]**(2/3.) for i in range(len(zs)))
Tcm = 0
for i in range(len(zs)):
Tcm += zs[i]*Vcs[i]**(2/3.)*Tcs[i]/denominator
for j in range(len(zs)):
Tcm += (zs[i]*Vcs[i]**(2/3.)/denominator)*(zs[j]*Vcs[j]**(2/3.)/denominator)*taus[i][j]
return Tcm |
def Grieves_Thodos(zs, Tcs, Aijs):
r'''Calculates critical temperature of a mixture according to
mixing rules in [1]_.
.. math::
T_{cm} = \sum_{i} \frac{T_{ci}}{1 + (1/x_i)\sum_j A_{ij} x_j}
For a binary mxiture, this simplifies to:
.. math::
T_{cm} = \frac{T_{c1}}{1 + (x_2/x_1)A_{12}} + \frac{T_{c2}}
{1 + (x_1/x_2)A_{21}}
Parameters
----------
zs : array-like
Mole fractions of all components
Tcs : array-like
Critical temperatures of all components, [K]
Aijs : array-like of shape `zs` by `zs`
Interaction parameters
Returns
-------
Tcm : float
Critical temperatures of the mixture, [K]
Notes
-----
All parameters, even if zero, must be given to this function.
Giving 0s gives really bad results however.
Examples
--------
butane/pentane/hexane 0.6449/0.2359/0.1192 mixture, exp: 450.22 K.
>>> Grieves_Thodos([0.6449, 0.2359, 0.1192], [425.12, 469.7, 507.6], [[0, 1.2503, 1.516], [0.799807, 0, 1.23843], [0.659633, 0.807474, 0]])
450.1839618758971
References
----------
.. [1] Grieves, Robert B., and George Thodos. "The Critical Temperatures of
Multicomponent Hydrocarbon Systems." AIChE Journal 8, no. 4
(September 1, 1962): 550-53. doi:10.1002/aic.690080426.
.. [2] Najafi, Hamidreza, Babak Maghbooli, and Mohammad Amin Sobati.
"Prediction of True Critical Temperature of Multi-Component Mixtures:
Extending Fast Estimation Methods." Fluid Phase Equilibria 392
(April 25, 2015): 104-26. doi:10.1016/j.fluid.2015.02.001.
'''
if not none_and_length_check([zs, Tcs]):
raise Exception('Function inputs are incorrect format')
Tcm = 0
for i in range(len(zs)):
Tcm += Tcs[i]/(1. + 1./zs[i]*sum(Aijs[i][j]*zs[j] for j in range(len(zs))))
return Tcm |
def modified_Wilson_Tc(zs, Tcs, Aijs):
r'''Calculates critical temperature of a mixture according to
mixing rules in [1]_. Equation
.. math::
T_{cm} = \sum_i x_i T_{ci} + C\sum_i x_i \ln \left(x_i + \sum_j x_j A_{ij}\right)T_{ref}
For a binary mxiture, this simplifies to:
.. math::
T_{cm} = x_1 T_{c1} + x_2 T_{c2} + C[x_1 \ln(x_1 + x_2A_{12}) + x_2\ln(x_2 + x_1 A_{21})]
Parameters
----------
zs : float
Mole fractions of all components
Tcs : float
Critical temperatures of all components, [K]
Aijs : matrix
Interaction parameters
Returns
-------
Tcm : float
Critical temperatures of the mixture, [K]
Notes
-----
The equation and original article has been reviewed.
[1]_ has 75 binary systems, and additional multicomponent mixture parameters.
All parameters, even if zero, must be given to this function.
2rd example is from [2]_, for:
butane/pentane/hexane 0.6449/0.2359/0.1192 mixture, exp: 450.22 K.
Its result is identical to that calculated in the article.
Examples
--------
>>> modified_Wilson_Tc([0.6449, 0.2359, 0.1192], [425.12, 469.7, 507.6],
... [[0, 1.174450, 1.274390], [0.835914, 0, 1.21038],
... [0.746878, 0.80677, 0]])
450.0305966823031
References
----------
.. [1] Teja, Amyn S., Kul B. Garg, and Richard L. Smith. "A Method for the
Calculation of Gas-Liquid Critical Temperatures and Pressures of
Multicomponent Mixtures." Industrial & Engineering Chemistry Process
Design and Development 22, no. 4 (1983): 672-76.
.. [2] Najafi, Hamidreza, Babak Maghbooli, and Mohammad Amin Sobati.
"Prediction of True Critical Temperature of Multi-Component Mixtures:
Extending Fast Estimation Methods." Fluid Phase Equilibria 392
(April 25, 2015): 104-26. doi:10.1016/j.fluid.2015.02.001.
'''
if not none_and_length_check([zs, Tcs]):
raise Exception('Function inputs are incorrect format')
C = -2500
Tcm = sum(zs[i]*Tcs[i] for i in range(len(zs)))
for i in range(len(zs)):
Tcm += C*zs[i]*log(zs[i] + sum(zs[j]*Aijs[i][j] for j in range(len(zs))))
return Tcm |
def Tc_mixture(Tcs=None, zs=None, CASRNs=None, AvailableMethods=False, Method=None): # pragma: no cover
'''This function handles the retrival of a mixture's critical temperature.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> Tc_mixture([400, 550], [0.3, 0.7])
505.0
'''
def list_methods():
methods = []
if none_and_length_check([Tcs]):
methods.append('Simple')
methods.append('None')
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
# This is the calculate, given the method section
if Method == 'Simple':
return mixing_simple(zs, Tcs)
elif Method == 'None':
return None
else:
raise Exception('Failure in in function') |
def Pc_mixture(Pcs=None, zs=None, CASRNs=None, AvailableMethods=False, Method=None): # pragma: no cover
'''This function handles the retrival of a mixture's critical temperature.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> Pc_mixture([2.2E7, 1.1E7], [0.3, 0.7])
14300000.0
'''
def list_methods():
methods = []
if none_and_length_check([Pcs]):
methods.append('Simple')
methods.append('None')
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
# This is the calculate, given the method section
if Method == 'Simple':
return mixing_simple(zs, Pcs)
elif Method == 'None':
return None
else:
raise Exception('Failure in in function') |
def Chueh_Prausnitz_Vc(zs, Vcs, nus):
r'''Calculates critical volume of a mixture according to
mixing rules in [1]_ with an interaction parameter.
.. math::
V_{cm} = \sum_i^n \theta_i V_{ci} + \sum_i^n\sum_j^n(\theta_i \theta_j \nu_{ij})V_{ref}
\theta = \frac{x_i V_{ci}^{2/3}}{\sum_{j=1}^n x_j V_{cj}^{2/3}}
Parameters
----------
zs : float
Mole fractions of all components
Vcs : float
Critical volumes of all components, [m^3/mol]
nus : matrix
Interaction parameters, [cm^3/mol]
Returns
-------
Vcm : float
Critical volume of the mixture, [m^3/mol]
Notes
-----
All parameters, even if zero, must be given to this function.
nu parameters are in cm^3/mol, but are converted to m^3/mol inside the function
Examples
--------
1-butanol/benzene 0.4271/0.5729 mixture, Vcm = 268.096 mL/mol.
>>> Chueh_Prausnitz_Vc([0.4271, 0.5729], [0.000273, 0.000256], [[0, 5.61847], [5.61847, 0]])
0.00026620503424517445
References
----------
.. [1] Chueh, P. L., and J. M. Prausnitz. "Vapor-Liquid Equilibria at High
Pressures: Calculation of Critical Temperatures, Volumes, and Pressures
of Nonpolar Mixtures." AIChE Journal 13, no. 6 (November 1, 1967):
1107-13. doi:10.1002/aic.690130613.
.. [2] Najafi, Hamidreza, Babak Maghbooli, and Mohammad Amin Sobati.
"Prediction of True Critical Volume of Multi-Component Mixtures:
Extending Fast Estimation Methods." Fluid Phase Equilibria 386
(January 25, 2015): 13-29. doi:10.1016/j.fluid.2014.11.008.
'''
if not none_and_length_check([zs, Vcs]): # check same-length inputs
raise Exception('Function inputs are incorrect format')
denominator = sum(zs[i]*Vcs[i]**(2/3.) for i in range(len(zs)))
Vcm = 0
for i in range(len(zs)):
Vcm += zs[i]*Vcs[i]**(2/3.)*Vcs[i]/denominator
for j in range(len(zs)):
Vcm += (zs[i]*Vcs[i]**(2/3.)/denominator)*(zs[j]*Vcs[j]**(2/3.)/denominator)*nus[i][j]/1E6
return Vcm |
def modified_Wilson_Vc(zs, Vcs, Aijs):
r'''Calculates critical volume of a mixture according to
mixing rules in [1]_ with parameters. Equation
.. math::
V_{cm} = \sum_i x_i V_{ci} + C\sum_i x_i \ln \left(x_i + \sum_j x_j A_{ij}\right)V_{ref}
For a binary mxiture, this simplifies to:
.. math::
V_{cm} = x_1 V_{c1} + x_2 V_{c2} + C[x_1 \ln(x_1 + x_2A_{12}) + x_2\ln(x_2 + x_1 A_{21})]
Parameters
----------
zs : float
Mole fractions of all components
Vcs : float
Critical volumes of all components, [m^3/mol]
Aijs : matrix
Interaction parameters, [cm^3/mol]
Returns
-------
Vcm : float
Critical volume of the mixture, [m^3/mol]
Notes
-----
The equation and original article has been reviewed.
All parameters, even if zero, must be given to this function.
C = -2500
All parameters, even if zero, must be given to this function.
nu parameters are in cm^3/mol, but are converted to m^3/mol inside the function
Examples
--------
1-butanol/benzene 0.4271/0.5729 mixture, Vcm = 268.096 mL/mol.
>>> modified_Wilson_Vc([0.4271, 0.5729], [0.000273, 0.000256],
... [[0, 0.6671250], [1.3939900, 0]])
0.0002664335032706881
References
----------
.. [1] Teja, Amyn S., Kul B. Garg, and Richard L. Smith. "A Method for the
Calculation of Gas-Liquid Critical Temperatures and Pressures of
Multicomponent Mixtures." Industrial & Engineering Chemistry Process
Design and Development 22, no. 4 (1983): 672-76.
.. [2] Najafi, Hamidreza, Babak Maghbooli, and Mohammad Amin Sobati.
"Prediction of True Critical Temperature of Multi-Component Mixtures:
Extending Fast Estimation Methods." Fluid Phase Equilibria 392
(April 25, 2015): 104-26. doi:10.1016/j.fluid.2015.02.001.
'''
if not none_and_length_check([zs, Vcs]): # check same-length inputs
raise Exception('Function inputs are incorrect format')
C = -2500
Vcm = sum(zs[i]*Vcs[i] for i in range(len(zs)))
for i in range(len(zs)):
Vcm += C*zs[i]*log(zs[i] + sum(zs[j]*Aijs[i][j] for j in range(len(zs))))/1E6
return Vcm |
def Vc_mixture(Vcs=None, zs=None, CASRNs=None, AvailableMethods=False, Method=None): # pragma: no cover
'''This function handles the retrival of a mixture's critical temperature.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> Vc_mixture([5.6E-5, 2E-4], [0.3, 0.7])
0.0001568
'''
def list_methods():
methods = []
if none_and_length_check([Vcs]):
methods.append('Simple')
methods.append('None')
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
# This is the calculate, given the method section
if Method == 'Simple':
return mixing_simple(zs, Vcs)
elif Method == 'None':
return None
else:
raise Exception('Failure in in function') |
def checkCAS(CASRN):
'''Checks if a CAS number is valid. Returns False if the parser cannot
parse the given string..
Parameters
----------
CASRN : string
A three-piece, dash-separated set of numbers
Returns
-------
result : bool
Boolean value if CASRN was valid. If parsing fails, return False also.
Notes
-----
Check method is according to Chemical Abstract Society. However, no lookup
to their service is performed; therefore, this function cannot detect
false positives.
Function also does not support additional separators, apart from '-'.
CAS numbers up to the series 1 XXX XXX-XX-X are now being issued.
A long can hold CAS numbers up to 2 147 483-64-7
Examples
--------
>>> checkCAS('7732-18-5')
True
>>> checkCAS('77332-18-5')
False
'''
try:
check = CASRN[-1]
CASRN = CASRN[::-1][1:]
productsum = 0
i = 1
for num in CASRN:
if num == '-':
pass
else:
productsum += i*int(num)
i += 1
return (productsum % 10 == int(check))
except:
return False |
def CAS_from_any(ID, autoload=False):
'''Looks up the CAS number of a chemical by searching and testing for the
string being any of the following types of chemical identifiers:
* Name, in IUPAC form or common form or a synonym registered in PubChem
* InChI name, prefixed by 'InChI=1S/' or 'InChI=1/'
* InChI key, prefixed by 'InChIKey='
* PubChem CID, prefixed by 'PubChem='
* SMILES (prefix with 'SMILES=' to ensure smiles parsing; ex.
'C' will return Carbon as it is an element whereas the SMILES
interpretation for 'C' is methane)
* CAS number (obsolete numbers may point to the current number)
If the input is an ID representing an element, the following additional
inputs may be specified as
* Atomic symbol (ex 'Na')
* Atomic number (as a string)
Parameters
----------
ID : str
One of the name formats described above
Returns
-------
CASRN : string
A three-piece, dash-separated set of numbers
Notes
-----
An exception is raised if the name cannot be identified. The PubChem
database includes a wide variety of other synonyms, but these may not be
present for all chemcials.
Examples
--------
>>> CAS_from_any('water')
'7732-18-5'
>>> CAS_from_any('InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3')
'64-17-5'
>>> CAS_from_any('CCCCCCCCCC')
'124-18-5'
>>> CAS_from_any('InChIKey=LFQSCWFLJHTTHZ-UHFFFAOYSA-N')
'64-17-5'
>>> CAS_from_any('pubchem=702')
'64-17-5'
>>> CAS_from_any('O') # only elements can be specified by symbol
'17778-80-2'
'''
ID = ID.strip()
ID_lower = ID.lower()
if ID in periodic_table:
if periodic_table[ID].number not in homonuclear_elemental_gases:
return periodic_table[ID].CAS
else:
for i in [periodic_table.symbol_to_elements,
periodic_table.number_to_elements,
periodic_table.CAS_to_elements]:
if i == periodic_table.number_to_elements:
if int(ID in i):
return periodic_table[int(ID)].CAS
else:
if ID in i:
return periodic_table[ID].CAS
if checkCAS(ID):
CAS_lookup = pubchem_db.search_CAS(ID, autoload)
if CAS_lookup:
return CAS_lookup.CASs
# handle the case of synonyms
CAS_alternate_loopup = pubchem_db.search_name(ID, autoload)
if CAS_alternate_loopup:
return CAS_alternate_loopup.CASs
if not autoload:
return CAS_from_any(ID, autoload=True)
raise Exception('A valid CAS number was recognized, but is not in the database')
ID_len = len(ID)
if ID_len > 9:
inchi_search = False
# normal upper case is 'InChI=1S/'
if ID_lower[0:9] == 'inchi=1s/':
inchi_search = ID[9:]
elif ID_lower[0:8] == 'inchi=1/':
inchi_search = ID[8:]
if inchi_search:
inchi_lookup = pubchem_db.search_InChI(inchi_search, autoload)
if inchi_lookup:
return inchi_lookup.CASs
else:
if not autoload:
return CAS_from_any(ID, autoload=True)
raise Exception('A valid InChI name was recognized, but it is not in the database')
if ID_lower[0:9] == 'inchikey=':
inchi_key_lookup = pubchem_db.search_InChI_key(ID[9:], autoload)
if inchi_key_lookup:
return inchi_key_lookup.CASs
else:
if not autoload:
return CAS_from_any(ID, autoload=True)
raise Exception('A valid InChI Key was recognized, but it is not in the database')
if ID_len > 8:
if ID_lower[0:8] == 'pubchem=':
pubchem_lookup = pubchem_db.search_pubchem(ID[8:], autoload)
if pubchem_lookup:
return pubchem_lookup.CASs
else:
if not autoload:
return CAS_from_any(ID, autoload=True)
raise Exception('A PubChem integer identifier was recognized, but it is not in the database.')
if ID_len > 7:
if ID_lower[0:7] == 'smiles=':
smiles_lookup = pubchem_db.search_smiles(ID[7:], autoload)
if smiles_lookup:
return smiles_lookup.CASs
else:
if not autoload:
return CAS_from_any(ID, autoload=True)
raise Exception('A SMILES identifier was recognized, but it is not in the database.')
# Try the smiles lookup anyway
# Parsing SMILES is an option, but this is faster
# Pybel API also prints messages to console on failure
smiles_lookup = pubchem_db.search_smiles(ID, autoload)
if smiles_lookup:
return smiles_lookup.CASs
try:
formula_query = pubchem_db.search_formula(serialize_formula(ID), autoload)
if formula_query and type(formula_query) == ChemicalMetadata:
return formula_query.CASs
except:
pass
# Try a direct lookup with the name - the fastest
name_lookup = pubchem_db.search_name(ID, autoload)
if name_lookup:
return name_lookup.CASs
# Permutate through various name options
ID_no_space = ID.replace(' ', '')
ID_no_space_dash = ID_no_space.replace('-', '')
for name in [ID, ID_no_space, ID_no_space_dash]:
for name2 in [name, name.lower()]:
name_lookup = pubchem_db.search_name(name2, autoload)
if name_lookup:
return name_lookup.CASs
if ID[-1] == ')' and '(' in ID:#
# Try to matck in the form 'water (H2O)'
first_identifier, second_identifier = ID[0:-1].split('(', 1)
try:
CAS1 = CAS_from_any(first_identifier)
CAS2 = CAS_from_any(second_identifier)
assert CAS1 == CAS2
return CAS1
except:
pass
if not autoload:
return CAS_from_any(ID, autoload=True)
raise Exception('Chemical name not recognized') |
def mixture_from_any(ID):
'''Looks up a string which may represent a mixture in the database of
thermo to determine the key by which the composition of that mixture can
be obtained in the dictionary `_MixtureDict`.
Parameters
----------
ID : str
A string or 1-element list containing the name which may represent a
mixture.
Returns
-------
key : str
Key for access to the data on the mixture in `_MixtureDict`.
Notes
-----
White space, '-', and upper case letters are removed in the search.
Examples
--------
>>> mixture_from_any('R512A')
'R512A'
>>> mixture_from_any([u'air'])
'Air'
'''
if type(ID) == list:
if len(ID) == 1:
ID = ID[0]
else:
raise Exception('If the input is a list, the list must contain only one item.')
ID = ID.lower().strip()
ID2 = ID.replace(' ', '')
ID3 = ID.replace('-', '')
for i in [ID, ID2, ID3]:
if i in _MixtureDictLookup:
return _MixtureDictLookup[i]
raise Exception('Mixture name not recognized') |
def charge(self):
'''Charge of the species as an integer. Computed as a property as most
species do not have a charge and so storing it would be a waste of
memory.
'''
try:
return self._charge
except AttributeError:
self._charge = charge_from_formula(self.formula)
return self._charge |
def load_included_indentifiers(self, file_name):
'''Loads a file with newline-separated integers representing which
chemical should be kept in memory; ones not included are ignored.
'''
self.restrict_identifiers = True
included_identifiers = set()
with open(file_name) as f:
[included_identifiers.add(int(line)) for line in f]
self.included_identifiers = included_identifiers |
def EQ100(T, A=0, B=0, C=0, D=0, E=0, F=0, G=0, order=0):
r'''DIPPR Equation # 100. Used in calculating the molar heat capacities
of liquids and solids, liquid thermal conductivity, and solid density.
All parameters default to zero. As this is a straightforward polynomial,
no restrictions on parameters apply. Note that high-order polynomials like
this may need large numbers of decimal places to avoid unnecessary error.
.. math::
Y = A + BT + CT^2 + DT^3 + ET^4 + FT^5 + GT^6
Parameters
----------
T : float
Temperature, [K]
A-G : float
Parameter for the equation; chemical and property specific [-]
order : int, optional
Order of the calculation. 0 for the calculation of the result itself;
for 1, the first derivative of the property is returned, for
-1, the indefinite integral of the property with respect to temperature
is returned; and for -1j, the indefinite integral of the property
divided by temperature with respect to temperature is returned. No
other integrals or derivatives are implemented, and an exception will
be raised if any other order is given.
Returns
-------
Y : float
Property [constant-specific; if order == 1, property/K; if order == -1,
property*K; if order == -1j, unchanged from default]
Notes
-----
The derivative with respect to T, integral with respect to T, and integral
over T with respect to T are computed as follows. All derivatives and
integrals are easily computed with SymPy.
.. math::
\frac{d Y}{dT} = B + 2 C T + 3 D T^{2} + 4 E T^{3} + 5 F T^{4}
+ 6 G T^{5}
.. math::
\int Y dT = A T + \frac{B T^{2}}{2} + \frac{C T^{3}}{3} + \frac{D
T^{4}}{4} + \frac{E T^{5}}{5} + \frac{F T^{6}}{6} + \frac{G T^{7}}{7}
.. math::
\int \frac{Y}{T} dT = A \log{\left (T \right )} + B T + \frac{C T^{2}}
{2} + \frac{D T^{3}}{3} + \frac{E T^{4}}{4} + \frac{F T^{5}}{5}
+ \frac{G T^{6}}{6}
Examples
--------
Water liquid heat capacity; DIPPR coefficients normally listed in J/kmol/K.
>>> EQ100(300, 276370., -2090.1, 8.125, -0.014116, 0.0000093701)
75355.81000000003
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
if order == 0:
return A + T*(B + T*(C + T*(D + T*(E + T*(F + G*T)))))
elif order == 1:
return B + T*(2*C + T*(3*D + T*(4*E + T*(5*F + 6*G*T))))
elif order == -1:
return T*(A + T*(B/2 + T*(C/3 + T*(D/4 + T*(E/5 + T*(F/6 + G*T/7))))))
elif order == -1j:
return A*log(T) + T*(B + T*(C/2 + T*(D/3 + T*(E/4 + T*(F/5 + G*T/6)))))
else:
raise Exception(order_not_found_msg) |
def EQ102(T, A, B, C, D, order=0):
r'''DIPPR Equation # 102. Used in calculating vapor viscosity, vapor
thermal conductivity, and sometimes solid heat capacity. High values of B
raise an OverflowError.
All 4 parameters are required. C and D are often 0.
.. math::
Y = \frac{A\cdot T^B}{1 + \frac{C}{T} + \frac{D}{T^2}}
Parameters
----------
T : float
Temperature, [K]
A-D : float
Parameter for the equation; chemical and property specific [-]
order : int, optional
Order of the calculation. 0 for the calculation of the result itself;
for 1, the first derivative of the property is returned, for
-1, the indefinite integral of the property with respect to temperature
is returned; and for -1j, the indefinite integral of the property
divided by temperature with respect to temperature is returned. No
other integrals or derivatives are implemented, and an exception will
be raised if any other order is given.
Returns
-------
Y : float
Property [constant-specific; if order == 1, property/K; if order == -1,
property*K; if order == -1j, unchanged from default]
Notes
-----
The derivative with respect to T, integral with respect to T, and integral
over T with respect to T are computed as follows. The first derivative is
easily computed; the two integrals required Rubi to perform the integration.
.. math::
\frac{d Y}{dT} = \frac{A B T^{B}}{T \left(\frac{C}{T} + \frac{D}{T^{2}}
+ 1\right)} + \frac{A T^{B} \left(\frac{C}{T^{2}} + \frac{2 D}{T^{3}}
\right)}{\left(\frac{C}{T} + \frac{D}{T^{2}} + 1\right)^{2}}
.. math::
\int Y dT = - \frac{2 A T^{B + 3} \operatorname{hyp2f1}{\left (1,B + 3,
B + 4,- \frac{2 T}{C - \sqrt{C^{2} - 4 D}} \right )}}{\left(B + 3\right)
\left(C + \sqrt{C^{2} - 4 D}\right) \sqrt{C^{2} - 4 D}} + \frac{2 A
T^{B + 3} \operatorname{hyp2f1}{\left (1,B + 3,B + 4,- \frac{2 T}{C
+ \sqrt{C^{2} - 4 D}} \right )}}{\left(B + 3\right) \left(C
- \sqrt{C^{2} - 4 D}\right) \sqrt{C^{2} - 4 D}}
.. math::
\int \frac{Y}{T} dT = - \frac{2 A T^{B + 2} \operatorname{hyp2f1}{\left
(1,B + 2,B + 3,- \frac{2 T}{C + \sqrt{C^{2} - 4 D}} \right )}}{\left(B
+ 2\right) \left(C + \sqrt{C^{2} - 4 D}\right) \sqrt{C^{2} - 4 D}}
+ \frac{2 A T^{B + 2} \operatorname{hyp2f1}{\left (1,B + 2,B + 3,
- \frac{2 T}{C - \sqrt{C^{2} - 4 D}} \right )}}{\left(B + 2\right)
\left(C - \sqrt{C^{2} - 4 D}\right) \sqrt{C^{2} - 4 D}}
Examples
--------
Water vapor viscosity; DIPPR coefficients normally listed in Pa*s.
>>> EQ102(300, 1.7096E-8, 1.1146, 0, 0)
9.860384711890639e-06
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
if order == 0:
return A*T**B/(1. + C/T + D/(T*T))
elif order == 1:
return (A*B*T**B/(T*(C/T + D/T**2 + 1))
+ A*T**B*(C/T**2 + 2*D/T**3)/(C/T + D/T**2 + 1)**2)
elif order == -1:
# imaginary part is 0
return (2*A*T**(3+B)*hyp2f1(1, 3+B, 4+B, -2*T/(C - csqrt(C*C
- 4*D)))/((3+B)*(C - csqrt(C*C-4*D))*csqrt(C*C-4*D))
-2*A*T**(3+B)*hyp2f1(1, 3+B, 4+B, -2*T/(C + csqrt(C*C - 4*D)))/(
(3+B)*(C + csqrt(C*C-4*D))*csqrt(C*C-4*D))).real
elif order == -1j:
return (2*A*T**(2+B)*hyp2f1(1, 2+B, 3+B, -2*T/(C - csqrt(C*C - 4*D)))/(
(2+B)*(C - csqrt(C*C-4*D))*csqrt(C*C-4*D)) -2*A*T**(2+B)*hyp2f1(
1, 2+B, 3+B, -2*T/(C + csqrt(C*C - 4*D)))/((2+B)*(C + csqrt(
C*C-4*D))*csqrt(C*C-4*D))).real
else:
raise Exception(order_not_found_msg) |
def EQ104(T, A, B, C, D, E, order=0):
r'''DIPPR Equation #104. Often used in calculating second virial
coefficients of gases. All 5 parameters are required.
C, D, and E are normally large values.
.. math::
Y = A + \frac{B}{T} + \frac{C}{T^3} + \frac{D}{T^8} + \frac{E}{T^9}
Parameters
----------
T : float
Temperature, [K]
A-E : float
Parameter for the equation; chemical and property specific [-]
order : int, optional
Order of the calculation. 0 for the calculation of the result itself;
for 1, the first derivative of the property is returned, for
-1, the indefinite integral of the property with respect to temperature
is returned; and for -1j, the indefinite integral of the property
divided by temperature with respect to temperature is returned. No
other integrals or derivatives are implemented, and an exception will
be raised if any other order is given.
Returns
-------
Y : float
Property [constant-specific; if order == 1, property/K; if order == -1,
property*K; if order == -1j, unchanged from default]
Notes
-----
The derivative with respect to T, integral with respect to T, and integral
over T with respect to T are computed as follows. All expressions can be
obtained with SymPy readily.
.. math::
\frac{d Y}{dT} = - \frac{B}{T^{2}} - \frac{3 C}{T^{4}}
- \frac{8 D}{T^{9}} - \frac{9 E}{T^{10}}
.. math::
\int Y dT = A T + B \log{\left (T \right )} - \frac{1}{56 T^{8}}
\left(28 C T^{6} + 8 D T + 7 E\right)
.. math::
\int \frac{Y}{T} dT = A \log{\left (T \right )} - \frac{1}{72 T^{9}}
\left(72 B T^{8} + 24 C T^{6} + 9 D T + 8 E\right)
Examples
--------
Water second virial coefficient; DIPPR coefficients normally dimensionless.
>>> EQ104(300, 0.02222, -26.38, -16750000, -3.894E19, 3.133E21)
-1.1204179007265156
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
if order == 0:
T2 = T*T
return A + (B + (C + (D + E/T)/(T2*T2*T))/T2)/T
elif order == 1:
T2 = T*T
T4 = T2*T2
return (-B + (-3*C + (-8*D - 9*E/T)/(T4*T))/T2)/T2
elif order == -1:
return A*T + B*log(T) - (28*C*T**6 + 8*D*T + 7*E)/(56*T**8)
elif order == -1j:
return A*log(T) - (72*B*T**8 + 24*C*T**6 + 9*D*T + 8*E)/(72*T**9)
else:
raise Exception(order_not_found_msg) |
def EQ105(T, A, B, C, D):
r'''DIPPR Equation #105. Often used in calculating liquid molar density.
All 4 parameters are required. C is sometimes the fluid's critical
temperature.
.. math::
Y = \frac{A}{B^{1 + (1-\frac{T}{C})^D}}
Parameters
----------
T : float
Temperature, [K]
A-D : float
Parameter for the equation; chemical and property specific [-]
Returns
-------
Y : float
Property [constant-specific]
Notes
-----
This expression can be integrated in terms of the incomplete gamma function
for dT, but for Y/T dT no integral could be found.
Examples
--------
Hexane molar density; DIPPR coefficients normally in kmol/m^3.
>>> EQ105(300., 0.70824, 0.26411, 507.6, 0.27537)
7.593170096339236
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
return A/B**(1. + (1. - T/C)**D) |
def EQ106(T, Tc, A, B, C=0, D=0, E=0):
r'''DIPPR Equation #106. Often used in calculating liquid surface tension,
and heat of vaporization.
Only parameters A and B parameters are required; many fits include no
further parameters. Critical temperature is also required.
.. math::
Y = A(1-T_r)^{B + C T_r + D T_r^2 + E T_r^3}
Tr = \frac{T}{Tc}
Parameters
----------
T : float
Temperature, [K]
Tc : float
Critical temperature, [K]
A-D : float
Parameter for the equation; chemical and property specific [-]
Returns
-------
Y : float
Property [constant-specific]
Notes
-----
The integral could not be found, but the integral over T actually could,
again in terms of hypergeometric functions.
Examples
--------
Water surface tension; DIPPR coefficients normally in Pa*s.
>>> EQ106(300, 647.096, 0.17766, 2.567, -3.3377, 1.9699)
0.07231499373541
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
Tr = T/Tc
return A*(1. - Tr)**(B + Tr*(C + Tr*(D + E*Tr))) |
def EQ107(T, A=0, B=0, C=0, D=0, E=0, order=0):
r'''DIPPR Equation #107. Often used in calculating ideal-gas heat capacity.
All 5 parameters are required.
Also called the Aly-Lee equation.
.. math::
Y = A + B\left[\frac{C/T}{\sinh(C/T)}\right]^2 + D\left[\frac{E/T}{
\cosh(E/T)}\right]^2
Parameters
----------
T : float
Temperature, [K]
A-E : float
Parameter for the equation; chemical and property specific [-]
order : int, optional
Order of the calculation. 0 for the calculation of the result itself;
for 1, the first derivative of the property is returned, for
-1, the indefinite integral of the property with respect to temperature
is returned; and for -1j, the indefinite integral of the property
divided by temperature with respect to temperature is returned. No
other integrals or derivatives are implemented, and an exception will
be raised if any other order is given.
Returns
-------
Y : float
Property [constant-specific; if order == 1, property/K; if order == -1,
property*K; if order == -1j, unchanged from default]
Notes
-----
The derivative with respect to T, integral with respect to T, and integral
over T with respect to T are computed as follows. The derivative is
obtained via SymPy; the integrals from Wolfram Alpha.
.. math::
\frac{d Y}{dT} = \frac{2 B C^{3} \cosh{\left (\frac{C}{T} \right )}}
{T^{4} \sinh^{3}{\left (\frac{C}{T} \right )}} - \frac{2 B C^{2}}{T^{3}
\sinh^{2}{\left (\frac{C}{T} \right )}} + \frac{2 D E^{3} \sinh{\left
(\frac{E}{T} \right )}}{T^{4} \cosh^{3}{\left (\frac{E}{T} \right )}}
- \frac{2 D E^{2}}{T^{3} \cosh^{2}{\left (\frac{E}{T} \right )}}
.. math::
\int Y dT = A T + \frac{B C}{\tanh{\left (\frac{C}{T} \right )}}
- D E \tanh{\left (\frac{E}{T} \right )}
.. math::
\int \frac{Y}{T} dT = A \log{\left (T \right )} + \frac{B C}{T \tanh{
\left (\frac{C}{T} \right )}} - B \log{\left (\sinh{\left (\frac{C}{T}
\right )} \right )} - \frac{D E}{T} \tanh{\left (\frac{E}{T} \right )}
+ D \log{\left (\cosh{\left (\frac{E}{T} \right )} \right )}
Examples
--------
Water ideal gas molar heat capacity; DIPPR coefficients normally in
J/kmol/K
>>> EQ107(300., 33363., 26790., 2610.5, 8896., 1169.)
33585.90452768923
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
.. [2] Aly, Fouad A., and Lloyd L. Lee. "Self-Consistent Equations for
Calculating the Ideal Gas Heat Capacity, Enthalpy, and Entropy." Fluid
Phase Equilibria 6, no. 3 (January 1, 1981): 169-79.
doi:10.1016/0378-3812(81)85002-9.
'''
if order == 0:
return A + B*((C/T)/sinh(C/T))**2 + D*((E/T)/cosh(E/T))**2
elif order == 1:
return (2*B*C**3*cosh(C/T)/(T**4*sinh(C/T)**3)
- 2*B*C**2/(T**3*sinh(C/T)**2)
+ 2*D*E**3*sinh(E/T)/(T**4*cosh(E/T)**3)
- 2*D*E**2/(T**3*cosh(E/T)**2))
elif order == -1:
return A*T + B*C/tanh(C/T) - D*E*tanh(E/T)
elif order == -1j:
return (A*log(T) + B*C/tanh(C/T)/T - B*log(sinh(C/T))
- D*E*tanh(E/T)/T + D*log(cosh(E/T)))
else:
raise Exception(order_not_found_msg) |
def EQ114(T, Tc, A, B, C, D, order=0):
r'''DIPPR Equation #114. Rarely used, normally as an alternate liquid
heat capacity expression. All 4 parameters are required, as well as
critical temperature.
.. math::
Y = \frac{A^2}{\tau} + B - 2AC\tau - AD\tau^2 - \frac{1}{3}C^2\tau^3
- \frac{1}{2}CD\tau^4 - \frac{1}{5}D^2\tau^5
\tau = 1 - \frac{T}{Tc}
Parameters
----------
T : float
Temperature, [K]
Tc : float
Critical temperature, [K]
A-D : float
Parameter for the equation; chemical and property specific [-]
order : int, optional
Order of the calculation. 0 for the calculation of the result itself;
for 1, the first derivative of the property is returned, for
-1, the indefinite integral of the property with respect to temperature
is returned; and for -1j, the indefinite integral of the property
divided by temperature with respect to temperature is returned. No
other integrals or derivatives are implemented, and an exception will
be raised if any other order is given.
Returns
-------
Y : float
Property [constant-specific; if order == 1, property/K; if order == -1,
property*K; if order == -1j, unchanged from default]
Notes
-----
The derivative with respect to T, integral with respect to T, and integral
over T with respect to T are computed as follows. All expressions can be
obtained with SymPy readily.
.. math::
\frac{d Y}{dT} = \frac{A^{2}}{T_{c} \left(- \frac{T}{T_{c}}
+ 1\right)^{2}} + \frac{2 A}{T_{c}} C + \frac{2 A}{T_{c}} D \left(
- \frac{T}{T_{c}} + 1\right) + \frac{C^{2}}{T_{c}} \left(
- \frac{T}{T_{c}} + 1\right)^{2} + \frac{2 C}{T_{c}} D \left(
- \frac{T}{T_{c}} + 1\right)^{3} + \frac{D^{2}}{T_{c}} \left(
- \frac{T}{T_{c}} + 1\right)^{4}
.. math::
\int Y dT = - A^{2} T_{c} \log{\left (T - T_{c} \right )} + \frac{D^{2}
T^{6}}{30 T_{c}^{5}} - \frac{T^{5}}{10 T_{c}^{4}} \left(C D + 2 D^{2}
\right) + \frac{T^{4}}{12 T_{c}^{3}} \left(C^{2} + 6 C D + 6 D^{2}
\right) - \frac{T^{3}}{3 T_{c}^{2}} \left(A D + C^{2} + 3 C D
+ 2 D^{2}\right) + \frac{T^{2}}{2 T_{c}} \left(2 A C + 2 A D + C^{2}
+ 2 C D + D^{2}\right) + T \left(- 2 A C - A D + B - \frac{C^{2}}{3}
- \frac{C D}{2} - \frac{D^{2}}{5}\right)
.. math::
\int \frac{Y}{T} dT = - A^{2} \log{\left (T + \frac{- 60 A^{2} T_{c}
+ 60 A C T_{c} + 30 A D T_{c} - 30 B T_{c} + 10 C^{2} T_{c}
+ 15 C D T_{c} + 6 D^{2} T_{c}}{60 A^{2} - 60 A C - 30 A D + 30 B
- 10 C^{2} - 15 C D - 6 D^{2}} \right )} + \frac{D^{2} T^{5}}
{25 T_{c}^{5}} - \frac{T^{4}}{8 T_{c}^{4}} \left(C D + 2 D^{2}
\right) + \frac{T^{3}}{9 T_{c}^{3}} \left(C^{2} + 6 C D + 6 D^{2}
\right) - \frac{T^{2}}{2 T_{c}^{2}} \left(A D + C^{2} + 3 C D
+ 2 D^{2}\right) + \frac{T}{T_{c}} \left(2 A C + 2 A D + C^{2}
+ 2 C D + D^{2}\right) + \frac{1}{30} \left(30 A^{2} - 60 A C
- 30 A D + 30 B - 10 C^{2} - 15 C D - 6 D^{2}\right) \log{\left
(T + \frac{1}{60 A^{2} - 60 A C - 30 A D + 30 B - 10 C^{2} - 15 C D
- 6 D^{2}} \left(- 30 A^{2} T_{c} + 60 A C T_{c} + 30 A D T_{c}
- 30 B T_{c} + 10 C^{2} T_{c} + 15 C D T_{c} + 6 D^{2} T_{c}
+ T_{c} \left(30 A^{2} - 60 A C - 30 A D + 30 B - 10 C^{2} - 15 C D
- 6 D^{2}\right)\right) \right )}
Strictly speaking, the integral over T has an imaginary component, but
only the real component is relevant and the complex part discarded.
Examples
--------
Hydrogen liquid heat capacity; DIPPR coefficients normally in J/kmol/K.
>>> EQ114(20, 33.19, 66.653, 6765.9, -123.63, 478.27)
19423.948911676463
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
if order == 0:
t = 1.-T/Tc
return (A**2./t + B - 2.*A*C*t - A*D*t**2. - C**2.*t**3./3.
- C*D*t**4./2. - D**2*t**5./5.)
elif order == 1:
return (A**2/(Tc*(-T/Tc + 1)**2) + 2*A*C/Tc + 2*A*D*(-T/Tc + 1)/Tc
+ C**2*(-T/Tc + 1)**2/Tc + 2*C*D*(-T/Tc + 1)**3/Tc
+ D**2*(-T/Tc + 1)**4/Tc)
elif order == -1:
return (-A**2*Tc*clog(T - Tc).real + D**2*T**6/(30*Tc**5)
- T**5*(C*D + 2*D**2)/(10*Tc**4)
+ T**4*(C**2 + 6*C*D + 6*D**2)/(12*Tc**3) - T**3*(A*D + C**2
+ 3*C*D + 2*D**2)/(3*Tc**2) + T**2*(2*A*C + 2*A*D + C**2 + 2*C*D
+ D**2)/(2*Tc) + T*(-2*A*C - A*D + B - C**2/3 - C*D/2 - D**2/5))
elif order == -1j:
return (-A**2*clog(T + (-60*A**2*Tc + 60*A*C*Tc + 30*A*D*Tc - 30*B*Tc
+ 10*C**2*Tc + 15*C*D*Tc + 6*D**2*Tc)/(60*A**2 - 60*A*C
- 30*A*D + 30*B - 10*C**2 - 15*C*D - 6*D**2)).real
+ D**2*T**5/(25*Tc**5) - T**4*(C*D + 2*D**2)/(8*Tc**4)
+ T**3*(C**2 + 6*C*D + 6*D**2)/(9*Tc**3) - T**2*(A*D + C**2
+ 3*C*D + 2*D**2)/(2*Tc**2) + T*(2*A*C + 2*A*D + C**2 + 2*C*D
+ D**2)/Tc + (30*A**2 - 60*A*C - 30*A*D + 30*B - 10*C**2
- 15*C*D - 6*D**2)*clog(T + (-30*A**2*Tc + 60*A*C*Tc
+ 30*A*D*Tc - 30*B*Tc + 10*C**2*Tc + 15*C*D*Tc + 6*D**2*Tc
+ Tc*(30*A**2 - 60*A*C - 30*A*D + 30*B - 10*C**2 - 15*C*D
- 6*D**2))/(60*A**2 - 60*A*C - 30*A*D + 30*B - 10*C**2
- 15*C*D - 6*D**2)).real/30)
else:
raise Exception(order_not_found_msg) |
def EQ115(T, A, B, C=0, D=0, E=0):
r'''DIPPR Equation #115. No major uses; has been used as an alternate
liquid viscosity expression, and as a model for vapor pressure.
Only parameters A and B are required.
.. math::
Y = \exp\left(A + \frac{B}{T} + C\log T + D T^2 + \frac{E}{T^2}\right)
Parameters
----------
T : float
Temperature, [K]
A-E : float
Parameter for the equation; chemical and property specific [-]
Returns
-------
Y : float
Property [constant-specific]
Notes
-----
No coefficients found for this expression.
This function is not integrable for either dT or Y/T dT.
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
return exp(A+B/T+C*log(T)+D*T**2 + E/T**2) |
def EQ116(T, Tc, A, B, C, D, E, order=0):
r'''DIPPR Equation #116. Used to describe the molar density of water fairly
precisely; no other uses listed. All 5 parameters are needed, as well as
the critical temperature.
.. math::
Y = A + B\tau^{0.35} + C\tau^{2/3} + D\tau + E\tau^{4/3}
\tau = 1 - \frac{T}{T_c}
Parameters
----------
T : float
Temperature, [K]
Tc : float
Critical temperature, [K]
A-E : float
Parameter for the equation; chemical and property specific [-]
order : int, optional
Order of the calculation. 0 for the calculation of the result itself;
for 1, the first derivative of the property is returned, for
-1, the indefinite integral of the property with respect to temperature
is returned; and for -1j, the indefinite integral of the property
divided by temperature with respect to temperature is returned. No
other integrals or derivatives are implemented, and an exception will
be raised if any other order is given.
Returns
-------
Y : float
Property [constant-specific; if order == 1, property/K; if order == -1,
property*K; if order == -1j, unchanged from default]
Notes
-----
The derivative with respect to T and integral with respect to T are
computed as follows. The integral divided by T with respect to T has an
extremely complicated (but still elementary) integral which can be read
from the source. It was computed with Rubi; the other expressions can
readily be obtained with SymPy.
.. math::
\frac{d Y}{dT} = - \frac{7 B}{20 T_c \left(- \frac{T}{T_c} + 1\right)^{
\frac{13}{20}}} - \frac{2 C}{3 T_c \sqrt[3]{- \frac{T}{T_c} + 1}}
- \frac{D}{T_c} - \frac{4 E}{3 T_c} \sqrt[3]{- \frac{T}{T_c} + 1}
.. math::
\int Y dT = A T - \frac{20 B}{27} T_c \left(- \frac{T}{T_c} + 1\right)^{
\frac{27}{20}} - \frac{3 C}{5} T_c \left(- \frac{T}{T_c} + 1\right)^{
\frac{5}{3}} + D \left(- \frac{T^{2}}{2 T_c} + T\right) - \frac{3 E}{7}
T_c \left(- \frac{T}{T_c} + 1\right)^{\frac{7}{3}}
Examples
--------
Water liquid molar density; DIPPR coefficients normally in kmol/m^3.
>>> EQ116(300., 647.096, 17.863, 58.606, -95.396, 213.89, -141.26)
55.17615446406527
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
if order == 0:
tau = 1-T/Tc
return A + B*tau**0.35 + C*tau**(2/3.) + D*tau + E*tau**(4/3.)
elif order == 1:
return (-7*B/(20*Tc*(-T/Tc + 1)**(13/20))
- 2*C/(3*Tc*(-T/Tc + 1)**(1/3))
- D/Tc - 4*E*(-T/Tc + 1)**(1/3)/(3*Tc))
elif order == -1:
return (A*T - 20*B*Tc*(-T/Tc + 1)**(27/20)/27
- 3*C*Tc*(-T/Tc + 1)**(5/3)/5 + D*(-T**2/(2*Tc) + T)
- 3*E*Tc*(-T/Tc + 1)**(7/3)/7)
elif order == -1j:
# 3x increase in speed - cse via sympy
x0 = log(T)
x1 = 0.5*x0
x2 = 1/Tc
x3 = T*x2
x4 = -x3 + 1
x5 = 1.5*C
x6 = x4**0.333333333333333
x7 = 2*B
x8 = x4**0.05
x9 = log(-x6 + 1)
x10 = sqrt(3)
x11 = x10*atan(x10*(2*x6 + 1)/3)
x12 = sqrt(5)
x13 = 0.5*x12
x14 = x13 + 0.5
x15 = B*x14
x16 = sqrt(x13 + 2.5)
x17 = 2*x8
x18 = -x17
x19 = -x13
x20 = x19 + 0.5
x21 = B*x20
x22 = sqrt(x19 + 2.5)
x23 = B*x16
x24 = 0.5*sqrt(0.1*x12 + 0.5)
x25 = x12 + 1
x26 = 4*x8
x27 = -x26
x28 = sqrt(10)*B/sqrt(x12 + 5)
x29 = 2*x12
x30 = sqrt(x29 + 10)
x31 = 1/x30
x32 = -x12 + 1
x33 = 0.5*B*x22
x34 = -x2*(T - Tc)
x35 = 2*x34**0.1
x36 = x35 + 2
x37 = x34**0.05
x38 = x30*x37
x39 = 0.5*B*x16
x40 = x37*sqrt(-x29 + 10)
x41 = 0.25*x12
x42 = B*(-x41 + 0.25)
x43 = x12*x37
x44 = x35 + x37 + 2
x45 = B*(x41 + 0.25)
x46 = -x43
x47 = x35 - x37 + 2
return A*x0 + 2.85714285714286*B*x4**0.35 - C*x1 + C*x11 + D*x0 - D*x3 - E*x1 - E*x11 + 0.75*E*x4**1.33333333333333 + 3*E*x6 + 1.5*E*x9 - x15*atan(x14*(x16 + x17)) + x15*atan(x14*(x16 + x18)) - x21*atan(x20*(x17 + x22)) + x21*atan(x20*(x18 + x22)) + x23*atan(x24*(x25 + x26)) - x23*atan(x24*(x25 + x27)) - x28*atan(x31*(x26 + x32)) + x28*atan(x31*(x27 + x32)) - x33*log(x36 - x38) + x33*log(x36 + x38) + x39*log(x36 - x40) - x39*log(x36 + x40) + x4**0.666666666666667*x5 - x42*log(x43 + x44) + x42*log(x46 + x47) + x45*log(x43 + x47) - x45*log(x44 + x46) + x5*x9 + x7*atan(x8) - x7*atanh(x8)
else:
raise Exception(order_not_found_msg) |
def EQ127(T, A, B, C, D, E, F, G, order=0):
r'''DIPPR Equation #127. Rarely used, and then only in calculating
ideal-gas heat capacity. All 7 parameters are required.
.. math::
Y = A+B\left[\frac{\left(\frac{C}{T}\right)^2\exp\left(\frac{C}{T}
\right)}{\left(\exp\frac{C}{T}-1 \right)^2}\right]
+D\left[\frac{\left(\frac{E}{T}\right)^2\exp\left(\frac{E}{T}\right)}
{\left(\exp\frac{E}{T}-1 \right)^2}\right]
+F\left[\frac{\left(\frac{G}{T}\right)^2\exp\left(\frac{G}{T}\right)}
{\left(\exp\frac{G}{T}-1 \right)^2}\right]
Parameters
----------
T : float
Temperature, [K]
A-G : float
Parameter for the equation; chemical and property specific [-]
order : int, optional
Order of the calculation. 0 for the calculation of the result itself;
for 1, the first derivative of the property is returned, for
-1, the indefinite integral of the property with respect to temperature
is returned; and for -1j, the indefinite integral of the property
divided by temperature with respect to temperature is returned. No
other integrals or derivatives are implemented, and an exception will
be raised if any other order is given.
Returns
-------
Y : float
Property [constant-specific; if order == 1, property/K; if order == -1,
property*K; if order == -1j, unchanged from default]
Notes
-----
The derivative with respect to T, integral with respect to T, and integral
over T with respect to T are computed as follows. All expressions can be
obtained with SymPy readily.
.. math::
\frac{d Y}{dT} = - \frac{B C^{3} e^{\frac{C}{T}}}{T^{4}
\left(e^{\frac{C}{T}} - 1\right)^{2}} + \frac{2 B C^{3}
e^{\frac{2 C}{T}}}{T^{4} \left(e^{\frac{C}{T}} - 1\right)^{3}}
- \frac{2 B C^{2} e^{\frac{C}{T}}}{T^{3} \left(e^{\frac{C}{T}}
- 1\right)^{2}} - \frac{D E^{3} e^{\frac{E}{T}}}{T^{4}
\left(e^{\frac{E}{T}} - 1\right)^{2}} + \frac{2 D E^{3}
e^{\frac{2 E}{T}}}{T^{4} \left(e^{\frac{E}{T}} - 1\right)^{3}}
- \frac{2 D E^{2} e^{\frac{E}{T}}}{T^{3} \left(e^{\frac{E}{T}}
- 1\right)^{2}} - \frac{F G^{3} e^{\frac{G}{T}}}{T^{4}
\left(e^{\frac{G}{T}} - 1\right)^{2}} + \frac{2 F G^{3}
e^{\frac{2 G}{T}}}{T^{4} \left(e^{\frac{G}{T}} - 1\right)^{3}}
- \frac{2 F G^{2} e^{\frac{G}{T}}}{T^{3} \left(e^{\frac{G}{T}}
- 1\right)^{2}}
.. math::
\int Y dT = A T + \frac{B C^{2}}{C e^{\frac{C}{T}} - C}
+ \frac{D E^{2}}{E e^{\frac{E}{T}} - E}
+ \frac{F G^{2}}{G e^{\frac{G}{T}} - G}
.. math::
\int \frac{Y}{T} dT = A \log{\left (T \right )} + B C^{2} \left(
\frac{1}{C T e^{\frac{C}{T}} - C T} + \frac{1}{C T} - \frac{1}{C^{2}}
\log{\left (e^{\frac{C}{T}} - 1 \right )}\right) + D E^{2} \left(
\frac{1}{E T e^{\frac{E}{T}} - E T} + \frac{1}{E T} - \frac{1}{E^{2}}
\log{\left (e^{\frac{E}{T}} - 1 \right )}\right) + F G^{2} \left(
\frac{1}{G T e^{\frac{G}{T}} - G T} + \frac{1}{G T} - \frac{1}{G^{2}}
\log{\left (e^{\frac{G}{T}} - 1 \right )}\right)
Examples
--------
Ideal gas heat capacity of methanol; DIPPR coefficients normally in
J/kmol/K
>>> EQ127(20., 3.3258E4, 3.6199E4, 1.2057E3, 1.5373E7, 3.2122E3, -1.5318E7, 3.2122E3)
33258.0
References
----------
.. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801
DIPPR/AIChE
'''
if order == 0:
return (A+B*((C/T)**2*exp(C/T)/(exp(C/T) - 1)**2) +
D*((E/T)**2*exp(E/T)/(exp(E/T)-1)**2) +
F*((G/T)**2*exp(G/T)/(exp(G/T)-1)**2))
elif order == 1:
return (-B*C**3*exp(C/T)/(T**4*(exp(C/T) - 1)**2)
+ 2*B*C**3*exp(2*C/T)/(T**4*(exp(C/T) - 1)**3)
- 2*B*C**2*exp(C/T)/(T**3*(exp(C/T) - 1)**2)
- D*E**3*exp(E/T)/(T**4*(exp(E/T) - 1)**2)
+ 2*D*E**3*exp(2*E/T)/(T**4*(exp(E/T) - 1)**3)
- 2*D*E**2*exp(E/T)/(T**3*(exp(E/T) - 1)**2)
- F*G**3*exp(G/T)/(T**4*(exp(G/T) - 1)**2)
+ 2*F*G**3*exp(2*G/T)/(T**4*(exp(G/T) - 1)**3)
- 2*F*G**2*exp(G/T)/(T**3*(exp(G/T) - 1)**2))
elif order == -1:
return (A*T + B*C**2/(C*exp(C/T) - C) + D*E**2/(E*exp(E/T) - E)
+ F*G**2/(G*exp(G/T) - G))
elif order == -1j:
return (A*log(T) + B*C**2*(1/(C*T*exp(C/T) - C*T) + 1/(C*T)
- log(exp(C/T) - 1)/C**2) + D*E**2*(1/(E*T*exp(E/T) - E*T)
+ 1/(E*T) - log(exp(E/T) - 1)/E**2)
+ F*G**2*(1/(G*T*exp(G/T) - G*T) + 1/(G*T) - log(exp(G/T)
- 1)/G**2))
else:
raise Exception(order_not_found_msg) |
def CoolProp_T_dependent_property(T, CASRN, prop, phase):
r'''Calculates a property of a chemical in either the liquid or gas phase
as a function of temperature only. This means that the property is
either at 1 atm or along the saturation curve.
Parameters
----------
T : float
Temperature of the fluid [K]
CASRN : str
CAS number of the fluid
prop : str
CoolProp string shortcut for desired property
phase : str
Either 'l' or 'g' for liquid or gas properties respectively
Returns
-------
prop : float
Desired chemical property, [units]
Notes
-----
For liquids above their boiling point, the liquid property is found on the
saturation line (at higher pressures). Under their boiling point, the
property is calculated at 1 atm.
No liquid calculations are permitted above the critical temperature.
For gases under the chemical's boiling point, the gas property is found
on the saturation line (at sub-atmospheric pressures). Above the boiling
point, the property is calculated at 1 atm.
An exception is raised if the desired CAS is not supported, or if CoolProp
is not available.
The list of strings acceptable as an input for property types is:
http://www.coolprop.org/coolprop/HighLevelAPI.html#table-of-string-inputs-to-propssi-function
Examples
--------
Water at STP according to IAPWS-95
>>> CoolProp_T_dependent_property(298.15, '7732-18-5', 'D', 'l')
997.047636760347
References
----------
.. [1] Bell, Ian H., Jorrit Wronski, Sylvain Quoilin, and Vincent Lemort.
"Pure and Pseudo-Pure Fluid Thermophysical Property Evaluation and the
Open-Source Thermophysical Property Library CoolProp." Industrial &
Engineering Chemistry Research 53, no. 6 (February 12, 2014):
2498-2508. doi:10.1021/ie4033999. http://www.coolprop.org/
'''
if not has_CoolProp: # pragma: no cover
raise Exception('CoolProp library is not installed')
if CASRN not in coolprop_dict:
raise Exception('CASRN not in list of supported fluids')
Tc = coolprop_fluids[CASRN].Tc
T = float(T) # Do not allow custom objects here
if phase == 'l':
if T > Tc:
raise Exception('For liquid properties, must be under the critical temperature.')
if PhaseSI('T', T, 'P', 101325, CASRN) in [u'liquid', u'supercritical_liquid']:
return PropsSI(prop, 'T', T, 'P', 101325, CASRN)
else:
return PropsSI(prop, 'T', T, 'Q', 0, CASRN)
elif phase == 'g':
if PhaseSI('T', T, 'P', 101325, CASRN) == 'gas':
return PropsSI(prop, 'T', T, 'P', 101325, CASRN)
else:
if T < Tc:
return PropsSI(prop, 'T', T, 'Q', 1, CASRN)
else:
# catch supercritical_gas and friends
return PropsSI(prop, 'T', T, 'P', 101325, CASRN)
else:
raise Exception('Error in CoolProp property function') |
def Stockmayer(Tm=None, Tb=None, Tc=None, Zc=None, omega=None,
CASRN='', AvailableMethods=False, Method=None):
r'''This function handles the retrieval or calculation a chemical's
Stockmayer parameter. Values are available from one source with lookup
based on CASRNs, or can be estimated from 7 CSP methods.
Will automatically select a data source to use if no Method is provided;
returns None if the data is not available.
Prefered sources are 'Magalhães, Lito, Da Silva, and Silva (2013)' for
common chemicals which had valies listed in that source, and the CSP method
`Tee, Gotoh, and Stewart CSP with Tc, omega (1966)` for chemicals which
don't.
Examples
--------
>>> Stockmayer(CASRN='64-17-5')
1291.41
Parameters
----------
Tm : float, optional
Melting temperature of fluid [K]
Tb : float, optional
Boiling temperature of fluid [K]
Tc : float, optional
Critical temperature, [K]
Zc : float, optional
Critical compressibility, [-]
omega : float, optional
Acentric factor of compound, [-]
CASRN : string, optional
CASRN [-]
Returns
-------
epsilon_k : float
Lennard-Jones depth of potential-energy minimum over k, [K]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain epsilon with the given
inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Stockmayer_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
epsilon for the desired chemical, and will return methods instead of
epsilon
Notes
-----
These values are somewhat rough, as they attempt to pigeonhole a chemical
into L-J behavior.
The tabulated data is from [2]_, for 322 chemicals.
References
----------
.. [1] Bird, R. Byron, Warren E. Stewart, and Edwin N. Lightfoot.
Transport Phenomena, Revised 2nd Edition. New York:
John Wiley & Sons, Inc., 2006
.. [2] Magalhães, Ana L., Patrícia F. Lito, Francisco A. Da Silva, and
Carlos M. Silva. "Simple and Accurate Correlations for Diffusion
Coefficients of Solutes in Liquids and Supercritical Fluids over Wide
Ranges of Temperature and Density." The Journal of Supercritical Fluids
76 (April 2013): 94-114. doi:10.1016/j.supflu.2013.02.002.
'''
def list_methods():
methods = []
if CASRN in MagalhaesLJ_data.index:
methods.append(MAGALHAES)
if Tc and omega:
methods.append(TEEGOTOSTEWARD2)
if Tc:
methods.append(FLYNN)
methods.append(BSLC)
methods.append(TEEGOTOSTEWARD1)
if Tb:
methods.append(BSLB)
if Tm:
methods.append(BSLM)
if Tc and Zc:
methods.append(STIELTHODOS)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == FLYNN:
epsilon = epsilon_Flynn(Tc)
elif Method == BSLC:
epsilon = epsilon_Bird_Stewart_Lightfoot_critical(Tc)
elif Method == BSLB:
epsilon = epsilon_Bird_Stewart_Lightfoot_boiling(Tb)
elif Method == BSLM:
epsilon = epsilon_Bird_Stewart_Lightfoot_melting(Tm)
elif Method == STIELTHODOS:
epsilon = epsilon_Stiel_Thodos(Tc, Zc)
elif Method == TEEGOTOSTEWARD1:
epsilon = epsilon_Tee_Gotoh_Steward_1(Tc)
elif Method == TEEGOTOSTEWARD2:
epsilon = epsilon_Tee_Gotoh_Steward_2(Tc, omega)
elif Method == MAGALHAES:
epsilon = float(MagalhaesLJ_data.at[CASRN, "epsilon"])
elif Method == NONE:
epsilon = None
else:
raise Exception('Failure in in function')
return epsilon |
def molecular_diameter(Tc=None, Pc=None, Vc=None, Zc=None, omega=None,
Vm=None, Vb=None, CASRN='', AvailableMethods=False, Method=None):
r'''This function handles the retrieval or calculation a chemical's
L-J molecular diameter. Values are available from one source with lookup
based on CASRNs, or can be estimated from 9 CSP methods.
Will automatically select a data source to use if no Method is provided;
returns None if the data is not available.
Prefered sources are 'Magalhães, Lito, Da Silva, and Silva (2013)' for
common chemicals which had valies listed in that source, and the CSP method
`Tee, Gotoh, and Stewart CSP with Tc, Pc, omega (1966)` for chemicals which
don't.
Examples
--------
>>> molecular_diameter(CASRN='64-17-5')
4.23738
Parameters
----------
Tc : float, optional
Critical temperature, [K]
Pc : float, optional
Critical pressure, [Pa]
Vc : float, optional
Critical volume, [m^3/mol]
Zc : float, optional
Critical compressibility, [-]
omega : float, optional
Acentric factor of compound, [-]
Vm : float, optional
Molar volume of liquid at the melting point of the fluid [K]
Vb : float, optional
Molar volume of liquid at the boiling point of the fluid [K]
CASRN : string, optional
CASRN [-]
Returns
-------
sigma : float
Lennard-Jones molecular diameter, [Angstrom]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain epsilon with the given
inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
molecular_diameter_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
sigma for the desired chemical, and will return methods instead of
sigma
Notes
-----
These values are somewhat rough, as they attempt to pigeonhole a chemical
into L-J behavior.
The tabulated data is from [2]_, for 322 chemicals.
References
----------
.. [1] Bird, R. Byron, Warren E. Stewart, and Edwin N. Lightfoot.
Transport Phenomena, Revised 2nd Edition. New York:
John Wiley & Sons, Inc., 2006
.. [2] Magalhães, Ana L., Patrícia F. Lito, Francisco A. Da Silva, and
Carlos M. Silva. "Simple and Accurate Correlations for Diffusion
Coefficients of Solutes in Liquids and Supercritical Fluids over Wide
Ranges of Temperature and Density." The Journal of Supercritical Fluids
76 (April 2013): 94-114. doi:10.1016/j.supflu.2013.02.002.
'''
def list_methods():
methods = []
if CASRN in MagalhaesLJ_data.index:
methods.append(MAGALHAES)
if Tc and Pc and omega:
methods.append(TEEGOTOSTEWARD4)
if Tc and Pc:
methods.append(SILVALIUMACEDO)
methods.append(BSLC2)
methods.append(TEEGOTOSTEWARD3)
if Vc and Zc:
methods.append(STIELTHODOSMD)
if Vc:
methods.append(FLYNN)
methods.append(BSLC1)
if Vb:
methods.append(BSLB)
if Vm:
methods.append(BSLM)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == FLYNN:
sigma = sigma_Flynn(Vc)
elif Method == BSLC1:
sigma = sigma_Bird_Stewart_Lightfoot_critical_1(Vc)
elif Method == BSLC2:
sigma = sigma_Bird_Stewart_Lightfoot_critical_2(Tc, Pc)
elif Method == TEEGOTOSTEWARD3:
sigma = sigma_Tee_Gotoh_Steward_1(Tc, Pc)
elif Method == SILVALIUMACEDO:
sigma = sigma_Silva_Liu_Macedo(Tc, Pc)
elif Method == BSLB:
sigma = sigma_Bird_Stewart_Lightfoot_boiling(Vb)
elif Method == BSLM:
sigma = sigma_Bird_Stewart_Lightfoot_melting(Vm)
elif Method == STIELTHODOSMD:
sigma = sigma_Stiel_Thodos(Vc, Zc)
elif Method == TEEGOTOSTEWARD4:
sigma = sigma_Tee_Gotoh_Steward_2(Tc, Pc, omega)
elif Method == MAGALHAES:
sigma = float(MagalhaesLJ_data.at[CASRN, "sigma"])
elif Method == NONE:
sigma = None
else:
raise Exception('Failure in in function')
return sigma |
def sigma_Tee_Gotoh_Steward_2(Tc, Pc, omega):
r'''Calculates Lennard-Jones molecular diameter.
Uses critical temperature, pressure, and acentric factor. CSP method by
[1]_.
.. math::
\sigma = (2.3551 - 0.0874\omega)\left(\frac{T_c}{P_c}\right)^{1/3}
Parameters
----------
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
omega : float
Acentric factor for fluid, [-]
Returns
-------
sigma : float
Lennard-Jones molecular diameter, [Angstrom]
Notes
-----
Original units of Pc are atm. Further regressions with other parameters
were performed in [1]_ but are not included here, except for
`sigma_Tee_Gotoh_Steward_1`.
Examples
--------
>>> sigma_Tee_Gotoh_Steward_2(560.1, 4550000, 0.245)
5.412104867264477
References
----------
.. [1] Tee, L. S., Sukehiro Gotoh, and W. E. Stewart. "Molecular Parameters
for Normal Fluids. Lennard-Jones 12-6 Potential." Industrial
& Engineering Chemistry Fundamentals 5, no. 3 (August 1, 1966): 356-63.
doi:10.1021/i160019a011
'''
Pc = Pc/101325.
sigma = (2.3551-0.0874*omega)*(Tc/Pc)**(1/3.)
return sigma |
def sigma_Silva_Liu_Macedo(Tc, Pc):
r'''Calculates Lennard-Jones molecular diameter.
Uses critical temperature and pressure. CSP method by [1]_.
.. math::
\sigma_{LJ}^3 = 0.17791 + 11.779 \left( \frac{T_c}{P_c}\right)
- 0.049029\left( \frac{T_c}{P_c}\right)^2
Parameters
----------
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
Returns
-------
sigma : float
Lennard-Jones molecular diameter, [Angstrom]
Notes
-----
Pc is originally in bar. An excellent paper. None is
returned if the polynomial returns a negative number, as in the case of
1029.13 K and 3.83 bar.
Examples
--------
>>> sigma_Silva_Liu_Macedo(560.1, 4550000)
5.164483998730177
References
----------
.. [1] Silva, Carlos M., Hongqin Liu, and Eugenia A. Macedo. "Models for
Self-Diffusion Coefficients of Dense Fluids, Including Hydrogen-Bonding
Substances." Chemical Engineering Science 53, no. 13 (July 1, 1998):
2423-29. doi:10.1016/S0009-2509(98)00037-2
'''
Pc = Pc/1E5 # Pa to bar
term = 0.17791 + 11.779*(Tc/Pc) - 0.049029 * (Tc/Pc)**2
if term < 0:
sigma = None
else:
sigma = (term)**(1/3.)
return sigma |
def collision_integral_Neufeld_Janzen_Aziz(Tstar, l=1, s=1):
r'''Calculates Lennard-Jones collision integral for any of 16 values of
(l,j) for the wide range of 0.3 < Tstar < 100. Values are accurate to
0.1 % of actual values, but the calculation of actual values is
computationally intensive and so these simplifications are used, developed
in [1]_.
.. math::
\Omega_D = \frac{A}{T^{*B}} + \frac{C}{\exp(DT^*)} +
\frac{E}{\exp(FT^{*})} + \frac{G}{\exp(HT^*)} + RT^{*B}\sin(ST^{*W}-P)
Parameters
----------
Tstar : float
Reduced temperature of the fluid [-]
l : int
term
s : int
term
Returns
-------
Omega : float
Collision integral of A and B
Notes
-----
Acceptable pairs of (l,s) are (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
(1, 6), (1, 7), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 3), (3, 4),
(3, 5), and (4, 4).
.. math::
T^* = \frac{k_b T}{\epsilon}
Results are very similar to those of the more modern formulation,
`collision_integral_Kim_Monroe`.
Calculations begin to yield overflow errors in some values of (l, 2) after
Tstar = 75, beginning with (1, 7). Also susceptible are (1, 5) and (1, 6).
Examples
--------
>>> collision_integral_Neufeld_Janzen_Aziz(100, 1, 1)
0.516717697672334
References
----------
.. [1] Neufeld, Philip D., A. R. Janzen, and R. A. Aziz. "Empirical
Equations to Calculate 16 of the Transport Collision Integrals
Omega(l, S)* for the Lennard-Jones (12-6) Potential." The Journal of
Chemical Physics 57, no. 3 (August 1, 1972): 1100-1102.
doi:10.1063/1.1678363
'''
if (l, s) not in Neufeld_collision:
raise Exception('Input values of l and s are not supported')
A, B, C, D, E, F, G, H, R, S, W, P = Neufeld_collision[(l, s)]
omega = A/Tstar**B + C/exp(D*Tstar) + E/exp(F*Tstar)
if (l, s) in [(1, 1), (1, 2), (3, 3)]:
omega += G/exp(H*Tstar)
if (l, s) not in [(1, 1), (1, 2)]:
omega += R*Tstar**B*sin(S*Tstar**W-P)
return omega |
def collision_integral_Kim_Monroe(Tstar, l=1, s=1):
r'''Calculates Lennard-Jones collision integral for any of 16 values of
(l,j) for the wide range of 0.3 < Tstar < 400. Values are accurate to
0.007 % of actual values, but the calculation of actual values is
computationally intensive and so these simplifications are used, developed
in [1]_.
.. math::
\Omega^{(l,s)*} = A^{(l,s)} + \sum_{k=1}^6 \left[ \frac{B_k^{(l,s)}}
{(T^*)^k} + C_k^{(l,s)} (\ln T^*)^k \right]
Parameters
----------
Tstar : float
Reduced temperature of the fluid [-]
l : int
term
s : int
term
Returns
-------
Omega : float
Collision integral of A and B
Notes
-----
Acceptable pairs of (l,s) are (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
(1, 6), (1, 7), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 3), (3, 4),
(3, 5), and (4, 4).
.. math::
T^* = \frac{k_b T}{\epsilon}
Examples
--------
>>> collision_integral_Kim_Monroe(400, 1, 1)
0.4141818082392228
References
----------
.. [1] Kim, Sun Ung, and Charles W. Monroe. "High-Accuracy Calculations of
Sixteen Collision Integrals for Lennard-Jones (12-6) Gases and Their
Interpolation to Parameterize Neon, Argon, and Krypton." Journal of
Computational Physics 273 (September 15, 2014): 358-73.
doi:10.1016/j.jcp.2014.05.018.
'''
if (l, s) not in As_collision:
raise Exception('Input values of l and s are not supported')
omega = As_collision[(l, s)]
for ki in range(6):
Bs = Bs_collision[(l, s)]
Cs = Cs_collision[(l, s)]
omega += Bs[ki]/Tstar**(ki+1) + Cs[ki]*log(Tstar)**(ki+1)
return omega |
def Tstar(T, epsilon_k=None, epsilon=None):
r'''This function calculates the parameter `Tstar` as needed in performing
collision integral calculations.
.. math::
T^* = \frac{kT}{\epsilon}
Examples
--------
>>> Tstar(T=318.2, epsilon_k=308.43)
1.0316765554582887
Parameters
----------
epsilon_k : float, optional
Lennard-Jones depth of potential-energy minimum over k, [K]
epsilon : float, optional
Lennard-Jones depth of potential-energy minimum [J]
Returns
-------
Tstar : float
Dimentionless temperature for calculating collision integral, [-]
Notes
-----
Tabulated values are normally listed as epsilon/k. k is the Boltzman
constant, with units of J/K.
References
----------
.. [1] Bird, R. Byron, Warren E. Stewart, and Edwin N. Lightfoot.
Transport Phenomena, Revised 2nd Edition. New York:
John Wiley & Sons, Inc., 2006
'''
if epsilon_k:
_Tstar = T/(epsilon_k)
elif epsilon:
_Tstar = k*T/epsilon
else:
raise Exception('Either epsilon/k or epsilon must be provided')
return _Tstar |
def Hf(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval of a chemical's standard-phase
heat of formation. The lookup is based on CASRNs. Selects the only
data source available ('API TDB') if the chemical is in it.
Returns None if the data is not available.
Function has data for 571 chemicals.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Hf : float
Standard-state heat of formation, [J/mol]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Hf with the given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Hf_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Hf for the desired chemical, and will return methods instead of Hf
Notes
-----
Only one source of information is available to this function. it is:
* 'API_TDB', a compilation of heats of formation of unspecified phase.
Not the original data, but as reproduced in [1]_. Some chemicals with
duplicated CAS numbers were removed.
Examples
--------
>>> Hf(CASRN='7732-18-5')
-241820.0
References
----------
.. [1] Albahri, Tareq A., and Abdulla F. Aljasmi. "SGC Method for
Predicting the Standard Enthalpy of Formation of Pure Compounds from
Their Molecular Structures." Thermochimica Acta 568
(September 20, 2013): 46-60. doi:10.1016/j.tca.2013.06.020.
'''
def list_methods():
methods = []
if CASRN in API_TDB_data.index:
methods.append(API_TDB)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == API_TDB:
_Hf = float(API_TDB_data.at[CASRN, 'Hf'])
elif Method == NONE:
_Hf = None
else:
raise Exception('Failure in in function')
return _Hf |
def Hf_l(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval of a chemical's liquid standard
phase heat of formation. The lookup is based on CASRNs. Selects the only
data source available, Active Thermochemical Tables (l), if the chemical is
in it. Returns None if the data is not available.
Function has data for 34 chemicals.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Hfl : float
Liquid standard-state heat of formation, [J/mol]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Hf(l) with the given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Hf_l_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Hf(l) for the desired chemical, and will return methods instead of Hf(l)
Notes
-----
Only one source of information is available to this function. It is:
* 'ATCT_L', the Active Thermochemical Tables version 1.112.
Examples
--------
>>> Hf_l('67-56-1')
-238400.0
References
----------
.. [1] Ruscic, Branko, Reinhardt E. Pinzon, Gregor von Laszewski, Deepti
Kodeboyina, Alexander Burcat, David Leahy, David Montoy, and Albert F.
Wagner. "Active Thermochemical Tables: Thermochemistry for the 21st
Century." Journal of Physics: Conference Series 16, no. 1
(January 1, 2005): 561. doi:10.1088/1742-6596/16/1/078.
'''
def list_methods():
methods = []
if CASRN in ATcT_l.index:
methods.append(ATCT_L)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == ATCT_L:
_Hfl = float(ATcT_l.at[CASRN, 'Hf_298K'])
elif Method == NONE:
return None
else:
raise Exception('Failure in in function')
return _Hfl |
def Hf_g(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval of a chemical's gas heat of
formation. Lookup is based on CASRNs. Will automatically select a data
source to use if no Method is provided; returns None if the data is not
available.
Prefered sources are 'Active Thermochemical Tables (g)' for high accuracy,
and 'TRC' for less accuracy but more chemicals.
Function has data for approximately 2000 chemicals.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
_Hfg : float
Gas phase heat of formation, [J/mol]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Hf(g) with the given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Hf_g_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Hf(g) for the desired chemical, and will return methods instead of Hf(g)
Notes
-----
Sources are:
* 'ATCT_G', the Active Thermochemical Tables version 1.112.
* 'TRC', from a 1994 compilation.
Examples
--------
>>> Hf_g('67-56-1')
-200700.0
References
----------
.. [1] Ruscic, Branko, Reinhardt E. Pinzon, Gregor von Laszewski, Deepti
Kodeboyina, Alexander Burcat, David Leahy, David Montoy, and Albert F.
Wagner. "Active Thermochemical Tables: Thermochemistry for the 21st
Century." Journal of Physics: Conference Series 16, no. 1
(January 1, 2005): 561. doi:10.1088/1742-6596/16/1/078.
.. [2] Frenkelʹ, M. L, Texas Engineering Experiment Station, and
Thermodynamics Research Center. Thermodynamics of Organic Compounds in
the Gas State. College Station, Tex.: Thermodynamics Research Center,
1994.
'''
def list_methods():
methods = []
if CASRN in ATcT_g.index:
methods.append(ATCT_G)
if CASRN in TRC_gas_data.index and not np.isnan(TRC_gas_data.at[CASRN, 'Hf']):
methods.append(TRC)
methods.append(NONE)
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == ATCT_G:
_Hfg = float(ATcT_g.at[CASRN, 'Hf_298K'])
elif Method == TRC:
_Hfg = float(TRC_gas_data.at[CASRN, 'Hf'])
elif Method == NONE:
return None
else:
raise Exception('Failure in in function')
return _Hfg |
def omega(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=['LK', 'DEFINITION']):
r'''This function handles the retrieval of a chemical's acentric factor,
`omega`, or its calculation from correlations or directly through the
definition of acentric factor if possible. Requires a known boiling point,
critical temperature and pressure for use of the correlations. Requires
accurate vapor pressure data for direct calculation.
Will automatically select a method to use if no Method is provided;
returns None if the data is not available and cannot be calculated.
.. math::
\omega \equiv -\log_{10}\left[\lim_{T/T_c=0.7}(P^{sat}/P_c)\right]-1.0
Examples
--------
>>> omega(CASRN='64-17-5')
0.635
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
omega : float
Acentric factor of compound
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain omega with the given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Accepted methods are 'PSRK', 'PD', 'YAWS',
'LK', and 'DEFINITION'. All valid values are also held in the list
omega_methods.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
omega for the desired chemical, and will return methods instead of
omega
IgnoreMethods : list, optional
A list of methods to ignore in obtaining the full list of methods,
useful for for performance reasons and ignoring inaccurate methods
Notes
-----
A total of five sources are available for this function. They are:
* 'PSRK', a compillation of experimental and estimated data published
in the Appendix of [15]_, the fourth revision of the PSRK model.
* 'PD', an older compillation of
data published in (Passut & Danner, 1973) [16]_.
* 'YAWS', a large compillation of data from a
variety of sources; no data points are sourced in the work of [17]_.
* 'LK', a estimation method for hydrocarbons.
* 'DEFINITION', based on the definition of omega as
presented in [1]_, using vapor pressure data.
References
----------
.. [1] Pitzer, K. S., D. Z. Lippmann, R. F. Curl, C. M. Huggins, and
D. E. Petersen: The Volumetric and Thermodynamic Properties of Fluids.
II. Compressibility Factor, Vapor Pressure and Entropy of Vaporization.
J. Am. Chem. Soc., 77: 3433 (1955).
.. [2] Horstmann, Sven, Anna Jabłoniec, Jörg Krafczyk, Kai Fischer, and
Jürgen Gmehling. "PSRK Group Contribution Equation of State:
Comprehensive Revision and Extension IV, Including Critical Constants
and Α-Function Parameters for 1000 Components." Fluid Phase Equilibria
227, no. 2 (January 25, 2005): 157-64. doi:10.1016/j.fluid.2004.11.002.
.. [3] Passut, Charles A., and Ronald P. Danner. "Acentric Factor. A
Valuable Correlating Parameter for the Properties of Hydrocarbons."
Industrial & Engineering Chemistry Process Design and Development 12,
no. 3 (July 1, 1973): 365-68. doi:10.1021/i260047a026.
.. [4] Yaws, Carl L. Thermophysical Properties of Chemicals and
Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
Publishing, 2014.
'''
def list_methods():
methods = []
if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'omega']):
methods.append('PSRK')
if CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, 'omega']):
methods.append('PD')
if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'omega']):
methods.append('YAWS')
Tcrit, Pcrit = Tc(CASRN), Pc(CASRN)
if Tcrit and Pcrit:
if Tb(CASRN):
methods.append('LK')
if VaporPressure(CASRN=CASRN).T_dependent_property(Tcrit*0.7):
methods.append('DEFINITION') # TODO: better integration
if IgnoreMethods:
for Method in IgnoreMethods:
if Method in methods:
methods.remove(Method)
methods.append('NONE')
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
# This is the calculate, given the method section
if Method == 'PSRK':
_omega = float(_crit_PSRKR4.at[CASRN, 'omega'])
elif Method == 'PD':
_omega = float(_crit_PassutDanner.at[CASRN, 'omega'])
elif Method == 'YAWS':
_omega = float(_crit_Yaws.at[CASRN, 'omega'])
elif Method == 'LK':
_omega = LK_omega(Tb(CASRN), Tc(CASRN), Pc(CASRN))
elif Method == 'DEFINITION':
P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc(CASRN)*0.7)
_omega = -log10(P/Pc(CASRN)) - 1.0
elif Method == 'NONE':
_omega = None
else:
raise Exception('Failure in in function')
return _omega |
def LK_omega(Tb, Tc, Pc):
r'''Estimates the acentric factor of a fluid using a correlation in [1]_.
.. math::
\omega = \frac{\ln P_{br}^{sat} - 5.92714 + 6.09648/T_{br} + 1.28862
\ln T_{br} -0.169347T_{br}^6}
{15.2518 - 15.6875/T_{br} - 13.4721 \ln T_{br} + 0.43577 T_{br}^6}
Parameters
----------
Tb : float
Boiling temperature of the fluid [K]
Tc : float
Critical temperature of the fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
Returns
-------
omega : float
Acentric factor of the fluid [-]
Notes
-----
Internal units are atmosphere and Kelvin.
Example value from Reid (1987). Using ASPEN V8.4, LK method gives 0.325595.
Examples
--------
Isopropylbenzene
>>> LK_omega(425.6, 631.1, 32.1E5)
0.32544249926397856
References
----------
.. [1] Lee, Byung Ik, and Michael G. Kesler. "A Generalized Thermodynamic
Correlation Based on Three-Parameter Corresponding States." AIChE Journal
21, no. 3 (1975): 510-527. doi:10.1002/aic.690210313.
'''
T_br = Tb/Tc
omega = (log(101325.0/Pc) - 5.92714 + 6.09648/T_br + 1.28862*log(T_br) -
0.169347*T_br**6)/(15.2518 - 15.6875/T_br - 13.4721*log(T_br) +
0.43577*T_br**6)
return omega |
def omega_mixture(omegas, zs, CASRNs=None, Method=None,
AvailableMethods=False):
r'''This function handles the calculation of a mixture's acentric factor.
Calculation is based on the omegas provided for each pure component. Will
automatically select a method to use if no Method is provided;
returns None if insufficient data is available.
Examples
--------
>>> omega_mixture([0.025, 0.12], [0.3, 0.7])
0.0915
Parameters
----------
omegas : array-like
acentric factors of each component, [-]
zs : array-like
mole fractions of each component, [-]
CASRNs: list of strings
CASRNs, not currently used [-]
Returns
-------
omega : float
acentric factor of the mixture, [-]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain omega with the given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Only 'SIMPLE' is accepted so far.
All valid values are also held in the list omega_mixture_methods.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
omega for the desired chemical, and will return methods instead of
omega
Notes
-----
The only data used in the methods implemented to date are mole fractions
and pure-component omegas. An alternate definition could be based on
the dew point or bubble point of a multicomponent mixture, but this has
not been done to date.
References
----------
.. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
New York: McGraw-Hill Professional, 2000.
'''
def list_methods():
methods = []
if none_and_length_check([zs, omegas]):
methods.append('SIMPLE')
methods.append('NONE')
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == 'SIMPLE':
_omega = mixing_simple(zs, omegas)
elif Method == 'NONE':
_omega = None
else:
raise Exception('Failure in in function')
return _omega |
def StielPolar(Tc=None, Pc=None, omega=None, CASRN='', Method=None,
AvailableMethods=False):
r'''This function handles the calculation of a chemical's Stiel Polar
factor, directly through the definition of Stiel-polar factor if possible.
Requires Tc, Pc, acentric factor, and a vapor pressure datum at Tr=0.6.
Will automatically select a method to use if no Method is provided;
returns None if the data is not available and cannot be calculated.
.. math::
x = \log P_r|_{T_r=0.6} + 1.70 \omega + 1.552
Parameters
----------
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
omega : float
Acentric factor of the fluid [-]
CASRN : string
CASRN [-]
Returns
-------
factor : float
Stiel polar factor of compound
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Stiel polar factor with the
given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Only 'DEFINITION' is accepted so far.
All valid values are also held in the list Stiel_polar_methods.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Stiel-polar factor for the desired chemical, and will return methods
instead of stiel-polar factor
Notes
-----
Only one source is available for this function. It is:
* 'DEFINITION', based on the definition of
Stiel Polar Factor presented in [1]_, using vapor pressure data.
A few points have also been published in [2]_, which may be used for
comparison. Currently this is only used for a surface tension correlation.
Examples
--------
>>> StielPolar(647.3, 22048321.0, 0.344, CASRN='7732-18-5')
0.024581140348734376
References
----------
.. [1] Halm, Roland L., and Leonard I. Stiel. "A Fourth Parameter for the
Vapor Pressure and Entropy of Vaporization of Polar Fluids." AIChE
Journal 13, no. 2 (1967): 351-355. doi:10.1002/aic.690130228.
.. [2] D, Kukoljac Miloš, and Grozdanić Dušan K. "New Values of the
Polarity Factor." Journal of the Serbian Chemical Society 65, no. 12
(January 1, 2000). http://www.shd.org.rs/JSCS/Vol65/No12-Pdf/JSCS12-07.pdf
'''
def list_methods():
methods = []
if Tc and Pc and omega:
methods.append('DEFINITION')
methods.append('NONE')
return methods
if AvailableMethods:
return list_methods()
if not Method:
Method = list_methods()[0]
if Method == 'DEFINITION':
P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc*0.6)
if not P:
factor = None
else:
Pr = P/Pc
factor = log10(Pr) + 1.70*omega + 1.552
elif Method == 'NONE':
factor = None
else:
raise Exception('Failure in in function')
return factor |
def VDI_tabular_data(CASRN, prop):
r'''This function retrieves the tabular data available for a given chemical
and a given property. Lookup is based on CASRNs. Length of data returned
varies between chemicals. All data is at saturation condition from [1]_.
Function has data for 58 chemicals.
Parameters
----------
CASRN : string
CASRN [-]
prop : string
Property [-]
Returns
-------
Ts : list
Temperatures where property data is available, [K]
props : list
Properties at each temperature, [various]
Notes
-----
The available properties are 'P', 'Density (l)', 'Density (g)', 'Hvap',
'Cp (l)', 'Cp (g)', 'Mu (l)', 'Mu (g)', 'K (l)', 'K (g)', 'Pr (l)',
'Pr (g)', 'sigma', 'Beta', 'Volume (l)', and 'Volume (g)'.
Data is available for all properties and all chemicals; surface tension
data was missing for mercury, but added as estimated from the a/b
coefficients listed in Jasper (1972) to simplify the function.
Examples
--------
>>> VDI_tabular_data('67-56-1', 'Mu (g)')
([337.63, 360.0, 385.0, 410.0, 435.0, 460.0, 500.0], [1.11e-05, 1.18e-05, 1.27e-05, 1.36e-05, 1.46e-05, 1.59e-05, 2.04e-05])
References
----------
.. [1] Gesellschaft, VDI, ed. VDI Heat Atlas. 2E. Berlin : Springer, 2010.
'''
try:
d = _VDISaturationDict[CASRN]
except KeyError:
raise Exception('CASRN not in VDI tabulation')
try:
props, Ts = d[prop], d['T']
except:
raise Exception('Proprty not specified correctly')
Ts = [T for p, T in zip(props, Ts) if p]
props = [p for p in props if p]
# Not all data series convererge to correct values
if prop == 'sigma':
Ts.append(d['Tc'])
props.append(0)
return Ts, props |
def ViswanathNatarajan2(T, A, B):
'''
This function is known to produce values 10 times too low.
The author's data must have an error.
I have adjusted it to fix this.
# DDBST has 0.0004580 as a value at this temperature
>>> ViswanathNatarajan2(348.15, -5.9719, 1007.0)
0.00045983686956829517
'''
mu = exp(A + B/T)
mu = mu/1000.
mu = mu*10
return mu |
def ViswanathNatarajan3(T, A, B, C):
r'''Calculate the viscosity of a liquid using the 3-term Antoine form
representation developed in [1]_. Requires input coefficients. The `A`
coefficient is assumed to yield coefficients in centipoise, as all
coefficients found so far have been.
.. math::
\log_{10} \mu = A + B/(T + C)
Parameters
----------
T : float
Temperature of fluid [K]
Returns
-------
mu : float
Liquid viscosity, [Pa*s]
Notes
-----
No other source for these coefficients has been found.
Examples
--------
>>> ViswanathNatarajan3(298.15, -2.7173, -1071.18, -129.51)
0.0006129806445142112
References
----------
.. [1] Viswanath, Dabir S., and G. Natarajan. Databook On The Viscosity Of
Liquids. New York: Taylor & Francis, 1989
'''
mu = 10**(A + B/(C - T))
return mu/1000. |
def Letsou_Stiel(T, MW, Tc, Pc, omega):
r'''Calculates the viscosity of a liquid using an emperical model
developed in [1]_. However. the fitting parameters for tabulated values
in the original article are found in ChemSep.
.. math::
\xi = \frac{2173.424 T_c^{1/6}}{\sqrt{MW} P_c^{2/3}}
\xi^{(0)} = (1.5174 - 2.135T_r + 0.75T_r^2)\cdot 10^{-5}
\xi^{(1)} = (4.2552 - 7.674 T_r + 3.4 T_r^2)\cdot 10^{-5}
\mu = (\xi^{(0)} + \omega \xi^{(1)})/\xi
Parameters
----------
T : float
Temperature of fluid [K]
MW : float
Molwcular weight of fluid [g/mol]
Tc : float
Critical temperature of the fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
omega : float
Acentric factor of compound
Returns
-------
mu_l : float
Viscosity of liquid, [Pa*S]
Notes
-----
The form of this equation is a polynomial fit to tabulated data.
The fitting was performed by the DIPPR. This is DIPPR Procedure 8G: Method
for the viscosity of pure, nonhydrocarbon liquids at high temperatures
internal units are SI standard. [1]_'s units were different.
DIPPR test value for ethanol is used.
Average error 34%. Range of applicability is 0.76 < Tr < 0.98.
Examples
--------
>>> Letsou_Stiel(400., 46.07, 516.25, 6.383E6, 0.6371)
0.0002036150875308151
References
----------
.. [1] Letsou, Athena, and Leonard I. Stiel. "Viscosity of Saturated
Nonpolar Liquids at Elevated Pressures." AIChE Journal 19, no. 2 (1973):
409-11. doi:10.1002/aic.690190241.
'''
Tr = T/Tc
xi0 = (1.5174-2.135*Tr + 0.75*Tr**2)*1E-5
xi1 = (4.2552-7.674*Tr + 3.4*Tr**2)*1E-5
xi = 2173.424*Tc**(1/6.)/(MW**0.5*Pc**(2/3.))
return (xi0 + omega*xi1)/xi |
def Przedziecki_Sridhar(T, Tm, Tc, Pc, Vc, Vm, omega, MW):
r'''Calculates the viscosity of a liquid using an emperical formula
developed in [1]_.
.. math::
\mu=\frac{V_o}{E(V-V_o)}
E=-1.12+\frac{V_c}{12.94+0.10MW-0.23P_c+0.0424T_{m}-11.58(T_{m}/T_c)}
V_o = 0.0085\omega T_c-2.02+\frac{V_{m}}{0.342(T_m/T_c)+0.894}
Parameters
----------
T : float
Temperature of the fluid [K]
Tm : float
Melting point of fluid [K]
Tc : float
Critical temperature of the fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
Vc : float
Critical volume of the fluid [m^3/mol]
Vm : float
Molar volume of the fluid at temperature [K]
omega : float
Acentric factor of compound
MW : float
Molwcular weight of fluid [g/mol]
Returns
-------
mu_l : float
Viscosity of liquid, [Pa*S]
Notes
-----
A test by Reid (1983) is used, but only mostly correct.
This function is not recommended. Its use has been removed from the Liquid Viscosity function.
Internal units are bar and mL/mol.
TODO: Test again with data from 5th ed table.
Examples
--------
>>> Przedziecki_Sridhar(383., 178., 591.8, 41E5, 316E-6, 95E-6, .263, 92.14)
0.0002198147995603383
References
----------
.. [1] Przedziecki, J. W., and T. Sridhar. "Prediction of Liquid
Viscosities." AIChE Journal 31, no. 2 (February 1, 1985): 333-35.
doi:10.1002/aic.690310225.
'''
Pc = Pc/1E5 # Pa to atm
Vm, Vc = Vm*1E6, Vc*1E6 # m^3/mol to mL/mol
Tr = T/Tc
Gamma = 0.29607 - 0.09045*Tr - 0.04842*Tr**2
VrT = 0.33593-0.33953*Tr + 1.51941*Tr**2 - 2.02512*Tr**3 + 1.11422*Tr**4
V = VrT*(1-omega*Gamma)*Vc
Vo = 0.0085*omega*Tc - 2.02 + Vm/(0.342*(Tm/Tc) + 0.894) # checked
E = -1.12 + Vc/(12.94 + 0.1*MW - 0.23*Pc + 0.0424*Tm - 11.58*(Tm/Tc))
return Vo/(E*(V-Vo))/1000. |
def Lucas(T, P, Tc, Pc, omega, P_sat, mu_l):
r'''Adjustes for pressure the viscosity of a liquid using an emperical
formula developed in [1]_, but as discussed in [2]_ as the original source
is in German.
.. math::
\frac{\mu}{\mu_{sat}}=\frac{1+D(\Delta P_r/2.118)^A}{1+C\omega \Delta P_r}
\Delta P_r = \frac{P-P^{sat}}{P_c}
A=0.9991-\frac{4.674\times 10^{-4}}{1.0523T_r^{-0.03877}-1.0513}
D = \frac{0.3257}{(1.0039-T_r^{2.573})^{0.2906}}-0.2086
C = -0.07921+2.1616T_r-13.4040T_r^2+44.1706T_r^3-84.8291T_r^4+
96.1209T_r^5-59.8127T_r^6+15.6719T_r^7
Parameters
----------
T : float
Temperature of fluid [K]
P : float
Pressure of fluid [Pa]
Tc: float
Critical point of fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
omega : float
Acentric factor of compound
P_sat : float
Saturation pressure of the fluid [Pa]
mu_l : float
Viscosity of liquid at 1 atm or saturation, [Pa*S]
Returns
-------
mu_l_dense : float
Viscosity of liquid, [Pa*s]
Notes
-----
This equation is entirely dimensionless; all dimensions cancel.
The example is from Reid (1987); all results agree.
Above several thousand bar, this equation does not represent true behavior.
If Psat is larger than P, the fluid may not be liquid; dPr is set to 0.
Examples
--------
>>> Lucas(300., 500E5, 572.2, 34.7E5, 0.236, 0, 0.00068) # methylcyclohexane
0.0010683738499316518
References
----------
.. [1] Lucas, Klaus. "Ein Einfaches Verfahren Zur Berechnung Der
Viskositat von Gasen Und Gasgemischen." Chemie Ingenieur Technik 46, no. 4
(February 1, 1974): 157-157. doi:10.1002/cite.330460413.
.. [2] Reid, Robert C.; Prausnitz, John M.; Poling, Bruce E.
Properties of Gases and Liquids. McGraw-Hill Companies, 1987.
'''
Tr = T/Tc
C = -0.07921+2.1616*Tr - 13.4040*Tr**2 + 44.1706*Tr**3 - 84.8291*Tr**4 \
+ 96.1209*Tr**5-59.8127*Tr**6+15.6719*Tr**7
D = 0.3257/((1.0039-Tr**2.573)**0.2906) - 0.2086
A = 0.9991 - 4.674E-4/(1.0523*Tr**-0.03877 - 1.0513)
dPr = (P-P_sat)/Pc
if dPr < 0:
dPr = 0
return (1. + D*(dPr/2.118)**A)/(1. + C*omega*dPr)*mu_l |
def Yoon_Thodos(T, Tc, Pc, MW):
r'''Calculates the viscosity of a gas using an emperical formula
developed in [1]_.
.. math::
\eta \xi \times 10^8 = 46.10 T_r^{0.618} - 20.40 \exp(-0.449T_r) + 1
9.40\exp(-4.058T_r)+1
\xi = 2173.424 T_c^{1/6} MW^{-1/2} P_c^{-2/3}
Parameters
----------
T : float
Temperature of the fluid [K]
Tc : float
Critical temperature of the fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
MW : float
Molwcular weight of fluid [g/mol]
Returns
-------
mu_g : float
Viscosity of gas, [Pa*S]
Notes
-----
This equation has been tested. The equation uses SI units only internally.
The constant 2173.424 is an adjustment factor for units.
Average deviation within 3% for most compounds.
Greatest accuracy with dipole moments close to 0.
Hydrogen and helium have different coefficients, not implemented.
This is DIPPR Procedure 8B: Method for the Viscosity of Pure,
non hydrocarbon, nonpolar gases at low pressures
Examples
--------
>>> Yoon_Thodos(300., 556.35, 4.5596E6, 153.8)
1.0194885727776819e-05
References
----------
.. [1] Yoon, Poong, and George Thodos. "Viscosity of Nonpolar Gaseous
Mixtures at Normal Pressures." AIChE Journal 16, no. 2 (1970): 300-304.
doi:10.1002/aic.690160225.
'''
Tr = T/Tc
xi = 2173.4241*Tc**(1/6.)/(MW**0.5*Pc**(2/3.))
a = 46.1
b = 0.618
c = 20.4
d = -0.449
e = 19.4
f = -4.058
return (1. + a*Tr**b - c * exp(d*Tr) + e*exp(f*Tr))/(1E8*xi) |
def Stiel_Thodos(T, Tc, Pc, MW):
r'''Calculates the viscosity of a gas using an emperical formula
developed in [1]_.
.. math::
TODO
Parameters
----------
T : float
Temperature of the fluid [K]
Tc : float
Critical temperature of the fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
MW : float
Molwcular weight of fluid [g/mol]
Returns
-------
mu_g : float
Viscosity of gas, [Pa*S]
Notes
-----
Untested.
Claimed applicability from 0.2 to 5 atm.
Developed with data from 52 nonpolar, and 53 polar gases.
internal units are poise and atm.
Seems to give reasonable results.
Examples
--------
>>> Stiel_Thodos(300., 556.35, 4.5596E6, 153.8) #CCl4
1.0408926223608723e-05
References
----------
.. [1] Stiel, Leonard I., and George Thodos. "The Viscosity of Nonpolar
Gases at Normal Pressures." AIChE Journal 7, no. 4 (1961): 611-15.
doi:10.1002/aic.690070416.
'''
Pc = Pc/101325.
Tr = T/Tc
xi = Tc**(1/6.)/(MW**0.5*Pc**(2/3.))
if Tr > 1.5:
mu_g = 17.78E-5*(4.58*Tr-1.67)**.625/xi
else:
mu_g = 34E-5*Tr**0.94/xi
return mu_g/1000. |
def lucas_gas(T, Tc, Pc, Zc, MW, dipole=0, CASRN=None):
r'''Estimate the viscosity of a gas using an emperical
formula developed in several sources, but as discussed in [1]_ as the
original sources are in German or merely personal communications with the
authors of [1]_.
.. math::
\eta = \left[0.807T_r^{0.618}-0.357\exp(-0.449T_r) + 0.340\exp(-4.058
T_r) + 0.018\right]F_p^\circ F_Q^\circ /\xi
F_p^\circ=1, 0 \le \mu_{r} < 0.022
F_p^\circ = 1+30.55(0.292-Z_c)^{1.72}, 0.022 \le \mu_{r} < 0.075
F_p^\circ = 1+30.55(0.292-Z_c)^{1.72}|0.96+0.1(T_r-0.7)| 0.075 < \mu_{r}
F_Q^\circ = 1.22Q^{0.15}\left\{ 1+0.00385[(T_r-12)^2]^{1/M}\text{sign}
(T_r-12)\right\}
\mu_r = 52.46 \frac{\mu^2 P_c}{T_c^2}
\xi=0.176\left(\frac{T_c}{MW^3 P_c^4}\right)^{1/6}
Parameters
----------
T : float
Temperature of fluid [K]
Tc: float
Critical point of fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
Zc : float
Critical compressibility of the fluid [Pa]
dipole : float
Dipole moment of fluid [debye]
CASRN : str, optional
CAS of the fluid
Returns
-------
mu_g : float
Viscosity of gas, [Pa*s]
Notes
-----
The example is from [1]_; all results agree.
Viscosity is calculated in micropoise, and converted to SI internally (1E-7).
Q for He = 1.38; Q for H2 = 0.76; Q for D2 = 0.52.
Examples
--------
>>> lucas_gas(T=550., Tc=512.6, Pc=80.9E5, Zc=0.224, MW=32.042, dipole=1.7)
1.7822676912698928e-05
References
----------
.. [1] Reid, Robert C.; Prausnitz, John M.; Poling, Bruce E.
Properties of Gases and Liquids. McGraw-Hill Companies, 1987.
'''
Tr = T/Tc
xi = 0.176*(Tc/MW**3/(Pc/1E5)**4)**(1/6.) # bar arrording to example in Poling
if dipole is None:
dipole = 0
dipoler = 52.46*dipole**2*(Pc/1E5)/Tc**2 # bar arrording to example in Poling
if dipoler < 0.022:
Fp = 1
elif 0.022 <= dipoler < 0.075:
Fp = 1 + 30.55*(0.292 - Zc)**1.72
else:
Fp = 1 + 30.55*(0.292 - Zc)**1.72*abs(0.96 + 0.1*(Tr-0.7))
if CASRN and CASRN in _lucas_Q_dict:
Q = _lucas_Q_dict[CASRN]
if Tr - 12 > 0:
value = 1
else:
value = -1
FQ = 1.22*Q**0.15*(1 + 0.00385*((Tr-12)**2)**(1./MW)*value)
else:
FQ = 1
eta = (0.807*Tr**0.618 - 0.357*exp(-0.449*Tr) + 0.340*exp(-4.058*Tr) + 0.018)*Fp*FQ/xi
return eta/1E7 |
def Gharagheizi_gas_viscosity(T, Tc, Pc, MW):
r'''Calculates the viscosity of a gas using an emperical formula
developed in [1]_.
.. math::
\mu = 10^{-7} | 10^{-5} P_cT_r + \left(0.091-\frac{0.477}{M}\right)T +
M \left(10^{-5}P_c-\frac{8M^2}{T^2}\right)
\left(\frac{10.7639}{T_c}-\frac{4.1929}{T}\right)|
Parameters
----------
T : float
Temperature of the fluid [K]
Tc : float
Critical temperature of the fluid [K]
Pc : float
Critical pressure of the fluid [Pa]
MW : float
Molwcular weight of fluid [g/mol]
Returns
-------
mu_g : float
Viscosity of gas, [Pa*S]
Notes
-----
Example is first point in supporting information of article, for methane.
This is the prefered function for gas viscosity.
7% average relative deviation. Deviation should never be above 30%.
Developed with the DIPPR database. It is believed theoretically predicted values
are included in the correlation.
Examples
--------
>>> Gharagheizi_gas_viscosity(120., 190.564, 45.99E5, 16.04246)
5.215761625399613e-06
References
----------
.. [1] Gharagheizi, Farhad, Ali Eslamimanesh, Mehdi Sattari, Amir H.
Mohammadi, and Dominique Richon. "Corresponding States Method for
Determination of the Viscosity of Gases at Atmospheric Pressure."
Industrial & Engineering Chemistry Research 51, no. 7
(February 22, 2012): 3179-85. doi:10.1021/ie202591f.
'''
Tr = T/Tc
mu_g = 1E-5*Pc*Tr + (0.091 - 0.477/MW)*T + MW*(1E-5*Pc - 8*MW**2/T**2)*(10.7639/Tc - 4.1929/T)
return 1E-7 * abs(mu_g) |
def Herning_Zipperer(zs, mus, MWs):
r'''Calculates viscosity of a gas mixture according to
mixing rules in [1]_.
.. math::
TODO
Parameters
----------
zs : float
Mole fractions of components
mus : float
Gas viscosities of all components, [Pa*S]
MWs : float
Molecular weights of all components, [g/mol]
Returns
-------
mug : float
Viscosity of gas mixture, Pa*S]
Notes
-----
This equation is entirely dimensionless; all dimensions cancel.
The original source has not been reviewed.
Examples
--------
References
----------
.. [1] Herning, F. and Zipperer, L,: "Calculation of the Viscosity of
Technical Gas Mixtures from the Viscosity of Individual Gases, german",
Gas u. Wasserfach (1936) 79, No. 49, 69.
'''
if not none_and_length_check([zs, mus, MWs]): # check same-length inputs
raise Exception('Function inputs are incorrect format')
MW_roots = [MWi**0.5 for MWi in MWs]
denominator = sum([zi*MW_root_i for zi, MW_root_i in zip(zs, MW_roots)])
k = sum([zi*mui*MW_root_i for zi, mui, MW_root_i in zip(zs, mus, MW_roots)])
return k/denominator |
def Wilke(ys, mus, MWs):
r'''Calculates viscosity of a gas mixture according to
mixing rules in [1]_.
.. math::
\eta_{mix} = \sum_{i=1}^n \frac{y_i \eta_i}{\sum_{j=1}^n y_j \phi_{ij}}
\phi_{ij} = \frac{(1 + \sqrt{\eta_i/\eta_j}(MW_j/MW_i)^{0.25})^2}
{\sqrt{8(1+MW_i/MW_j)}}
Parameters
----------
ys : float
Mole fractions of gas components
mus : float
Gas viscosities of all components, [Pa*S]
MWs : float
Molecular weights of all components, [g/mol]
Returns
-------
mug : float
Viscosity of gas mixture, Pa*S]
Notes
-----
This equation is entirely dimensionless; all dimensions cancel.
The original source has not been reviewed or found.
Examples
--------
>>> Wilke([0.05, 0.95], [1.34E-5, 9.5029E-6], [64.06, 46.07])
9.701614885866193e-06
References
----------
.. [1] TODO
'''
if not none_and_length_check([ys, mus, MWs]): # check same-length inputs
raise Exception('Function inputs are incorrect format')
cmps = range(len(ys))
phis = [[(1 + (mus[i]/mus[j])**0.5*(MWs[j]/MWs[i])**0.25)**2/(8*(1 + MWs[i]/MWs[j]))**0.5
for j in cmps] for i in cmps]
return sum([ys[i]*mus[i]/sum([ys[j]*phis[i][j] for j in cmps]) for i in cmps]) |
def Brokaw(T, ys, mus, MWs, molecular_diameters, Stockmayers):
r'''Calculates viscosity of a gas mixture according to
mixing rules in [1]_.
.. math::
\eta_{mix} = \sum_{i=1}^n \frac{y_i \eta_i}{\sum_{j=1}^n y_j \phi_{ij}}
\phi_{ij} = \left( \frac{\eta_i}{\eta_j} \right)^{0.5} S_{ij} A_{ij}
A_{ij} = m_{ij} M_{ij}^{-0.5} \left[1 +
\frac{M_{ij} - M_{ij}^{0.45}}
{2(1+M_{ij}) + \frac{(1 + M_{ij}^{0.45}) m_{ij}^{-0.5}}{1 + m_{ij}}} \right]
m_{ij} = \left[ \frac{4}{(1+M_{ij}^{-1})(1+M_{ij})}\right]^{0.25}
M_{ij} = \frac{M_i}{M_j}
S_{ij} = \frac{1 + (T_i^* T_j^*)^{0.5} + (\delta_i \delta_j/4)}
{[1+T_i^* + (\delta_i^2/4)]^{0.5}[1+T_j^*+(\delta_j^2/4)]^{0.5}}
T^* = kT/\epsilon
Parameters
----------
T : float
Temperature of fluid, [K]
ys : float
Mole fractions of gas components
mus : float
Gas viscosities of all components, [Pa*S]
MWs : float
Molecular weights of all components, [g/mol]
molecular_diameters : float
L-J molecular diameter of all components, [angstroms]
Stockmayers : float
L-J Stockmayer energy parameters of all components, []
Returns
-------
mug : float
Viscosity of gas mixture, [Pa*S]
Notes
-----
This equation is entirely dimensionless; all dimensions cancel.
The original source has not been reviewed.
This is DIPPR Procedure 8D: Method for the Viscosity of Nonhydrocarbon
Vapor Mixtures at Low Pressure (Polar and Nonpolar)
Examples
--------
>>> Brokaw(308.2, [0.05, 0.95], [1.34E-5, 9.5029E-6], [64.06, 46.07], [0.42, 0.19], [347, 432])
9.699085099801568e-06
References
----------
.. [1] Brokaw, R. S. "Predicting Transport Properties of Dilute Gases."
Industrial & Engineering Chemistry Process Design and Development
8, no. 2 (April 1, 1969): 240-53. doi:10.1021/i260030a015.
.. [2] Brokaw, R. S. Viscosity of Gas Mixtures, NASA-TN-D-4496, 1968.
.. [3] Danner, Ronald P, and Design Institute for Physical Property Data.
Manual for Predicting Chemical Process Design Data. New York, N.Y, 1982.
'''
cmps = range(len(ys))
MDs = molecular_diameters
if not none_and_length_check([ys, mus, MWs, molecular_diameters, Stockmayers]): # check same-length inputs
raise Exception('Function inputs are incorrect format')
Tsts = [T/Stockmayer_i for Stockmayer_i in Stockmayers]
Sij = [[0 for i in cmps] for j in cmps]
Mij = [[0 for i in cmps] for j in cmps]
mij = [[0 for i in cmps] for j in cmps]
Aij = [[0 for i in cmps] for j in cmps]
phiij =[[0 for i in cmps] for j in cmps]
for i in cmps:
for j in cmps:
Sij[i][j] = (1+(Tsts[i]*Tsts[j])**0.5 + (MDs[i]*MDs[j])/4.)/(1 + Tsts[i] + (MDs[i]**2/4.))**0.5/(1 + Tsts[j] + (MDs[j]**2/4.))**0.5
if MDs[i] <= 0.1 and MDs[j] <= 0.1:
Sij[i][j] = 1
Mij[i][j] = MWs[i]/MWs[j]
mij[i][j] = (4./(1+Mij[i][j]**-1)/(1+Mij[i][j]))**0.25
Aij[i][j] = mij[i][j]*Mij[i][j]**-0.5*(1 + (Mij[i][j]-Mij[i][j]**0.45)/(2*(1+Mij[i][j]) + (1+Mij[i][j]**0.45)*mij[i][j]**-0.5/(1+mij[i][j])))
phiij[i][j] = (mus[i]/mus[j])**0.5*Sij[i][j]*Aij[i][j]
return sum([ys[i]*mus[i]/sum([ys[j]*phiij[i][j] for j in cmps]) for i in cmps]) |
def _round_whole_even(i):
r'''Round a number to the nearest whole number. If the number is exactly
between two numbers, round to the even whole number. Used by
`viscosity_index`.
Parameters
----------
i : float
Number, [-]
Returns
-------
i : int
Rounded number, [-]
Notes
-----
Should never run with inputs from a practical function, as numbers on
computers aren't really normally exactly between two numbers.
Examples
--------
_round_whole_even(116.5)
116
'''
if i % .5 == 0:
if (i + 0.5) % 2 == 0:
i = i + 0.5
else:
i = i - 0.5
else:
i = round(i, 0)
return int(i) |
def viscosity_index(nu_40, nu_100, rounding=False):
r'''Calculates the viscosity index of a liquid. Requires dynamic viscosity
of a liquid at 40°C and 100°C. Value may either be returned with or
without rounding. Rounding is performed per the standard.
if nu_100 < 70:
.. math::
L, H = interp(nu_100)
else:
.. math::
L = 0.8353\nu_{100}^2 + 14.67\nu_{100} - 216
H = 0.1684\nu_{100}^2 + 11.85\nu_{100} - 97
if nu_40 > H:
.. math::
VI = \frac{L-nu_{40}}{L-H}\cdot 100
else:
.. math::
N = \frac{\log(H) - \log(\nu_{40})}{\log (\nu_{100})}
VI = \frac{10^N-1}{0.00715} + 100
Parameters
----------
nu_40 : float
Dynamic viscosity of fluid at 40°C, [m^2/s]
nu_100 : float
Dynamic viscosity of fluid at 100°C, [m^2/s]
rounding : bool, optional
Whether to round the value or not.
Returns
-------
VI: float
Viscosity index [-]
Notes
-----
VI is undefined for nu_100 under 2 mm^2/s. None is returned if this is the
case. Internal units are mm^2/s. Higher values of viscosity index suggest
a lesser decrease in kinematic viscosity as temperature increases.
Note that viscosity is a pressure-dependent property, and that the
viscosity index is defined for a fluid at whatever pressure it is at.
The viscosity index is thus also a function of pressure.
Examples
--------
>>> viscosity_index(73.3E-6, 8.86E-6, rounding=True)
92
References
----------
.. [1] ASTM D2270-10(2016) Standard Practice for Calculating Viscosity
Index from Kinematic Viscosity at 40 °C and 100 °C, ASTM International,
West Conshohocken, PA, 2016, http://dx.doi.org/10.1520/D2270-10R16
'''
nu_40, nu_100 = nu_40*1E6, nu_100*1E6 # m^2/s to mm^2/s
if nu_100 < 2:
return None # Not defined for under this
elif nu_100 < 70:
L = np.interp(nu_100, VI_nus, VI_Ls)
H = np.interp(nu_100, VI_nus, VI_Hs)
else:
L = 0.8353*nu_100**2 + 14.67*nu_100 - 216
H = 0.1684*nu_100**2 + 11.85*nu_100 - 97
if nu_40 > H:
VI = (L-nu_40)/(L-H)*100
else:
N = (log(H) - log(nu_40))/log(nu_100)
VI = (10**N-1)/0.00715 + 100
if rounding:
VI = _round_whole_even(VI)
return VI |
def viscosity_converter(val, old_scale, new_scale, extrapolate=False):
r'''Converts kinematic viscosity values from different scales which have
historically been used. Though they may not be in use much, some standards
still specify values in these scales.
Parameters
----------
val : float
Viscosity value in the specified scale; [m^2/s] if
'kinematic viscosity'; [degrees] if Engler or Barbey; [s] for the other
scales.
old_scale : str
String representing the scale that `val` is in originally.
new_scale : str
String representing the scale that `val` should be converted to.
extrapolate : bool
If True, a conversion will be performed even if outside the limits of
either scale; if False, and either value is outside a limit, an
exception will be raised.
Returns
-------
result : float
Viscosity value in the specified scale; [m^2/s] if
'kinematic viscosity'; [degrees] if Engler or Barbey; [s] for the other
scales
Notes
-----
The valid scales for this function are any of the following:
['a&w b', 'a&w crucible', 'american can', 'astm 0.07', 'astm 0.10',
'astm 0.15', 'astm 0.20', 'astm 0.25', 'barbey', 'caspers tin plate',
'continental can', 'crown cork and seal', 'demmier #1', 'demmier #10',
'engler', 'ford cup #3', 'ford cup #4', 'kinematic viscosity',
'mac michael', 'murphy varnish', 'parlin cup #10', 'parlin cup #15',
'parlin cup #20', 'parlin cup #25', 'parlin cup #30', 'parlin cup #7',
'pratt lambert a', 'pratt lambert b', 'pratt lambert c', 'pratt lambert d',
'pratt lambert e', 'pratt lambert f', 'pratt lambert g', 'pratt lambert h',
'pratt lambert i', 'redwood admiralty', 'redwood standard',
'saybolt furol', 'saybolt universal', 'scott', 'stormer 100g load',
'westinghouse', 'zahn cup #1', 'zahn cup #2', 'zahn cup #3', 'zahn cup #4',
'zahn cup #5']
Some of those scales are converted linearly; the rest use tabulated data
and splines.
Because the conversion is performed by spline functions, a re-conversion
of a value will not yield exactly the original value. However, it is quite
close.
The method 'Saybolt universal' has a special formula implemented for its
conversion, from [4]_. It is designed for maximum backwards compatibility
with prior experimental data. It is solved by newton's method when
kinematic viscosity is desired as an output.
.. math::
SUS_{eq} = 4.6324\nu_t + \frac{[1.0 + 0.03264\nu_t]}
{[(3930.2 + 262.7\nu_t + 23.97\nu_t^2 + 1.646\nu_t^3)\times10^{-5})]}
Examples
--------
>>> viscosity_converter(8.79, 'engler', 'parlin cup #7')
52.5
>>> viscosity_converter(700, 'Saybolt Universal Seconds', 'kinematic viscosity')
0.00015108914751515542
References
----------
.. [1] Hydraulic Institute. Hydraulic Institute Engineering Data Book.
Cleveland, Ohio: Hydraulic Institute, 1990.
.. [2] Gardner/Sward. Paint Testing Manual. Physical and Chemical
Examination of Paints, Varnishes, Lacquers, and Colors. 13th Edition.
ASTM, 1972.
.. [3] Euverard, M. R., The Efflux Type Viscosity Cup. National Paint,
Varnish, and Lacquer Association, 1948.
.. [4] API Technical Data Book: General Properties & Characterization.
American Petroleum Institute, 7E, 2005.
.. [5] ASTM. Standard Practice for Conversion of Kinematic Viscosity to
Saybolt Universal Viscosity or to Saybolt Furol Viscosity. D 2161 - 93.
'''
def range_check(visc, scale):
scale_min, scale_max, nu_min, nu_max = viscosity_converter_limits[scale]
if visc < scale_min*(1.-1E-7) or visc > scale_max*(1.+1E-7):
raise Exception('Viscosity conversion is outside the limits of the '
'%s scale; given value is %s, but the range of the '
'scale is from %s to %s. Set `extrapolate` to True '
'to perform the conversion anyway.' %(scale, visc, scale_min, scale_max))
def range_check_linear(val, c, tmin, scale):
if val < tmin:
raise Exception('Viscosity conversion is outside the limits of the '
'%s scale; given value is %s, but the minimum time '
'for this scale is %s s. Set `extrapolate` to True '
'to perform the conversion anyway.' %(scale, val, tmin))
old_scale = old_scale.lower().replace('degrees', '').replace('seconds', '').strip()
new_scale = new_scale.lower().replace('degrees', '').replace('seconds', '').strip()
def Saybolt_universal_eq(nu):
return (4.6324*nu + (1E5 + 3264.*nu)/(nu*(nu*(1.646*nu + 23.97)
+ 262.7) + 3930.2))
# Convert to kinematic viscosity
if old_scale == 'kinematic viscosity':
val = 1E6*val # convert to centistokes, the basis of the functions
elif old_scale == 'saybolt universal':
if not extrapolate:
range_check(val, old_scale)
to_solve = lambda nu: Saybolt_universal_eq(nu) - val
val = newton(to_solve, 1)
elif old_scale in viscosity_converters_to_nu:
if not extrapolate:
range_check(val, old_scale)
val = exp(viscosity_converters_to_nu[old_scale](log(val)))
elif old_scale in viscosity_scales_linear:
c, tmin = viscosity_scales_linear[old_scale]
if not extrapolate:
range_check_linear(val, c, tmin, old_scale)
val = c*val # convert from seconds to centistokes
else:
keys = sorted(set(list(viscosity_scales.keys()) + list(viscosity_scales_linear.keys())))
raise Exception('Scale "%s" not recognized - allowable values are any of %s.' %(old_scale, keys))
# Convert to desired scale
if new_scale == 'kinematic viscosity':
val = 1E-6*val # convert to m^2/s
elif new_scale == 'saybolt universal':
val = Saybolt_universal_eq(val)
elif new_scale in viscosity_converters_from_nu:
val = exp(viscosity_converters_from_nu[new_scale](log(val)))
if not extrapolate:
range_check(val, new_scale)
elif new_scale in viscosity_scales_linear:
c, tmin = viscosity_scales_linear[new_scale]
val = val/c # convert from centistokes to seconds
if not extrapolate:
range_check_linear(val, c, tmin, new_scale)
else:
keys = sorted(set(list(viscosity_scales.keys()) + list(viscosity_scales_linear.keys())))
raise Exception('Scale "%s" not recognized - allowable values are any of %s.' %(new_scale, keys))
return float(val) |
def load_all_methods(self):
r'''Method which picks out coefficients for the specified chemical
from the various dictionaries and DataFrames storing it. All data is
stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`,
:obj:`all_methods` and obj:`all_methods_P` as a set of methods for
which the data exists for.
Called on initialization only. See the source code for the variables at
which the coefficients are stored. The coefficients can safely be
altered once the class is initialized. This method can be called again
to reset the parameters.
'''
methods, methods_P = [], []
Tmins, Tmaxs = [], []
if has_CoolProp and self.CASRN in coolprop_dict:
methods.append(COOLPROP); methods_P.append(COOLPROP)
self.CP_f = coolprop_fluids[self.CASRN]
Tmins.append(self.CP_f.Tmin); Tmaxs.append(self.CP_f.Tc)
if self.CASRN in _VDISaturationDict:
methods.append(VDI_TABULAR)
Ts, props = VDI_tabular_data(self.CASRN, 'Mu (l)')
self.VDI_Tmin = Ts[0]
self.VDI_Tmax = Ts[-1]
self.tabular_data[VDI_TABULAR] = (Ts, props)
Tmins.append(self.VDI_Tmin); Tmaxs.append(self.VDI_Tmax)
if self.CASRN in Dutt_Prasad.index:
methods.append(DUTT_PRASAD)
_, A, B, C, self.DUTT_PRASAD_Tmin, self.DUTT_PRASAD_Tmax = _Dutt_Prasad_values[Dutt_Prasad.index.get_loc(self.CASRN)].tolist()
self.DUTT_PRASAD_coeffs = [A, B, C]
Tmins.append(self.DUTT_PRASAD_Tmin); Tmaxs.append(self.DUTT_PRASAD_Tmax)
if self.CASRN in VN3_data.index:
methods.append(VISWANATH_NATARAJAN_3)
_, _, A, B, C, self.VISWANATH_NATARAJAN_3_Tmin, self.VISWANATH_NATARAJAN_3_Tmax = _VN3_data_values[VN3_data.index.get_loc(self.CASRN)].tolist()
self.VISWANATH_NATARAJAN_3_coeffs = [A, B, C]
Tmins.append(self.VISWANATH_NATARAJAN_3_Tmin); Tmaxs.append(self.VISWANATH_NATARAJAN_3_Tmax)
if self.CASRN in VN2_data.index:
methods.append(VISWANATH_NATARAJAN_2)
_, _, A, B, self.VISWANATH_NATARAJAN_2_Tmin, self.VISWANATH_NATARAJAN_2_Tmax = _VN2_data_values[VN2_data.index.get_loc(self.CASRN)].tolist()
self.VISWANATH_NATARAJAN_2_coeffs = [A, B]
Tmins.append(self.VISWANATH_NATARAJAN_2_Tmin); Tmaxs.append(self.VISWANATH_NATARAJAN_2_Tmax)
if self.CASRN in VN2E_data.index:
methods.append(VISWANATH_NATARAJAN_2E)
_, _, C, D, self.VISWANATH_NATARAJAN_2E_Tmin, self.VISWANATH_NATARAJAN_2E_Tmax = _VN2E_data_values[VN2E_data.index.get_loc(self.CASRN)].tolist()
self.VISWANATH_NATARAJAN_2E_coeffs = [C, D]
Tmins.append(self.VISWANATH_NATARAJAN_2E_Tmin); Tmaxs.append(self.VISWANATH_NATARAJAN_2E_Tmax)
if self.CASRN in Perrys2_313.index:
methods.append(DIPPR_PERRY_8E)
_, C1, C2, C3, C4, C5, self.Perrys2_313_Tmin, self.Perrys2_313_Tmax = _Perrys2_313_values[Perrys2_313.index.get_loc(self.CASRN)].tolist()
self.Perrys2_313_coeffs = [C1, C2, C3, C4, C5]
Tmins.append(self.Perrys2_313_Tmin); Tmaxs.append(self.Perrys2_313_Tmax)
if self.CASRN in VDI_PPDS_7.index:
methods.append(VDI_PPDS)
self.VDI_PPDS_coeffs = _VDI_PPDS_7_values[VDI_PPDS_7.index.get_loc(self.CASRN)].tolist()[2:]
if all((self.MW, self.Tc, self.Pc, self.omega)):
methods.append(LETSOU_STIEL)
Tmins.append(self.Tc/4); Tmaxs.append(self.Tc) # TODO: test model at low T
if all((self.MW, self.Tm, self.Tc, self.Pc, self.Vc, self.omega, self.Vml)):
methods.append(PRZEDZIECKI_SRIDHAR)
Tmins.append(self.Tm); Tmaxs.append(self.Tc) # TODO: test model at Tm
if all([self.Tc, self.Pc, self.omega]):
methods_P.append(LUCAS)
self.all_methods = set(methods)
self.all_methods_P = set(methods_P)
if Tmins and Tmaxs:
self.Tmin, self.Tmax = min(Tmins), max(Tmaxs) |
def calculate(self, T, method):
r'''Method to calculate low-pressure liquid viscosity at tempearture
`T` with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature at which to calculate viscosity, [K]
method : str
Name of the method to use
Returns
-------
mu : float
Viscosity of the liquid at T and a low pressure, [Pa*S]
'''
if method == DUTT_PRASAD:
A, B, C = self.DUTT_PRASAD_coeffs
mu = ViswanathNatarajan3(T, A, B, C, )
elif method == VISWANATH_NATARAJAN_3:
A, B, C = self.VISWANATH_NATARAJAN_3_coeffs
mu = ViswanathNatarajan3(T, A, B, C)
elif method == VISWANATH_NATARAJAN_2:
A, B = self.VISWANATH_NATARAJAN_2_coeffs
mu = ViswanathNatarajan2(T, self.VISWANATH_NATARAJAN_2_coeffs[0], self.VISWANATH_NATARAJAN_2_coeffs[1])
elif method == VISWANATH_NATARAJAN_2E:
C, D = self.VISWANATH_NATARAJAN_2E_coeffs
mu = ViswanathNatarajan2Exponential(T, C, D)
elif method == DIPPR_PERRY_8E:
mu = EQ101(T, *self.Perrys2_313_coeffs)
elif method == COOLPROP:
mu = CoolProp_T_dependent_property(T, self.CASRN, 'V', 'l')
elif method == LETSOU_STIEL:
mu = Letsou_Stiel(T, self.MW, self.Tc, self.Pc, self.omega)
elif method == PRZEDZIECKI_SRIDHAR:
Vml = self.Vml(T) if hasattr(self.Vml, '__call__') else self.Vml
mu = Przedziecki_Sridhar(T, self.Tm, self.Tc, self.Pc, self.Vc, Vml, self.omega, self.MW)
elif method == VDI_PPDS:
A, B, C, D, E = self.VDI_PPDS_coeffs
term = (C - T)/(T-D)
if term < 0:
term1 = -((T - C)/(T-D))**(1/3.)
else:
term1 = term**(1/3.)
term2 = term*term1
mu = E*exp(A*term1 + B*term2)
elif method in self.tabular_data:
mu = self.interpolate(T, method)
return mu |
def calculate_P(self, T, P, method):
r'''Method to calculate pressure-dependent liquid viscosity at
temperature `T` and pressure `P` with a given method.
This method has no exception handling; see `TP_dependent_property`
for that.
Parameters
----------
T : float
Temperature at which to calculate viscosity, [K]
P : float
Pressure at which to calculate viscosity, [K]
method : str
Name of the method to use
Returns
-------
mu : float
Viscosity of the liquid at T and P, [Pa*S]
'''
if method == LUCAS:
mu = self.T_dependent_property(T)
Psat = self.Psat(T) if hasattr(self.Psat, '__call__') else self.Psat
mu = Lucas(T, P, self.Tc, self.Pc, self.omega, Psat, mu)
elif method == COOLPROP:
mu = PropsSI('V', 'T', T, 'P', P, self.CASRN)
elif method in self.tabular_data:
mu = self.interpolate_P(T, P, method)
return mu |
def load_all_methods(self):
r'''Method to initialize the object by precomputing any values which
may be used repeatedly and by retrieving mixture-specific variables.
All data are stored as attributes. This method also sets :obj:`Tmin`,
:obj:`Tmax`, and :obj:`all_methods` as a set of methods which should
work to calculate the property.
Called on initialization only. See the source code for the variables at
which the coefficients are stored. The coefficients can safely be
altered once the class is initialized. This method can be called again
to reset the parameters.
'''
methods = [MIXING_LOG_MOLAR, MIXING_LOG_MASS]
if len(self.CASs) > 1 and '7732-18-5' in self.CASs:
wCASs = [i for i in self.CASs if i != '7732-18-5']
if all([i in _Laliberte_Viscosity_ParametersDict for i in wCASs]):
methods.append(LALIBERTE_MU)
self.wCASs = wCASs
self.index_w = self.CASs.index('7732-18-5')
self.all_methods = set(methods)
Tmins = [i.Tmin for i in self.ViscosityLiquids if i.Tmin]
Tmaxs = [i.Tmax for i in self.ViscosityLiquids if i.Tmax]
if Tmins:
self.Tmin = max(Tmins)
if Tmaxs:
self.Tmax = max(Tmaxs) |
def calculate(self, T, P, zs, ws, method):
r'''Method to calculate viscosity of a liquid mixture at
temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
`ws` with a given method.
This method has no exception handling; see `mixture_property`
for that.
Parameters
----------
T : float
Temperature at which to calculate the property, [K]
P : float
Pressure at which to calculate the property, [Pa]
zs : list[float]
Mole fractions of all species in the mixture, [-]
ws : list[float]
Weight fractions of all species in the mixture, [-]
method : str
Name of the method to use
Returns
-------
mu : float
Viscosity of the liquid mixture, [Pa*s]
'''
if method == MIXING_LOG_MOLAR:
mus = [i(T, P) for i in self.ViscosityLiquids]
return mixing_logarithmic(zs, mus)
elif method == MIXING_LOG_MASS:
mus = [i(T, P) for i in self.ViscosityLiquids]
return mixing_logarithmic(ws, mus)
elif method == LALIBERTE_MU:
ws = list(ws) ; ws.pop(self.index_w)
return Laliberte_viscosity(T, ws, self.wCASs)
else:
raise Exception('Method not valid') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.