_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q255500 | T_converter | validation | def T_converter(T, current, desired):
r'''Converts the a temperature reading made in any of the scales
'ITS-90', 'ITS-68','ITS-48', 'ITS-76', or 'ITS-27' to any of the other
scales. Not all temperature ranges can be converted to other ranges; for
instance, 'ITS-76' is purely for low temperatures, and 5 K on it has no
conversion to 'ITS-90' or any other scale. Both a conversion to ITS-90 and
to the desired scale must be possible for the conversion to occur.
The conversion uses cubic spline interpolation.
ITS-68 conversion is valid from 14 K to 4300 K.
ITS-48 conversion is valid from 93.15 K to 4273.15 K
ITS-76 conversion is valid from 5 K to 27 K.
ITS-27 is valid from 903.15 K to 4273.15 k.
Parameters
----------
T : float
Temperature, on `current` scale [K]
current : str
String representing the scale T is in, 'ITS-90', 'ITS-68',
'ITS-48', 'ITS-76', or 'ITS-27'.
desired : str
String representing the scale T will be returned in, 'ITS-90',
'ITS-68', 'ITS-48', 'ITS-76', or 'ITS-27'.
Returns
-------
T : float
Temperature, on scale `desired` [K]
Notes
-----
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 use of splines is quite quick (20 micro seconds/calculation). While
just a spline for one-way conversion could be used, a numerical solver
would have to be used to obtain an exact result for the reverse conversion.
This was found to take approximately 1 ms/calculation, depending on the
region.
Examples
--------
>>> T_converter(500, 'ITS-68', 'ITS-48')
499.9470092992346
References
----------
.. [1] Wier, Ron D., and Robert N. Goldberg. "On the Conversion of
Thermodynamic Properties to the Basis of the International Temperature
Scale of 1990." The Journal of Chemical Thermodynamics 28, no. 3
(March 1996): 261-76. doi:10.1006/jcht.1996.0026.
.. [2] Goldberg, Robert N., and R. D. Weir. "Conversion of Temperatures
and Thermodynamic Properties to the Basis of the International
Temperature Scale of 1990 (Technical Report)." Pure and Applied
Chemistry 64, no. 10 (1992): 1545-1562. doi:10.1351/pac199264101545.
'''
def range_check(T, Tmin, Tmax):
if T < Tmin or T > Tmax:
raise Exception('Temperature conversion is outside one or both scales')
try:
if current == 'ITS-90':
pass
elif current == 'ITS-68':
| python | {
"resource": ""
} |
q255501 | GWP | validation | def GWP(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval of a chemical's Global Warming
Potential, relative to CO2. 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.
Returns the GWP for the 100yr outlook by default.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
GWP : float
Global warming potential, [(impact/mass chemical)/(impact/mass CO2)]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain GWP with the
given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Accepted methods are IPCC (2007) 100yr',
'IPCC (2007) 100yr-SAR', 'IPCC (2007) 20yr', and 'IPCC (2007) 500yr'.
All valid values are also held in the list GWP_methods.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the GWP for the desired chemical, and will return methods
instead of the GWP
Notes
-----
All data is from [1]_, the official source. Several chemicals are available
in [1]_ are not included here as they do not have a CAS.
Methods are 'IPCC (2007) 100yr', 'IPCC (2007) 100yr-SAR',
'IPCC (2007) 20yr', and 'IPCC (2007) 500yr'.
Examples
--------
Methane, 100-yr outlook
>>> GWP(CASRN='74-82-8')
25.0
References
----------
.. | python | {
"resource": ""
} |
q255502 | logP | validation | def logP(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval of a chemical's octanol-water
partition coefficient. 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.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
logP : float
Octanol-water partition coefficient, [-]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain logP with the
given inputs
Other Parameters
----------------
Method : string, optional
The method name to use. Accepted methods are 'SYRRES', or 'CRC',
All valid values are also held in the list logP_methods.
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the logP for the desired chemical, and will return methods
instead of the logP
Notes
-----
.. math::
\log P_{ oct/wat} = \log\left(\frac{\left[{solute}
\right]_{ octanol}^{un-ionized}}{\left[{solute}
\right]_{ water}^{ un-ionized}}\right)
Examples
--------
>>> logP('67-56-1')
-0.74
References
----------
.. [1] Syrres. 2006. KOWWIN Data, SrcKowData2.zip.
http://esc.syrres.com/interkow/Download/SrcKowData2.zip
| python | {
"resource": ""
} |
q255503 | VaporPressure.calculate | validation | def calculate(self, T, method):
r'''Method to calculate vapor pressure of a fluid at temperature `T`
with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature at calculate vapor pressure, [K]
method : str
Name of the method to use
Returns
-------
Psat : float
Vapor pressure at T, [pa]
'''
if method == WAGNER_MCGARRY:
Psat = Wagner_original(T, self.WAGNER_MCGARRY_Tc, self.WAGNER_MCGARRY_Pc, *self.WAGNER_MCGARRY_coefs)
elif method == WAGNER_POLING:
Psat = Wagner(T, self.WAGNER_POLING_Tc, self.WAGNER_POLING_Pc, *self.WAGNER_POLING_coefs)
elif method == ANTOINE_EXTENDED_POLING:
Psat = TRC_Antoine_extended(T, *self.ANTOINE_EXTENDED_POLING_coefs)
elif method == ANTOINE_POLING:
A, B, C = self.ANTOINE_POLING_coefs
Psat = Antoine(T, A, B, C, base=10.0)
elif method == DIPPR_PERRY_8E:
Psat = EQ101(T, *self.Perrys2_8_coeffs)
elif method == VDI_PPDS:
Psat = Wagner(T, self.VDI_PPDS_Tc, self.VDI_PPDS_Pc, *self.VDI_PPDS_coeffs)
elif method == COOLPROP:
| python | {
"resource": ""
} |
q255504 | GCEOS.solve | validation | def solve(self):
'''First EOS-generic method; should be called by all specific EOSs.
For solving for `T`, the EOS must provide the method `solve_T`.
For all cases, the EOS must provide `a_alpha_and_derivatives`.
Calls `set_from_PT` once done.
'''
self.check_sufficient_inputs()
if self.V:
if self.P:
self.T = self.solve_T(self.P, self.V)
self.a_alpha, self.da_alpha_dT, self.d2a_alpha_dT2 = self.a_alpha_and_derivatives(self.T)
else:
self.a_alpha, self.da_alpha_dT, self.d2a_alpha_dT2 = self.a_alpha_and_derivatives(self.T)
self.P = | python | {
"resource": ""
} |
q255505 | GCEOS.set_from_PT | validation | def set_from_PT(self, Vs):
'''Counts the number of real volumes in `Vs`, and determines what to do.
If there is only one real volume, the method
`set_properties_from_solution` is called with it. If there are
two real volumes, `set_properties_from_solution` is called once with
each volume. The phase is returned by `set_properties_from_solution`,
and the volumes is set to either `V_l` or `V_g` as appropriate.
Parameters
----------
Vs : list[float]
Three possible molar volumes, [m^3/mol]
'''
# All roots will have some imaginary component; ignore them if > 1E-9
good_roots = []
bad_roots = []
for i in Vs:
j = i.real
if abs(i.imag) > 1E-9 or j < 0:
bad_roots.append(i)
else:
good_roots.append(j)
if | python | {
"resource": ""
} |
q255506 | GCEOS.solve_T | validation | def solve_T(self, P, V, quick=True):
'''Generic method to calculate `T` from a specified `P` and `V`.
Provides SciPy's `newton` solver, and iterates to solve the general
equation for `P`, recalculating `a_alpha` as a function of temperature
using `a_alpha_and_derivatives` each iteration.
Parameters
----------
P : float
Pressure, [Pa]
V : float
Molar volume, [m^3/mol]
quick : bool, optional
Whether to use a SymPy cse-derived expression (3x faster) or
| python | {
"resource": ""
} |
q255507 | PR.a_alpha_and_derivatives | validation | def a_alpha_and_derivatives(self, T, full=True, quick=True):
r'''Method to calculate `a_alpha` and its first and second
derivatives for this EOS. Returns `a_alpha`, `da_alpha_dT`, and
`d2a_alpha_dT2`. See `GCEOS.a_alpha_and_derivatives` for more
documentation. Uses the set values of `Tc`, `kappa`, and `a`.
For use in `solve_T`, returns only `a_alpha` if full is False.
.. math::
a\alpha = a \left(\kappa \left(- \frac{T^{0.5}}{Tc^{0.5}}
+ 1\right) + 1\right)^{2}
\frac{d a\alpha}{dT} = - \frac{1.0 a \kappa}{T^{0.5} Tc^{0.5}}
\left(\kappa \left(- \frac{T^{0.5}}{Tc^{0.5}} + 1\right) + 1\right)
\frac{d^2 a\alpha}{dT^2} = 0.5 a \kappa \left(- \frac{1}{T^{1.5}
Tc^{0.5}} \left(\kappa \left(\frac{T^{0.5}}{Tc^{0.5}} - 1\right)
- 1\right) + \frac{\kappa}{T^{1.0} Tc^{1.0}}\right)
'''
if not full:
return self.a*(1 + self.kappa*(1-(T/self.Tc)**0.5))**2
else:
if quick:
Tc, kappa = self.Tc, self.kappa
x0 = T**0.5
| python | {
"resource": ""
} |
q255508 | PRSV.solve_T | validation | def solve_T(self, P, V, quick=True):
r'''Method to calculate `T` from a specified `P` and `V` for the PRSV
EOS. Uses `Tc`, `a`, `b`, `kappa0` and `kappa` as well, obtained from
the class's namespace.
Parameters
----------
P : float
Pressure, [Pa]
V : float
Molar volume, [m^3/mol]
quick : bool, optional
Whether to use a SymPy cse-derived expression (somewhat faster) or
individual formulas.
Returns
-------
T : float
Temperature, [K]
Notes
-----
Not guaranteed to produce a solution. There are actually two solution,
one much higher than normally desired; it is possible the solver could
converge on this.
'''
Tc, a, b, kappa0, kappa1 = self.Tc, self.a, self.b, self.kappa0, self.kappa1
if quick:
x0 = V - b
R_x0 = R/x0
x3 = (100.*(V*(V + b) + | python | {
"resource": ""
} |
q255509 | VDW.solve_T | validation | def solve_T(self, P, V):
r'''Method to calculate `T` from a specified `P` and `V` for the VDW
EOS. Uses `a`, and `b`, obtained from the class's namespace.
.. math::
T = \frac{1}{R V^{2}} \left(P V^{2} \left(V - b\right)
+ V a - a b\right)
Parameters
----------
P : float
Pressure, [Pa]
| python | {
"resource": ""
} |
q255510 | RK.solve_T | validation | def solve_T(self, P, V, quick=True):
r'''Method to calculate `T` from a specified `P` and `V` for the RK
EOS. Uses `a`, and `b`, obtained from the class's namespace.
Parameters
----------
P : float
Pressure, [Pa]
V : float
Molar volume, [m^3/mol]
quick : bool, optional
Whether to use a SymPy cse-derived expression (3x faster) or
individual formulas
Returns
-------
T : float
Temperature, [K]
Notes
-----
The exact solution can be derived as follows; it is excluded for
breviety.
>>> from sympy import *
>>> P, T, V, R = symbols('P, T, V, R')
>>> Tc, Pc = symbols('Tc, Pc')
>>> a, b = symbols('a, b')
>>> RK = Eq(P, R*T/(V-b) - a/sqrt(T)/(V*V + b*V))
>>> # solve(RK, T)
'''
a, b = self.a, self.b
if quick:
x1 = -1.j*1.7320508075688772 + 1.
x2 = | python | {
"resource": ""
} |
q255511 | APISRK.solve_T | validation | def solve_T(self, P, V, quick=True):
r'''Method to calculate `T` from a specified `P` and `V` for the API
SRK EOS. Uses `a`, `b`, and `Tc` obtained from the class's namespace.
Parameters
----------
P : float
Pressure, [Pa]
V : float
Molar volume, [m^3/mol]
quick : bool, optional
Whether to use a SymPy cse-derived expression (3x faster) or
individual formulas
Returns
-------
T : float
Temperature, [K]
Notes
-----
If S2 is set to 0, the solution is the same as in the SRK EOS, and that
is used. Otherwise, newton's method must be used to solve for `T`.
There are 8 roots of T in that case, six of them real. No guarantee can
be made regarding which root will be obtained.
'''
if self.S2 == 0:
self.m = self.S1
return SRK.solve_T(self, P, V, quick=quick)
else:
# Previously coded method is 63 microseconds vs 47 here
# | python | {
"resource": ""
} |
q255512 | TWUSRK.a_alpha_and_derivatives | validation | def a_alpha_and_derivatives(self, T, full=True, quick=True):
r'''Method to calculate `a_alpha` and its first and second
derivatives for this EOS. Returns `a_alpha`, `da_alpha_dT`, and
`d2a_alpha_dT2`. See `GCEOS.a_alpha_and_derivatives` for more
documentation. Uses the set values of `Tc`, `omega`, and `a`.
| python | {
"resource": ""
} |
q255513 | Tb | validation | def Tb(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[PSAT_DEFINITION]):
r'''This function handles the retrieval of a chemical's boiling
point. 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 'CRC Physical Constants, organic' for organic
chemicals, and 'CRC Physical Constants, inorganic' for inorganic
chemicals. Function has data for approximately 13000 chemicals.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Tb : float
Boiling temperature, [K]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Tb with the given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Tb_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Tb for the desired chemical, and will return methods instead of Tb
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 four methods are available for this function. They are:
* 'CRC_ORG', a compillation of data on organics
as published in [1]_.
* 'CRC_INORG', a compillation of data on
inorganic as published in [1]_.
* 'YAWS', a large compillation of data from a
variety of sources; no data points are sourced in the work of [2]_.
* 'PSAT_DEFINITION', calculation of boiling point from a
vapor pressure calculation. This is normally off by a fraction of a
degree even in the best cases. Listed in IgnoreMethods by default
for performance reasons.
Examples
--------
>>> Tb('7732-18-5')
373.124
References
----------
.. [1] Haynes, W.M., Thomas J. Bruno, and David R. Lide. CRC Handbook of
Chemistry and Physics, 95E. Boca Raton, FL: CRC press, 2014.
.. [2] Yaws, Carl L. Thermophysical Properties of Chemicals and
Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional
Publishing, 2014.
'''
def list_methods():
methods = []
if CASRN in CRC_inorganic_data.index and not np.isnan(CRC_inorganic_data.at[CASRN, 'Tb']):
methods.append(CRC_INORG)
| python | {
"resource": ""
} |
q255514 | Tm | validation | def Tm(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=[]):
r'''This function handles the retrieval of a chemical's melting
point. 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 'Open Notebook Melting Points', with backup sources
'CRC Physical Constants, organic' for organic chemicals, and
'CRC Physical Constants, inorganic' for inorganic chemicals. Function has
data for approximately 14000 chemicals.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Tm : float
Melting temperature, [K]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Tm with the given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Tm_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Tm for the desired chemical, and will return methods instead of Tm
IgnoreMethods : list, optional
A list of methods to ignore in obtaining the full list of methods
Notes
-----
A total of three sources are available for this function. They are:
* 'OPEN_NTBKM, a compillation of | python | {
"resource": ""
} |
q255515 | Clapeyron | validation | def Clapeyron(T, Tc, Pc, dZ=1, Psat=101325):
r'''Calculates enthalpy of vaporization at arbitrary temperatures using the
Clapeyron equation.
The enthalpy of vaporization is given by:
.. math::
\Delta H_{vap} = RT \Delta Z \frac{\ln (P_c/Psat)}{(1-T_{r})}
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
dZ : float
Change in compressibility factor between liquid and gas, []
Psat : float
Saturation pressure of fluid [Pa], optional
Returns
-------
Hvap : float
Enthalpy of vaporization, [J/mol]
Notes
-----
No original source is available for this equation.
[1]_ claims this equation overpredicts enthalpy by several percent. | python | {
"resource": ""
} |
q255516 | Watson | validation | def Watson(T, Hvap_ref, T_Ref, Tc, exponent=0.38):
'''
Adjusts enthalpy of vaporization of enthalpy for another temperature, for one temperature.
'''
Tr = T/Tc | python | {
"resource": ""
} |
q255517 | Hfus | validation | def Hfus(T=298.15, P=101325, MW=None, AvailableMethods=False, Method=None, CASRN=''): # pragma: no cover
'''This function handles the calculation of a chemical's enthalpy of fusion.
Generally this, is used by the chemical class, as all parameters are passed.
Calling the function directly works okay.
Enthalpy of fusion is a weak function of pressure, and its effects are
neglected.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
'''
def list_methods():
methods = []
if CASRN in CRCHfus_data.index:
methods.append('CRC, at melting point')
| python | {
"resource": ""
} |
q255518 | Hsub | validation | def Hsub(T=298.15, P=101325, MW=None, AvailableMethods=False, Method=None, CASRN=''): # pragma: no cover
'''This function handles the calculation of a chemical's enthalpy of sublimation.
Generally this, is used by the chemical class, as all parameters are passed.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
'''
def list_methods():
methods = []
# if Hfus(T=T, P=P, MW=MW, CASRN=CASRN) and Hvap(T=T, P=P, MW=MW, CASRN=CASRN):
# methods.append('Hfus + Hvap')
if CASRN in GharagheiziHsub_data.index:
methods.append('Ghazerati Appendix, at 298K')
methods.append('None')
return methods
if AvailableMethods:
return list_methods()
if not Method:
| python | {
"resource": ""
} |
q255519 | Tliquidus | validation | def Tliquidus(Tms=None, ws=None, xs=None, CASRNs=None, AvailableMethods=False,
Method=None): # pragma: no cover
'''This function handles the retrival of a mixtures's liquidus point.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> Tliquidus(Tms=[250.0, 350.0], xs=[0.5, 0.5])
350.0
>>> Tliquidus(Tms=[250, 350], xs=[0.5, 0.5], Method='Simple')
300.0
>>> Tliquidus(Tms=[250, 350], xs=[0.5, 0.5], AvailableMethods=True)
['Maximum', 'Simple', 'None']
'''
def list_methods():
methods = []
if none_and_length_check([Tms]):
methods.append('Maximum')
| python | {
"resource": ""
} |
q255520 | solubility_parameter | validation | def solubility_parameter(T=298.15, Hvapm=None, Vml=None,
CASRN='', AvailableMethods=False, Method=None):
r'''This function handles the calculation of a chemical's solubility
parameter. Calculation is a function of temperature, but is not always
presented as such. No lookup values are available; either `Hvapm`, `Vml`,
and `T` are provided or the calculation cannot be performed.
.. math::
\delta = \sqrt{\frac{\Delta H_{vap} - RT}{V_m}}
Parameters
----------
T : float
Temperature of the fluid [k]
Hvapm : float
Heat of vaporization [J/mol/K]
Vml : float
Specific volume of the liquid [m^3/mol]
CASRN : str, optional
CASRN of the fluid, not currently used [-]
Returns
-------
delta : float
Solubility parameter, [Pa^0.5]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain the solubility parameter
with the given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
solubility_parameter_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the solubility parameter for the desired chemical, and will return
methods instead of the solubility parameter
Notes
-----
Undefined past the critical point. For convenience, if Hvap is not defined,
an error is not raised; None is returned instead. Also for convenience,
if Hvapm is less than RT, None is returned to avoid taking the root of a
negative number.
| python | {
"resource": ""
} |
q255521 | solubility_eutectic | validation | def solubility_eutectic(T, Tm, Hm, Cpl=0, Cps=0, gamma=1):
r'''Returns the maximum solubility of a solute in a solvent.
.. math::
\ln x_i^L \gamma_i^L = \frac{\Delta H_{m,i}}{RT}\left(
1 - \frac{T}{T_{m,i}}\right) - \frac{\Delta C_{p,i}(T_{m,i}-T)}{RT}
+ \frac{\Delta C_{p,i}}{R}\ln\frac{T_m}{T}
\Delta C_{p,i} = C_{p,i}^L - C_{p,i}^S
Parameters
----------
T : float
Temperature of the system [K]
Tm : float
Melting temperature of the solute [K]
Hm : float
Heat of melting at the melting temperature of the solute [J/mol]
| python | {
"resource": ""
} |
q255522 | Tm_depression_eutectic | validation | def Tm_depression_eutectic(Tm, Hm, x=None, M=None, MW=None):
r'''Returns the freezing point depression caused by a solute in a solvent.
Can use either the mole fraction of the solute or its molality and the
molecular weight of the solvent. Assumes ideal system behavior.
.. math::
\Delta T_m = \frac{R T_m^2 x}{\Delta H_m}
\Delta T_m = \frac{R T_m^2 (MW) M}{1000 \Delta H_m}
Parameters
----------
Tm : float
Melting temperature of the solute [K]
Hm : float
Heat of melting at the melting temperature of the solute [J/mol]
x : float, optional
Mole fraction of the solute [-]
| python | {
"resource": ""
} |
q255523 | Rackett | validation | def Rackett(T, Tc, Pc, Zc):
r'''Calculates saturation liquid volume, using Rackett CSP method and
critical properties.
The molar volume of a liquid is given by:
.. math::
V_s = \frac{RT_c}{P_c}{Z_c}^{[1+(1-{T/T_c})^{2/7} ]}
Units are all currently in m^3/mol - this can be changed to kg/m^3
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
Pc : float
Critical pressure of fluid [Pa]
Zc : float
Critical compressibility of fluid, [-]
Returns
-------
Vs : float
Saturation liquid volume, [m^3/mol]
Notes
-----
Units are dependent on gas constant R, | python | {
"resource": ""
} |
q255524 | Yamada_Gunn | validation | def Yamada_Gunn(T, Tc, Pc, omega):
r'''Calculates saturation liquid volume, using Yamada and Gunn CSP method
and a chemical's critical properties and acentric factor.
The molar volume of a liquid is given by:
.. math::
V_s = \frac{RT_c}{P_c}{(0.29056-0.08775\omega)}^{[1+(1-{T/T_c})^{2/7}]}
Units are in m^3/mol.
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
-------
Vs : float
saturation liquid volume, [m^3/mol]
Notes
-----
This equation is an improvement on the Rackett equation.
This is often presented as the Rackett equation.
The acentric factor is used here, instead of the critical compressibility
A variant using a | python | {
"resource": ""
} |
q255525 | Townsend_Hales | validation | def Townsend_Hales(T, Tc, Vc, omega):
r'''Calculates saturation liquid density, using the Townsend and Hales
CSP method as modified from the original Riedel equation. Uses
chemical critical volume and temperature, as well as acentric factor
The density of a liquid is given by:
.. math::
Vs = V_c/\left(1+0.85(1-T_r)+(1.692+0.986\omega)(1-T_r)^{1/3}\right)
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
-------
Vs : float
Saturation liquid volume, [m^3/mol] | python | {
"resource": ""
} |
q255526 | COSTALD | validation | def COSTALD(T, Tc, Vc, omega):
r'''Calculate saturation liquid density using the COSTALD CSP method.
A popular and accurate estimation method. If possible, fit parameters are
used; alternatively critical properties work well.
The density of a liquid is given by:
.. math::
V_s=V^*V^{(0)}[1-\omega_{SRK}V^{(\delta)}]
V^{(0)}=1-1.52816(1-T_r)^{1/3}+1.43907(1-T_r)^{2/3}
- 0.81446(1-T_r)+0.190454(1-T_r)^{4/3}
V^{(\delta)}=\frac{-0.296123+0.386914T_r-0.0427258T_r^2-0.0480645T_r^3}
{T_r-1.00001}
Units are that of critical or fit constant volume.
Parameters
----------
T : float
Temperature of fluid [K]
Tc : float
Critical temperature of fluid [K]
Vc : float
Critical volume of fluid [m^3/mol].
This parameter is alternatively a fit parameter
omega : float
(ideally SRK) Acentric factor for fluid, [-]
This parameter is alternatively a fit parameter.
Returns
-------
Vs : float
Saturation liquid volume
Notes
-----
196 constants are fit to this function in [1]_.
Range: 0.25 < Tr < 0.95, often said to be to 1.0
This function has been checked with the API handbook example problem.
Examples | python | {
"resource": ""
} |
q255527 | Amgat | validation | def Amgat(xs, Vms):
r'''Calculate mixture liquid density using the Amgat mixing rule.
Highly inacurate, but easy to use. Assumes idea liquids with
no excess volume. Average molecular weight should be used with it to obtain
density.
.. math::
V_{mix} = \sum_i x_i V_i
or in terms of density:
.. math::
\rho_{mix} = \sum\frac{x_i}{\rho_i}
Parameters
----------
xs : array
Mole fractions of each component, []
Vms : array
Molar volumes of each fluids at conditions [m^3/mol]
Returns
-------
Vm : float
Mixture liquid volume [m^3/mol]
Notes | python | {
"resource": ""
} |
q255528 | COSTALD_mixture | validation | def COSTALD_mixture(xs, T, Tcs, Vcs, omegas):
r'''Calculate mixture liquid density using the COSTALD CSP method.
A popular and accurate estimation method. If possible, fit parameters are
used; alternatively critical properties work well.
The mixing rules giving parameters for the pure component COSTALD
equation are:
.. math::
T_{cm} = \frac{\sum_i\sum_j x_i x_j (V_{ij}T_{cij})}{V_m}
V_m = 0.25\left[ \sum x_i V_i + 3(\sum x_i V_i^{2/3})(\sum_i x_i V_i^{1/3})\right]
V_{ij}T_{cij} = (V_iT_{ci}V_{j}T_{cj})^{0.5}
\omega = \sum_i z_i \omega_i
Parameters
----------
xs: list
Mole fractions of each component
T : float
Temperature of fluid [K]
Tcs : list
Critical temperature of fluids [K]
Vcs : list
Critical volumes of fluids [m^3/mol].
This parameter is alternatively a fit parameter
omegas : list
(ideally SRK) Acentric factor of all fluids, [-]
This parameter is alternatively a fit parameter.
Returns
-------
Vs : float
Saturation liquid mixture volume
Notes
-----
Range: 0.25 < Tr < 0.95, often said to be to 1.0
No example has been found.
Units are that of critical or fit constant volume.
Examples
--------
>>> COSTALD_mixture([0.4576, 0.5424], 298., [512.58, 647.29],[0.000117, 5.6e-05], [0.559,0.344] )
2.706588773271354e-05 | python | {
"resource": ""
} |
q255529 | VolumeLiquid.calculate | validation | def calculate(self, T, method):
r'''Method to calculate low-pressure liquid molar volume 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 molar volume, [K]
method : str
Name of the method to use
Returns
-------
Vm : float
Molar volume of the liquid at T and a low pressure, [m^3/mol]
'''
if method == RACKETT:
Vm = Rackett(T, self.Tc, self.Pc, self.Zc)
elif method == YAMADA_GUNN:
Vm = Yamada_Gunn(T, self.Tc, self.Pc, self.omega)
elif method == BHIRUD_NORMAL:
Vm = Bhirud_normal(T, self.Tc, self.Pc, self.omega)
elif method == TOWNSEND_HALES:
Vm = Townsend_Hales(T, self.Tc, self.Vc, self.omega)
elif method == HTCOSTALD:
Vm = COSTALD(T, self.Tc, self.Vc, self.omega)
elif method == YEN_WOODS_SAT:
Vm = Yen_Woods_saturation(T, self.Tc, self.Vc, self.Zc)
elif method == MMSNM0:
Vm = SNM0(T, self.Tc, self.Vc, self.omega)
elif method == MMSNM0FIT:
Vm = SNM0(T, self.Tc, self.Vc, self.omega, self.SNM0_delta_SRK)
elif method == CAMPBELL_THODOS:
Vm = Campbell_Thodos(T, self.Tb, self.Tc, self.Pc, self.MW, self.dipole)
elif method == HTCOSTALDFIT:
| python | {
"resource": ""
} |
q255530 | VolumeLiquid.calculate_P | validation | def calculate_P(self, T, P, method):
r'''Method to calculate pressure-dependent liquid molar volume 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 molar volume, [K]
P : float
Pressure at which to calculate molar volume, [K]
method : str
| python | {
"resource": ""
} |
q255531 | VolumeLiquidMixture.calculate | validation | def calculate(self, T, P, zs, ws, method):
r'''Method to calculate molar volume 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
-------
Vm : float
Molar volume of the liquid mixture at the given conditions,
[m^3/mol]
'''
if method == SIMPLE:
Vms = [i(T, P) for i in self.VolumeLiquids]
return Amgat(zs, Vms)
elif method == COSTALD_MIXTURE:
| python | {
"resource": ""
} |
q255532 | VolumeGas.calculate_P | validation | def calculate_P(self, T, P, method):
r'''Method to calculate pressure-dependent gas molar volume 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 molar volume, [K]
P : float
Pressure at which to calculate molar volume, [K]
method : str
Name of the method to use
Returns
-------
Vm : float
Molar volume of the gas at T and P, [m^3/mol]
'''
if method == EOS:
self.eos[0] = self.eos[0].to_TP(T=T, P=P)
Vm = self.eos[0].V_g
elif method == TSONOPOULOS_EXTENDED:
B = BVirial_Tsonopoulos_extended(T, self.Tc, self.Pc, self.omega, dipole=self.dipole)
Vm = ideal_gas(T, P) + B
elif method == TSONOPOULOS:
B = BVirial_Tsonopoulos(T, self.Tc, self.Pc, self.omega)
Vm = ideal_gas(T, P) + B
elif method == ABBOTT:
B = BVirial_Abbott(T, self.Tc, self.Pc, self.omega)
Vm = ideal_gas(T, P) + | python | {
"resource": ""
} |
q255533 | VolumeGasMixture.calculate | validation | def calculate(self, T, P, zs, ws, method):
r'''Method to calculate molar volume of a gas 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
-------
Vm : float
Molar volume of the gas mixture at the given conditions, | python | {
"resource": ""
} |
q255534 | VolumeSolid.calculate | validation | def calculate(self, T, method):
r'''Method to calculate the molar volume of a solid 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 molar volume, [K]
method : str
Name of the method to use
Returns
-------
Vms : float
| python | {
"resource": ""
} |
q255535 | VolumeSolidMixture.calculate | validation | def calculate(self, T, P, zs, ws, method):
r'''Method to calculate molar volume of a solid 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 | python | {
"resource": ""
} |
q255536 | legal_status | validation | def legal_status(CASRN, Method=None, AvailableMethods=False, CASi=None):
r'''Looks up the legal status of a chemical according to either a specifc
method or with all methods.
Returns either the status as a string for a specified method, or the
status of the chemical in all available data sources, in the format
{source: status}.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
status : str or dict
Legal status information [-]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain legal status with the
given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
legal_status_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the legal status for the desired chemical, and will return methods
instead of the status
CASi : int, optional
CASRN as an integer, used internally [-]
Notes
-----
Supported methods are:
* **DSL**: Canada Domestic Substance List, [1]_. As extracted on Feb 11, 2015
from a html list. This list is updated continuously, so this version
will always be somewhat old. Strictly speaking, there are multiple
lists but they are all bundled together here. A chemical may be
'Listed', or be on the 'Non-Domestic Substances List (NDSL)',
or be on the list of substances with 'Significant New Activity (SNAc)',
or be on the DSL but with a 'Ministerial Condition pertaining to this
substance', or have been removed from the DSL, or have had a
Ministerial prohibition for the substance.
* **TSCA**: USA EPA Toxic Substances Control Act Chemical Inventory, [2]_.
This list is as extracted on 2016-01. It is believed this list is
updated on a periodic basis (> 6 month). A chemical may simply be
'Listed', or may have certain flags attached to it. All these flags
are described in the dict TSCA_flags.
* **EINECS**: European INventory of Existing Commercial chemical
Substances, [3]_. As extracted from a spreadsheet dynamically
generated at [1]_. This list was obtained March 2015; a more recent
revision already exists.
* **NLP**: No Longer Polymers, a list of chemicals with special
regulatory exemptions in EINECS. Also described at [3]_.
* **SPIN**: Substances Prepared in Nordic Countries. Also a boolean
data type. Retrieved 2015-03 from [4]_.
Other methods which could be added are:
* Australia: AICS Australian Inventory of Chemical Substances
* China: Inventory of Existing Chemical Substances Produced or Imported
in China (IECSC)
* Europe: REACH List of Registered Substances
* India: List of Hazardous Chemicals
* Japan: ENCS: Inventory of existing and new chemical substances
* Korea: Existing Chemicals Inventory (KECI)
* Mexico: INSQ National Inventory of Chemical Substances in Mexico
* New Zealand: | python | {
"resource": ""
} |
q255537 | economic_status | validation | def economic_status(CASRN, Method=None, AvailableMethods=False): # pragma: no cover
'''Look up the economic status of a chemical.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> pprint(economic_status(CASRN='98-00-0'))
["US public: {'Manufactured': 0.0, 'Imported': 10272.711, 'Exported': 184.127}",
u'10,000 - 100,000 tonnes per annum',
'OECD HPV Chemicals']
>>> economic_status(CASRN='13775-50-3') # SODIUM SESQUISULPHATE
[]
>>> economic_status(CASRN='98-00-0', Method='OECD high production volume chemicals')
'OECD HPV Chemicals'
>>> economic_status(CASRN='98-01-1', Method='European Chemicals Agency Total Tonnage Bands')
[u'10,000 - 100,000 tonnes per annum']
'''
load_economic_data()
CASi = CAS2int(CASRN)
def list_methods():
methods = []
methods.append('Combined')
if CASRN in _EPACDRDict:
methods.append(EPACDR)
if CASRN in _ECHATonnageDict:
methods.append(ECHA)
if CASi in HPV_data.index:
methods.append(OECD)
methods.append(NONE)
return methods
if AvailableMethods:
| python | {
"resource": ""
} |
q255538 | Joback.estimate | validation | def estimate(self):
'''Method to compute all available properties with the Joback method;
returns their results as a dict. For the tempearture dependent values
Cpig and mul, both the coefficients and objects to perform calculations
are returned.
'''
# Pre-generate the coefficients or they will not be returned
self.mul(300)
self.Cpig(300)
estimates = {'Tb': self.Tb(self.counts),
| python | {
"resource": ""
} |
q255539 | conductivity | validation | def conductivity(CASRN=None, AvailableMethods=False, Method=None, full_info=True):
r'''This function handles the retrieval of a chemical's conductivity.
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.
Function has data for approximately 100 chemicals.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
kappa : float
Electrical conductivity of the fluid, [S/m]
T : float, only returned if full_info == True
Temperature at which conductivity measurement was made
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain RI with the given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
conductivity_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
conductivity for the desired chemical, and will return methods instead
of conductivity
full_info : bool, optional
If True, function will return the temperature at which the conductivity
reading was made
Notes
-----
Only one source is available in this function. It is:
* 'LANGE_COND' which is from Lange's Handbook, Table 8.34 Electrical
Conductivity of Various Pure | python | {
"resource": ""
} |
q255540 | ionic_strength | validation | 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, | python | {
"resource": ""
} |
q255541 | ion_balance_proportional | validation | 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
| python | {
"resource": ""
} |
q255542 | Permittivity.calculate | validation | 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 | python | {
"resource": ""
} |
q255543 | SurfaceTensionMixture.calculate | validation | 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:
| python | {
"resource": ""
} |
q255544 | load_group_assignments_DDBST | validation | 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
| python | {
"resource": ""
} |
q255545 | dipole_moment | validation | 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 | python | {
"resource": ""
} |
q255546 | Pc | validation | 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.
| python | {
"resource": ""
} |
q255547 | Vc | validation | 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 | python | {
"resource": ""
} |
q255548 | Zc | validation | 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.
| python | {
"resource": ""
} |
q255549 | critical_surface | validation | 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):
| python | {
"resource": ""
} |
q255550 | third_property | validation | 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])
| python | {
"resource": ""
} |
q255551 | checkCAS | validation | 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
| python | {
"resource": ""
} |
q255552 | mixture_from_any | validation | 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 | python | {
"resource": ""
} |
q255553 | ChemicalMetadata.charge | validation | 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:
| python | {
"resource": ""
} |
q255554 | ChemicalMetadataDB.load_included_indentifiers | validation | 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() | python | {
"resource": ""
} |
q255555 | CoolProp_T_dependent_property | validation | 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/
'''
| python | {
"resource": ""
} |
q255556 | Stockmayer | validation | 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)
| python | {
"resource": ""
} |
q255557 | molecular_diameter | validation | 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)
| python | {
"resource": ""
} |
q255558 | Tstar | validation | 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 | python | {
"resource": ""
} |
q255559 | Hf_g | validation | 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
| python | {
"resource": ""
} |
q255560 | omega | validation | 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.
| python | {
"resource": ""
} |
q255561 | omega_mixture | validation | 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
| python | {
"resource": ""
} |
q255562 | StielPolar | validation | 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 | python | {
"resource": ""
} |
q255563 | ViswanathNatarajan2 | validation | 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 | python | {
"resource": ""
} |
q255564 | _round_whole_even | validation | 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, | python | {
"resource": ""
} |
q255565 | ViscosityLiquid.calculate | validation | 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 | python | {
"resource": ""
} |
q255566 | ViscosityLiquid.calculate_P | validation | 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]
| python | {
"resource": ""
} |
q255567 | ViscosityLiquidMixture.calculate | validation | 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:
| python | {
"resource": ""
} |
q255568 | ViscosityGas.calculate | validation | def calculate(self, T, method):
r'''Method to calculate low-pressure gas viscosity at
tempearture `T` with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperature of the gas, [K]
method : str
Name of the method to use
Returns
-------
mu : float
Viscosity of the gas at T and a low pressure, [Pa*S]
'''
if method == GHARAGHEIZI:
mu = Gharagheizi_gas_viscosity(T, self.Tc, self.Pc, self.MW)
elif method == COOLPROP:
mu = CoolProp_T_dependent_property(T, self.CASRN, 'V', 'g')
elif method == DIPPR_PERRY_8E:
| python | {
"resource": ""
} |
q255569 | ViscosityGas.calculate_P | validation | def calculate_P(self, T, P, method):
r'''Method to calculate pressure-dependent gas 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 gas viscosity, [K]
P : float
Pressure at which to calculate gas viscosity, [K]
method : str
Name of the method to use
| python | {
"resource": ""
} |
q255570 | ViscosityGasMixture.calculate | validation | def calculate(self, T, P, zs, ws, method):
r'''Method to calculate viscosity of a gas 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 gas mixture, [Pa*s]
'''
if method == SIMPLE:
mus = [i(T, P) for i in self.ViscosityGases]
| python | {
"resource": ""
} |
q255571 | TWA | validation | def TWA(CASRN, AvailableMethods=False, Method=None): # pragma: no cover
'''This function handles the retrieval of Time-Weighted Average limits on worker
exposure to dangerous chemicals.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> TWA('98-00-0')
(10.0, 'ppm')
>>> TWA('1303-00-0')
(5.0742430905659505e-05, 'ppm')
>>> TWA('7782-42-5', AvailableMethods=True)
['Ontario Limits', 'None']
'''
def list_methods():
methods = []
if CASRN in _OntarioExposureLimits and (_OntarioExposureLimits[CASRN]["TWA (ppm)"] or _OntarioExposureLimits[CASRN]["TWA (mg/m^3)"]):
methods.append(ONTARIO)
methods.append(NONE)
return methods
if AvailableMethods: | python | {
"resource": ""
} |
q255572 | STEL | validation | def STEL(CASRN, AvailableMethods=False, Method=None): # pragma: no cover
'''This function handles the retrieval of Short-term Exposure Limit on
worker exposure to dangerous chemicals.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> STEL('67-64-1')
(750.0, 'ppm')
>>> STEL('7664-38-2')
(0.7489774978301237, 'ppm')
>>> STEL('55720-99-5')
(2.0, 'mg/m^3')
>>> STEL('86290-81-5', AvailableMethods=True)
['Ontario Limits', 'None']
'''
def list_methods():
methods = []
if CASRN in _OntarioExposureLimits and (_OntarioExposureLimits[CASRN]["STEL (ppm)"] or _OntarioExposureLimits[CASRN]["STEL (mg/m^3)"]):
methods.append(ONTARIO)
methods.append(NONE)
return | python | {
"resource": ""
} |
q255573 | Ceiling | validation | def Ceiling(CASRN, AvailableMethods=False, Method=None): # pragma: no cover
'''This function handles the retrieval of Ceiling limits on worker
exposure to dangerous chemicals.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> Ceiling('75-07-0')
(25.0, 'ppm')
>>> Ceiling('1395-21-7')
(6e-05, 'mg/m^3')
>>> Ceiling('7572-29-4', AvailableMethods=True)
['Ontario Limits', 'None']
'''
def list_methods():
methods = []
if CASRN in _OntarioExposureLimits and (_OntarioExposureLimits[CASRN]["Ceiling (ppm)"] or _OntarioExposureLimits[CASRN]["Ceiling (mg/m^3)"]):
methods.append(ONTARIO)
methods.append(NONE)
return methods
if AvailableMethods:
| python | {
"resource": ""
} |
q255574 | Skin | validation | def Skin(CASRN, AvailableMethods=False, Method=None): # pragma: no cover
'''This function handles the retrieval of whether or not a chemical can
be absorbed through the skin, relevant to chemical safety calculations.
This API is considered experimental, and is expected to be removed in a
future release in favor of a more complete object-oriented interface.
>>> Skin('108-94-1')
True
>>> Skin('1395-21-7')
False
>>> Skin('7572-29-4', AvailableMethods=True)
['Ontario Limits', 'None']
'''
def list_methods():
methods = []
if CASRN in _OntarioExposureLimits:
methods.append(ONTARIO)
| python | {
"resource": ""
} |
q255575 | Carcinogen | validation | def Carcinogen(CASRN, AvailableMethods=False, Method=None):
r'''Looks up if a chemical is listed as a carcinogen or not according to
either a specifc method or with all methods.
Returns either the status as a string for a specified method, or the
status of the chemical in all available data sources, in the format
{source: status}.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
status : str or dict
Carcinogen status information [-]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain carcinogen status with the
given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Carcinogen_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
if a chemical is listed as carcinogenic, and will return methods
instead of the status
Notes
-----
Supported methods are:
* **IARC**: International Agency for Research on Cancer, [1]_. As
extracted with a last update of February 22, 2016. Has listing
information of 843 chemicals with CAS numbers. Chemicals without
CAS numbers not included here. If two listings for the same CAS
were available, that closest to the CAS number was used. If two
listings were available published at different times, the latest
value was used. All else equal, the most pessimistic value was used.
* **NTP**: National Toxicology Program, [2]_. Has data on 226
chemicals.
Examples
--------
>>> Carcinogen('61-82-5')
{'National Toxicology | python | {
"resource": ""
} |
q255576 | Tautoignition | validation | def Tautoignition(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval or calculation of a chemical's
autoifnition temperature. Lookup is based on CASRNs. No predictive methods
are currently implemented. Will automatically select a data source to use
if no Method is provided; returns None if the data is not available.
Prefered source is 'IEC 60079-20-1 (2010)' [1]_, with the secondary source
'NFPA 497 (2008)' [2]_ having very similar data.
Examples
--------
>>> Tautoignition(CASRN='71-43-2')
771.15
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Tautoignition : float
Autoignition point of the chemical, [K]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Tautoignition with the
given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Tautoignition_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
Tautoignition for the desired chemical, and will return methods
instead of Tautoignition
Notes
-----
References
----------
.. [1] IEC. “IEC 60079-20-1:2010 Explosive atmospheres - Part 20-1:
Material characteristics for gas and vapour classification - Test
methods and data.” https://webstore.iec.ch/publication/635. See also
https://law.resource.org/pub/in/bis/S05/is.iec.60079.20.1.2010.pdf
.. | python | {
"resource": ""
} |
q255577 | LFL | validation | def LFL(Hc=None, atoms={}, CASRN='', AvailableMethods=False, Method=None):
r'''This function handles the retrieval or calculation of a chemical's
Lower Flammability Limit. Lookup is based on CASRNs. Two predictive methods
are currently implemented. Will automatically select a data source to use
if no Method is provided; returns None if the data is not available.
Prefered source is 'IEC 60079-20-1 (2010)' [1]_, with the secondary source
'NFPA 497 (2008)' [2]_ having very similar data. If the heat of combustion
is provided, the estimation method `Suzuki_LFL` can be used. If the atoms
of the molecule are available, the method `Crowl_Louvar_LFL` can be used.
Examples
--------
>>> LFL(CASRN='71-43-2')
0.012
Parameters
----------
Hc : float, optional
Heat of combustion of gas [J/mol]
atoms : dict, optional
Dictionary of atoms and atom counts
CASRN : string, optional
CASRN [-]
Returns
-------
LFL : float
Lower flammability limit of the gas in an atmosphere at STP, [mole fraction]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain LFL with the
given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
LFL_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the Lower Flammability Limit for the desired chemical, and will return
methods instead of Lower Flammability Limit.
Notes
-----
References
----------
.. [1] IEC. “IEC 60079-20-1:2010 Explosive atmospheres - Part 20-1: | python | {
"resource": ""
} |
q255578 | UFL | validation | def UFL(Hc=None, atoms={}, CASRN='', AvailableMethods=False, Method=None):
r'''This function handles the retrieval or calculation of a chemical's
Upper Flammability Limit. Lookup is based on CASRNs. Two predictive methods
are currently implemented. Will automatically select a data source to use
if no Method is provided; returns None if the data is not available.
Prefered source is 'IEC 60079-20-1 (2010)' [1]_, with the secondary source
'NFPA 497 (2008)' [2]_ having very similar data. If the heat of combustion
is provided, the estimation method `Suzuki_UFL` can be used. If the atoms
of the molecule are available, the method `Crowl_Louvar_UFL` can be used.
Examples
--------
>>> UFL(CASRN='71-43-2')
0.086
Parameters
----------
Hc : float, optional
Heat of combustion of gas [J/mol]
atoms : dict, optional
Dictionary of atoms and atom counts
CASRN : string, optional
CASRN [-]
Returns
-------
UFL : float
Upper flammability limit of the gas in an atmosphere at STP, [mole fraction]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain UFL with the
given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
UFL_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the Upper Flammability Limit for the desired chemical, and will return
methods instead of Upper Flammability Limit.
Notes
-----
References
----------
.. [1] IEC. “IEC 60079-20-1:2010 Explosive atmospheres - Part 20-1: | python | {
"resource": ""
} |
q255579 | Mixture.atom_fractions | validation | def atom_fractions(self):
r'''Dictionary of atomic fractions for each atom in the mixture.
Examples
--------
>>> Mixture(['CO2', 'O2'], zs=[0.5, 0.5]).atom_fractions
{'C': 0.2, 'O': 0.8}
'''
things = dict()
for zi, atoms in zip(self.zs, self.atomss):
for atom, count in atoms.iteritems():
if atom in things:
| python | {
"resource": ""
} |
q255580 | Mixture.mass_fractions | validation | def mass_fractions(self):
r'''Dictionary of mass fractions for each atom in the mixture.
Examples
--------
>>> Mixture(['CO2', 'O2'], zs=[0.5, 0.5]).mass_fractions
{'C': 0.15801826905745822, 'O': 0.8419817309425419}
| python | {
"resource": ""
} |
q255581 | Mixture.draw_2d | validation | def draw_2d(self, Hs=False): # pragma: no cover
r'''Interface for drawing a 2D image of all the molecules in the
mixture. Requires an HTML5 browser, and the libraries RDKit and
IPython. An exception is raised if either of these libraries is
absent.
Parameters
----------
Hs : bool
Whether or not to show hydrogen
Examples
--------
Mixture(['natural gas']).draw_2d()
'''
try:
| python | {
"resource": ""
} |
q255582 | Tt | validation | def Tt(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval of a chemical's triple temperature.
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.
Returns data from [1]_, or a chemical's melting point if available.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Tt : float
Triple point temperature, [K]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Tt with the
given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Tt_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the Tt for the desired chemical, and will return methods
instead of the Tt
Notes
-----
Median difference between melting points and triple points is 0.02 K.
Accordingly, this should be more than good enough for engineering
applications.
Temperatures are on the ITS-68 scale.
Examples
--------
Ammonia
>>> Tt('7664-41-7')
195.47999999999999
References
----------
.. [1] Staveley, L. A. K., L. Q. | python | {
"resource": ""
} |
q255583 | Pt | validation | def Pt(CASRN, AvailableMethods=False, Method=None):
r'''This function handles the retrieval of a chemical's triple 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.
Returns data from [1]_, or attempts to calculate the vapor pressure at the
triple temperature, if data is available.
Parameters
----------
CASRN : string
CASRN [-]
Returns
-------
Pt : float
Triple point pressure, [Pa]
methods : list, only returned if AvailableMethods == True
List of methods which can be used to obtain Pt with the
given inputs
Other Parameters
----------------
Method : string, optional
A string for the method name to use, as defined by constants in
Pt_methods
AvailableMethods : bool, optional
If True, function will determine which methods can be used to obtain
the Pt for the desired chemical, and will return methods
instead of the Pt
Notes
-----
Examples
--------
Ammonia
>>> Pt('7664-41-7')
6079.5
References
----------
.. [1] Staveley, L. A. K., L. Q. Lobo, and J. C. G. Calado. "Triple-Points
of Low Melting Substances and Their Use in Cryogenic Work." Cryogenics
| python | {
"resource": ""
} |
q255584 | Parachor | validation | def Parachor(MW, rhol, rhog, sigma):
r'''Calculate Parachor for a pure species, using its density in the
liquid and gas phases, surface tension, and molecular weight.
.. math::
P = \frac{\sigma^{0.25} MW}{\rho_L - \rho_V}
Parameters
----------
MW : float
Molecular weight, [g/mol]
rhol : float
Liquid density [kg/m^3]
rhog : float
Gas density [kg/m^3]
sigma : float
Surface tension, [N/m]
Returns
-------
P : float
Parachor, [N^0.25*m^2.75/mol]
Notes
-----
To convert the output of this function to units of [mN^0.25*m^2.75/kmol],
multiply by 5623.4132519.
Values in group contribution tables for Parachor are often listed as
dimensionless, in | python | {
"resource": ""
} |
q255585 | Joule_Thomson | validation | def Joule_Thomson(T, V, Cp, dV_dT=None, beta=None):
r'''Calculate a real fluid's Joule Thomson coefficient. The required
derivative should be calculated with an equation of state, and `Cp` is the
real fluid versions. This can either be calculated with `dV_dT` directly,
or with `beta` if it is already known.
.. math::
\mu_{JT} = \left(\frac{\partial T}{\partial P}\right)_H = \frac{1}{C_p}
\left[T \left(\frac{\partial V}{\partial T}\right)_P - V\right]
= \frac{V}{C_p}\left(\beta T-1\right)
Parameters
----------
T : float
Temperature of fluid, [K]
V : float
Molar volume of fluid, [m^3/mol]
Cp : float
Real fluid heat capacity at constant pressure, [J/mol/K]
dV_dT : float, optional
Derivative of `V` with respect to `T`, [m^3/mol/K]
beta : float, optional
Isobaric coefficient of a thermal expansion, [1/K]
Returns
-------
mu_JT : float
Joule-Thomson coefficient [K/Pa]
Examples
--------
Example from [2]_:
>>> Joule_Thomson(T=390, V=0.00229754, Cp=153.235, dV_dT=1.226396e-05)
| python | {
"resource": ""
} |
q255586 | Z_from_virial_pressure_form | validation | def Z_from_virial_pressure_form(P, *args):
r'''Calculates the compressibility factor of a gas given its pressure, and
pressure-form virial coefficients. Any number of coefficients is supported.
.. math::
Z = \frac{Pv}{RT} = 1 + B'P + C'P^2 + D'P^3 + E'P^4 \dots
Parameters
----------
P : float
Pressure, [Pa]
B to Z : float, optional
Pressure form Virial coefficients, [various]
Returns
-------
Z : float
Compressibility factor at P, and with given virial coefficients, [-]
Notes
-----
Note that although this function does not require a temperature input, it
is still dependent on it because the coefficients themselves normally are
regressed | python | {
"resource": ""
} |
q255587 | zs_to_ws | validation | def zs_to_ws(zs, MWs):
r'''Converts a list of mole fractions to mass fractions. Requires molecular
weights for all species.
.. math::
w_i = \frac{z_i MW_i}{MW_{avg}}
MW_{avg} = \sum_i z_i MW_i
Parameters
----------
zs : iterable
Mole fractions [-]
MWs : iterable
Molecular weights [g/mol]
Returns
-------
ws : iterable
Mass fractions [-]
Notes
-----
Does not check that the sums add to one. Does not check that inputs are of
| python | {
"resource": ""
} |
q255588 | zs_to_Vfs | validation | def zs_to_Vfs(zs, Vms):
r'''Converts a list of mole fractions to volume fractions. Requires molar
volumes for all species.
.. math::
\text{Vf}_i = \frac{z_i V_{m,i}}{\sum_i z_i V_{m,i}}
Parameters
----------
zs : iterable
Mole fractions [-]
VMs : iterable
Molar volumes of species [m^3/mol]
Returns
-------
Vfs : list
Molar volume fractions [-]
Notes
-----
Does not check that the sums add to one. Does not check that inputs are of
the same length.
Molar volumes are specified in terms of pure components only. Function
| python | {
"resource": ""
} |
q255589 | none_and_length_check | validation | def none_and_length_check(all_inputs, length=None):
r'''Checks inputs for suitability of use by a mixing rule which requires
all inputs to be of the same length and non-None. A number of variations
were attempted for this function; this was found to be the quickest.
Parameters
----------
all_inputs : array-like of array-like
list of all the lists of inputs, [-]
length : int, optional
Length of the desired inputs, [-]
Returns
-------
False/True : bool
Returns True only if all inputs are the same length (or length `length`)
and none of the inputs | python | {
"resource": ""
} |
q255590 | mixing_simple | validation | def mixing_simple(fracs, props):
r'''Simple function calculates a property based on weighted averages of
properties. Weights could be mole fractions, volume fractions, mass
fractions, or anything else.
.. math::
y = \sum_i \text{frac}_i \cdot \text{prop}_i
Parameters
----------
fracs : array-like
Fractions of a mixture
props: array-like
Properties
Returns
-------
prop : value
Calculated property
Notes
-----
Returns None if any fractions or properties are missing | python | {
"resource": ""
} |
q255591 | mixing_logarithmic | validation | def mixing_logarithmic(fracs, props):
r'''Simple function calculates a property based on weighted averages of
logarithmic properties.
.. math::
y = \sum_i \text{frac}_i \cdot \log(\text{prop}_i)
Parameters
----------
fracs : array-like
Fractions of a mixture
props: array-like
Properties
Returns
-------
prop : value
Calculated property
Notes
-----
Does not work on negative values.
Returns None if any fractions or properties are missing or are not of the
| python | {
"resource": ""
} |
q255592 | phase_select_property | validation | def phase_select_property(phase=None, s=None, l=None, g=None, V_over_F=None):
r'''Determines which phase's property should be set as a default, given
the phase a chemical is, and the property values of various phases. For the
case of liquid-gas phase, returns None. If the property is not available
for the current phase, or if the current phase is not known, returns None.
Parameters
----------
phase : str
One of {'s', 'l', 'g', 'two-phase'}
s : float
Solid-phase property
l : float
Liquid-phase property
g : float
Gas-phase property
V_over_F : float
Vapor phase fraction
Returns
-------
prop : float
The selected/calculated | python | {
"resource": ""
} |
q255593 | TDependentProperty.set_user_methods | validation | def set_user_methods(self, user_methods, forced=False):
r'''Method used to select certain property methods as having a higher
priority than were set by default. If `forced` is true, then methods
which were not specified are excluded from consideration.
As a side effect, `method` is removed to ensure than the new methods
will be used in calculations afterwards.
An exception is raised if any of the methods specified aren't available
for the chemical. An exception is raised if no methods are provided.
Parameters
----------
user_methods : str or list
Methods by name to be considered or prefered
forced : bool, optional
If True, only the user specified methods will ever be considered;
if False other methods will be considered if no user methods
suceed
'''
# Accept either a string or a list of methods, and whether
# or not to only consider the false methods
if isinstance(user_methods, str):
user_methods = [user_methods]
# The user's order matters and | python | {
"resource": ""
} |
q255594 | TDependentProperty.select_valid_methods | validation | def select_valid_methods(self, T):
r'''Method to obtain a sorted list of methods which are valid at `T`
according to `test_method_validity`. Considers either only user methods
if forced is True, or all methods. User methods are first tested
according to their listed order, and unless forced is True, then all
methods are tested and sorted by their order in `ranked_methods`.
Parameters
----------
T : float
Temperature at which to test methods, [K]
Returns
-------
sorted_valid_methods : list
Sorted lists of methods valid at T according to
`test_method_validity`
'''
# Consider either only the user's methods or all methods
# Tabular data will be in both when inserted
if self.forced:
considered_methods = list(self.user_methods)
else:
considered_methods = list(self.all_methods)
# User methods (incl. tabular data); add back later, after ranking the rest
if self.user_methods:
[considered_methods.remove(i) for i in self.user_methods]
# Index the rest of the methods by ranked_methods, and add them to a | python | {
"resource": ""
} |
q255595 | TDependentProperty.solve_prop | validation | def solve_prop(self, goal, reset_method=True):
r'''Method to solve for the temperature at which a property is at a
specified value. `T_dependent_property` is used to calculate the value
of the property as a function of temperature; if `reset_method` is True,
the best method is used at each temperature as the solver seeks a
solution. This slows the solution moderately.
Checks the given property value with `test_property_validity` first
and raises an exception if it is not valid. Requires that Tmin and
Tmax have been set to know what range to search within.
Search is performed with the brenth solver from SciPy.
Parameters
----------
goal : float
Propoerty value desired, [`units`]
reset_method : bool
Whether or not to reset the method as the solver searches
Returns
-------
T : float
Temperature at which the property is the specified value [K]
'''
if self.Tmin is None or | python | {
"resource": ""
} |
q255596 | TDependentProperty.T_dependent_property_derivative | validation | def T_dependent_property_derivative(self, T, order=1):
r'''Method to obtain a derivative of a property with respect to
temperature, of a given order. Methods found valid by
`select_valid_methods` are attempted until a method succeeds. If no
methods are valid and succeed, None is returned.
Calls `calculate_derivative` internally to perform the actual
calculation.
.. math::
\text{derivative} = \frac{d (\text{property})}{d T}
Parameters
----------
T : float
Temperature at which to calculate the derivative, [K]
order : int
Order of the derivative, >= 1
Returns
-------
derivative : float
Calculated derivative property, [`units/K^order`]
'''
if self.method:
# retest within range
| python | {
"resource": ""
} |
q255597 | TDependentProperty.calculate_integral | validation | def calculate_integral(self, T1, T2, method):
r'''Method to calculate the integral of a property with respect to
temperature, using a specified method. Uses SciPy's `quad` function
to perform the integral, with no options.
This method can be overwritten by subclasses who may perfer to add
analytical methods for some or all methods as this is much faster.
If the calculation does not succeed, returns the actual error
encountered.
Parameters
----------
T1 : float
| python | {
"resource": ""
} |
q255598 | TDependentProperty.T_dependent_property_integral | validation | def T_dependent_property_integral(self, T1, T2):
r'''Method to calculate the integral of a property with respect to
temperature, using a specified method. Methods found valid by
`select_valid_methods` are attempted until a method succeeds. If no
methods are valid and succeed, None is returned.
Calls `calculate_integral` internally to perform the actual
calculation.
.. math::
\text{integral} = \int_{T_1}^{T_2} \text{property} \; dT
Parameters
----------
T1 : float
Lower limit of integration, [K]
T2 : float
Upper limit of integration, [K]
method : str
Method for which to find the integral
Returns
-------
integral : float
Calculated integral of the property over the given range,
[`units*K`]
'''
Tavg = 0.5*(T1+T2) | python | {
"resource": ""
} |
q255599 | TDependentProperty.calculate_integral_over_T | validation | def calculate_integral_over_T(self, T1, T2, method):
r'''Method to calculate the integral of a property over temperature
with respect to temperature, using a specified method. Uses SciPy's
`quad` function to perform the integral, with no options.
This method can be overwritten by subclasses who may perfer to add
analytical methods for some or all methods as this is much faster.
If the calculation does not succeed, returns the actual error
encountered.
Parameters
----------
T1 : float
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.