Thermo: Thermodynamics and Phase Equilibrium component of Chemical Engineering Design Library (ChEDL)¶
Contents:
Introduction to Cubic Equations of State¶
Cubic equations of state provide thermodynamically-consistent and relatively fast models for pure chemicals and mixtures. They are normally used to represent gases and liquids.
The generic three-parameter form is as follows:
\[P=\frac{RT}{V-b}-\frac{a\alpha(T)}{V^2 + \delta V + \epsilon} \]
This forms the basis of the implementation in thermo.
Two separate interfaces are provided, thermo.eos
for pure component modeling and thermo.eos_mix
for multicomponent modeling. Pure components are quite a bit faster than multicomponent mixtures, because the Van der Waals mixing rules conventionally used take N^2 operations to compute \(\alpha(T)\):
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
The other slow parts which applies to both types are calculating some basic properties (the list is at set_properties_from_solution
) that other properties may depend on, and calculating the molar volume given a pair of (T, P) inputs (an entire submodule thermo.eos_volume
discusses and implements this topic). Both of those calculations are constant-time, so their overhead is the same for pure components and multicomponent mixtures.
Working With Pure Components¶
We can use the GCEOS
(short for “General Cubic Equation Of State”) interface with any component or implemented equation of state, but for simplicity n-hexane is used with the Peng-Robinson EOS. Its critical temperature is 507.6 K, critical pressure 3.025 MPa, and acentric factor is 0.2975.
The state must be specified along with the critical constants when initializing a GCEOS
object; we use 400 K and 1e6 Pa here:
>>> from thermo import *
>>> eos = PR(Tc=507.6, Pc=3025000.0, omega=0.2975, T=400., P=1E6)
>>> eos
PR(Tc=507.6, Pc=3025000.0, omega=0.2975, T=400.0, P=1000000.0)
The __repr__
string is designed to show all the inputs to the object.
We can check the volume solutions with the raw_volumes
attribute:
>>> eos.raw_volumes
(0.0001560731847856, 0.002141876816741, 0.000919295474982)
At this point there are three real volume, so there is a liquid-like and a vapor-like solution available. The phase
attribute will have the value of ‘l/g’ in this state; otherwise it will be ‘l’ or ‘g’.
>>> eos.phase
'l/g'
The basic properties calculated at initialization are directly attributes, and can be accessed as such. Liquid-like properties have “_l” at the end of their name, and “_g” is at the end of gas-like properties.
>>> eos.H_dep_l
-26111.877
>>> eos.S_dep_g
-6.4394518
>>> eos.dP_dT_l
288501.633
All calculations in thermo.eos
and thermo.eos_mix
are on a molar basis; molecular weight is never provided or needed. All outputs are in base SI units (K, Pa, m^3, mole, etc). This simplified development substantially. For working with mass-based units, use the Phase
interface. The thermo.eos
and thermo.eos_mix
interfaces were developed prior to the Phase
interface and does have some features not exposed in the Phase
interface however.
Other properties are either implemented as methods that require arguments, or Python properties which act just like attributes but calculate the results on the fly. For example, the liquid-phase fugacity fugacity_l
or the gas isobaric (constant-pressure) expansion coefficient are properties.
>>> eos.fugacity_l
421597.00785
>>> eos.beta_g
0.0101232239
There are an awful lot of these properties, because many of them are derivatives subject to similar conditions. A full list is in the documentation for GCEOS
. There are fewer calls that take temperature, such as Hvap
which calculates the heat of vaporization of the object at a specified temperature:
>>> eos.Hvap(300)
31086.2
Once an object has been created, it can be used to instantiate new GCEOS
objects at different conditions, without re-specifying the critical constants and other parameters that may be needed.
>>> eos.to(T=300.0, P=1e5)
PR(Tc=507.6, Pc=3025000.0, omega=0.2975, T=300.0, P=100000.0)
>>> eos.to(V=1e2, P=1e5)
PR(Tc=507.6, Pc=3025000.0, omega=0.2975, P=100000.0, V=100.0)
>>> eos.to(V=1e2, T=300)
PR(Tc=507.6, Pc=3025000.0, omega=0.2975, T=300, V=100.0)
As was seen in the examples above, any two of T, P, V can be used to specify the state of the object. The input variables of the object are stored and can be checked with state_specs
:
>>> eos.state_specs
{'T': 400.0, 'P': 1000000.0}
The individual parts of the generic cubic equation are stored as well. We can use them to check that the pressure equation is satisfied:
>>> from thermo.eos import R
>>> R*eos.T/(eos.V_l-eos.b) - eos.a_alpha/(eos.V_l**2 + eos.V_l*eos.delta + eos.epsilon)
1000000.000000
>>> R*eos.T/(eos.V_g-eos.b) - eos.a_alpha/(eos.V_g**2 + eos.V_g*eos.delta + eos.epsilon)
1000000.000000
Note that as floating points are not perfectly precise, some small error may be shown but great care has been taken to minimize this.
The value of the gas constant used is 8.31446261815324 J/(mol*K). This is near the full precision of floating point numbers, but not quite. It is now an exact value used as a “definition” in the SI system. Note that other implementations of equations of state may not use the full value of the gas constant, but the author strongly recommends anyone considering writing their own EOS implementation use the full gas constant. This will allow more interchangeable results.
Pure Component Equilibrium¶
Continuing with the same state and example as before, there were two solutions available from the equation of state. However, unless the exact temperature 400 K and pressure 1 MPa happens to be on the saturation line, there is always one more thermodynamically stable state. We need to use the departure Gibbs free energy to determine which state is more stable. For a pure component, the state which minimizes departure Gibbs free energy is the most stable state.
>>> eos = PR(Tc=507.6, Pc=3025000.0, omega=0.2975, T=400., P=1E6)
>>> eos.G_dep_l, eos.G_dep_g
(-2872.498434, -973.5198207)
It is easy to see the liquid phase is more stable. This shortcut of using departure Gibbs free energy is valid only for pure components with all phases using the ideal-gas reference state. The full criterial is whichever state minimizes the actual Gibbs free energy.
The method more_stable_phase
does this check and returns either ‘l’ or ‘g’:
>>> eos.more_stable_phase
'l'
For a pure component, there is a vapor-liquid equilibrium line right up to the critical point which defines the vapor pressure of the fluid. This can be calculated using the Psat
method:
>>> eos.Psat(400.0)
466205.073739
The result is accurate to more than 10 digits, and is implemented using some fancy mathematical techniques that allow a direct calculation of the vapor pressure. A few more digits can be obtained by setting polish to True, which polishes the result with a newton solver to as much accuracy as a floating point number can provide:
>>> 1-eos.Psat(400, polish=True)/eos.Psat(400)
1.6e-14
A few more methods of interest are V_l_sat
and V_g_sat
which calculate the saturation liquid and molar volumes; Tsat
which calculates the saturation temperature given a specified pressure, and phi_sat
which computes the saturation fugacity coefficient given a temperature.
>>> eos.V_l_sat(298.15), eos.V_g_sat(500)
(0.0001303559, 0.0006827569)
>>> eos.Tsat(101325.0)
341.76265
>>> eos.phi_sat(425.0)
0.8349716
Working With Mixtures¶
Using mixture from thermo.eos_mix
is first illustrated using an equimolar mixture of nitrogen-methane at 115 K and 1 MPa and the Peng-Robinson equation of state:
>>> eos = PRMIX(T=115.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.5, 0.5], kijs=[[0.0, 0.0289], [0.0289, 0.0]])
>>> eos.V_l, eos.V_g
(3.658707770e-05, 0.00070676607)
>>> eos.fugacities_l, eos.fugacities_g
([838516.99, 78350.27], [438108.61, 359993.48])
All of the properties available in GCEOS
are also available for GCEOSMIX
objects.
New GCEOSMIX
objects can be created with the to
method, which accepts new mole fractions zs as well as new state variables. If a new composition zs is not provided, the current composition is also used for the new object.
>>> eos.to(T=300.0, P=1e5)
PRMIX(Tcs=[126.1, 190.6], Pcs=[3394000.0, 4604000.0], omegas=[0.04, 0.011], kijs=[[0.0, 0.0289], [0.0289, 0.0]], zs=[0.5, 0.5], T=300.0, P=100000.0)
>>> eos.to(T=300.0, P=1e5, zs=[.1, .9])
PRMIX(Tcs=[126.1, 190.6], Pcs=[3394000.0, 4604000.0], omegas=[0.04, 0.011], kijs=[[0.0, 0.0289], [0.0289, 0.0]], zs=[0.1, 0.9], T=300.0, P=100000.0)
>>> eos.to(V=1, P=1e5, zs=[.4, .6])
PRMIX(Tcs=[126.1, 190.6], Pcs=[3394000.0, 4604000.0], omegas=[0.04, 0.011], kijs=[[0.0, 0.0289], [0.0289, 0.0]], zs=[0.4, 0.6], P=100000.0, V=1)
>>> eos.to(V=1.0, T=300.0, zs=[.4, .6])
PRMIX(Tcs=[126.1, 190.6], Pcs=[3394000.0, 4604000.0], omegas=[0.04, 0.011], kijs=[[0.0, 0.0289], [0.0289, 0.0]], zs=[0.4, 0.6], T=300.0, V=1.0)
It is possible to create new GCEOSMIX
objects with the subset
method which uses only some of the initially specified components:
>>> kijs = [[0.0, 0.00076, 0.00171], [0.00076, 0.0, 0.00061], [0.00171, 0.00061, 0.0]]
>>> PR3 = PRMIX(Tcs=[469.7, 507.4, 540.3], zs=[0.8168, 0.1501, 0.0331], omegas=[0.249, 0.305, 0.349], Pcs=[3.369E6, 3.012E6, 2.736E6], T=322.29, P=101325.0, kijs=kijs)
>>> PR3.subset([1,2])
PRMIX(Tcs=[507.4, 540.3], Pcs=[3012000.0, 2736000.0], omegas=[0.305, 0.349], kijs=[[0.0, 0.00061], [0.00061, 0.0]], zs=[0.8193231441048, 0.1806768558951], T=322.29, P=101325.0)
>>> PR3.subset([1,2], T=500.0, P=1e5, zs=[.2, .8])
PRMIX(Tcs=[507.4, 540.3], Pcs=[3012000.0, 2736000.0], omegas=[0.305, 0.349], kijs=[[0.0, 0.00061], [0.00061, 0.0]], zs=[0.2, 0.8], T=500.0, P=100000.0)
>>> PR3.subset([1,2], zs=[.2, .8])
PRMIX(Tcs=[507.4, 540.3], Pcs=[3012000.0, 2736000.0], omegas=[0.305, 0.349], kijs=[[0.0, 0.00061], [0.00061, 0.0]], zs=[0.2, 0.8], T=322.29, P=101325.0)
It is also possible to create pure GCEOS
objects:
>>> PR3.pures()
[PR(Tc=469.7, Pc=3369000.0, omega=0.249, T=322.29, P=101325.0), PR(Tc=507.4, Pc=3012000.0, omega=0.305, T=322.29, P=101325.0), PR(Tc=540.3, Pc=2736000.0, omega=0.349, T=322.29, P=101325.0)]
Temperature, pressure, mole number, and mole fraction derivatives of the log fugacity coefficients are available as well with the methods dlnphis_dT
, dlnphis_dP
, dlnphis_dns
, and dlnphis_dzs
:
>>> PR3.dlnphis_dT('l')
[0.029486952019, 0.03514175794, 0.040281845273]
>>> PR3.dlnphis_dP('l')
[-9.8253779e-06, -9.8189093031e-06, -9.8122598e-06]
>>> PR3.dlnphis_dns(PR3.Z_l)
[[-0.0010590517, 0.004153228837, 0.007300114797], [0.0041532288, -0.016918292791, -0.0257680231], [0.0073001147, -0.02576802316, -0.0632916462]]
>>> PR3.dlnphis_dzs(PR3.Z_l)
[[0.0099380692, 0.0151503498, 0.0182972357], [-0.038517738, -0.059589260, -0.068438990], [-0.070571069, -0.103639207, -0.141162830]]
Other features¶
Hashing¶
It is possible to compare the two objects with each other to see if they have the same kijs, model parameters, and components by using the model_hash
method:
>>> PR_case = PRMIX(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.5, 0.5], kijs=[[0,0.41],[0.41,0]])
>>> SRK_case = SRKMIX(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.5, 0.5], kijs=[[0,0.41],[0.41,0]])
>>> PR_case.model_hash() == SRK_case.model_hash()
False
It is possible to see if both the exact state and the model match between two different objects by using the state_hash
method:
>>> PR_case2 = PRMIX(T=116, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.5, 0.5], kijs=[[0,0.41],[0.41,0]])
>>> PR_case.model_hash() == PR_case2.model_hash()
True
>>> PR_case.state_hash() == PR_case2.state_hash()
False
And finally it is possible to see if two objects are exactly identical, including cached calculation results, by using the __hash__
method:
>>> PR_case3 = PRMIX(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.5, 0.5], kijs=[[0,0.41],[0.41,0]])
>>> PR_case.state_hash() == PR_case3.state_hash()
True
>>> hash(PR_case) == hash(PR_case3)
True
>>> _ = PR_case.da_alpha_dT_ijs
>>> hash(PR_case) == hash(PR_case3)
False
Serialization¶
All cubic EOS models offer a as_json
method and a from_json
to serialize the object state for transport over a network, storing to disk, and passing data between processes.
>>> import json
>>> eos = PRSV2MIX(Tcs=[507.6], Pcs=[3025000], omegas=[0.2975], zs=[1], T=299., P=1E6, kappa1s=[0.05104], kappa2s=[0.8634], kappa3s=[0.460])
>>> json_stuff = json.dumps(eos.as_json())
>>> new_eos = GCEOSMIX.from_json(json.loads(json_stuff))
>>> assert new_eos == eos
Other json libraries can be used besides the standard json library by design.
Storing and recreating objects with Python’s pickle.dumps
library is also tested; this can be faster than using JSON at the cost of being binary data.
Mixture Equilibrium¶
Unlike pure components, it is not straightforward to determine what the equilibrium state is for mixtures. Different algorithms are used such as sequential substitution and Gibbs minimization. All of those require initial guesses, which usually come from simpler thermodynamic models. While in practice it is possible to determine the equilibrium composition to an N-phase problem, in theory a global optimization algorithm must be used.
More details on this topic can be found in the thermo.flash
module.
Using Units with Cubic Equations of State¶
There is a pint wrapper to use these objects as well.
>>> from thermo.units import *
>>> kwargs = dict(T=400.0*u.degC, P=30*u.psi, Tcs=[126.1, 190.6]*u.K, Pcs=[33.94E5, 46.04E5]*u.Pa, omegas=[0.04, 0.011]*u.dimensionless, zs=[0.5, 0.5]*u.dimensionless, kijs=[[0.0, 0.0289], [0.0289, 0.0]]*u.dimensionless)
>>> eos_units = PRMIX(**kwargs)
>>> eos_units.H_dep_g, eos_units.T
(<Quantity(-2.53858854, 'joule / mole')>, <Quantity(673.15, 'kelvin')>)
>>> base = IG(T=300.0*u.K, P=1e6*u.Pa)
>>> base.V_g
<Quantity(0.00249433879, 'meter ** 3 / mole')>
Introduction to Activity Coefficient Models¶
Vapor-liquid and liquid-liquid equilibria systems can have all sorts of different behavior. Raoult’s law can describe only temperature and pressure dependence, so a correction factor that adds dependence on composition called the “activity coefficient” is often used. This is a separate approach to using an equation of state, but because direct vapor pressure correlations are used with the activity coefficients, a higher-accuracy result can be obtained for phase equilibria.
While these models are often called “activity coefficient models”, they are in fact actually a prediction for excess Gibbs energy. The activity coefficients that are used for phase equilibria are derived from the partial mole number derivative of excess Gibbs energy according to the following expression:
There are 5 basic activity coefficient models in thermo:
Each of these models are object-oriented, and inherit from a base class GibbsExcess
that provides many common methods. A further dummy class that predicts zero excess Gibbs energy and activity coefficients of 1 is available as IdealSolution
.
The excess Gibbs energy model is typically fairly simple. A number of derivatives are needed to calculate other properties like activity coefficient so those expressions can seem more complicated than the model really is. In the literature it is common for a model to be shown directly in activity coefficient form without discussion of the Gibbs excess energy model. To illustrate the difference, here is the NRTL
model Gibbs energy expression and its activity coefficient model:
The models NRTL
, Wilson
, and UNIQUAC
are the most commonly used. Each of them is regression-based - all coefficients must be found in the literature or regressed yourself. Each of these models has extensive temperature dependence parameters in addition to the composition dependence. The temperature dependencies implemented should allow parameters from most other sources to be used here with them.
The model RegularSolution
is based on the concept of a solubility parameter
; with liquid molar volumes and solubility parameters it is a predictive model. It does not show temperature dependence. Additional regression coefficients can be used with that model also.
The UNIFAC
model is a predictive group-contribution scheme.
In it, each molecule is fragmented into different sections. These sections have interaction parameters with other sections. Usually the fragmentation is not done by hand. One online tool for doing this is the DDBST Online Group Assignment Tool.
Object Structure¶
The GibbsExcess
object doesn’t know anything about phase equilibria, vapor pressure, or flash routines; it is limited in scope to dealing with excess Gibbs energy. Because of that modularity, an initialized GibbsExcess
object is designed to be passed in an argument to a cubic equations of state that use excess Gibbs energy such as PSRK
.
The other place these objects are used are in GibbsExcessLiquid
objects, which brings the pieces together to construct a thermodynamically (mostly) consistent phase that the flash algorithms
can work with.
This modularity allows new Gibbs excess models to be written and used anywhere - so the PSRK
model will happily allow a UNIFAC object configured like VTPR.
UNIFAC Example¶
The UNIFAC model is a group contribution based predictive model that is works using “fragmentations” of each molecule into a number of different “groups” and their “counts”,
The DDBST has published numerous sample problems using UNIFAC; a simple binary system from example P05.22a in 2 with n-hexane and butanone-2 is shown below:
>>> from thermo.unifac import UFIP, UFSG, UNIFAC
>>> GE = UNIFAC.from_subgroups(chemgroups=[{1:2, 2:4}, {1:1, 2:1, 18:1}], T=60+273.15, xs=[0.5, 0.5], version=0, interaction_data=UFIP, subgroups=UFSG)
The solution given by the DDBST has the activity coefficient values [1.428, 1.365], which match those calculated by the UNIFAC object:
>>> GE.gammas()
[1.4276025835, 1.3646545010]
Many other properties are also implemented, a few of which are shown below:
>>> GE.GE(), GE.dGE_dT(), GE.d2GE_dT2()
(923.641197, 0.206721488, -0.00380070204)
>>> GE.HE(), GE.SE(), GE.dHE_dT(), GE.dSE_dT()
(854.77193363, -0.2067214889, 1.266203886, 0.0038007020460)
Note that the UFIP
and UFSG
variables contain the actual interaction parameters;
none are hardcoded with the class, so the class could be used for regression. The version parameter controls which variant of UNIFAC to
use, as there are quite a few. The different UNIFAC models implemented include original UNIFAC, Dortmund UNIFAC, PSRK, VTPR, Lyngby/Larsen, and UNIFAC KT.
Interaction parameters for all models are included as well, but the version argument is not connected to the data files.
For convenience, a number of molecule fragmentations are distributed with the UNIFAC code. All fragmentations were obtained through the DDBST online portal, where molecular structure files can be submitted. This has the advantage that what is submitted is unambiguous; there are no worries about CAS numbers like how graphite and diamond have a different CAS number while being the same element or Air having a CAS number despite being a mixture. Accordingly, The index in these distributed data files are InChI keys, which can be obtained from chemicals.identifiers
or in various places online.
>>> import thermo.unifac
>>> thermo.unifac.load_group_assignments_DDBST()
>>> len(thermo.unifac.DDBST_UNIFAC_assignments)
28846
>>> len(thermo.unifac.DDBST_MODIFIED_UNIFAC_assignments)
29271
>>> len(thermo.unifac.DDBST_PSRK_assignments)
30034
>>> from chemicals import search_chemical
>>> search_chemical('toluene').InChI_key
'YXFVVABEGXRONW-UHFFFAOYSA-N'
>>> thermo.unifac.DDBST_MODIFIED_UNIFAC_assignments['YXFVVABEGXRONW-UHFFFAOYSA-N']
{9: 5, 11: 1}
Please note that the identifying integer in these {group: count} elements are not necessarily the same in different UNIFAC versions, making them a royal pain.
Notes on Performance¶
Initializing the object for the first time is a not a high performance operation as certain checks need to be done and data structures set up. Some pieces of the equations of the Gibbs excess model may depend only on temperature or composition, instead of depending on both. Each model implements the method to_T_xs
which should be used to create a new object at the new temperature and/or composition. The design of the object is to lazy-calculate properties, and to be immutable: calculations at new temperatures and compositions are done in a new object.
Note also that the __repr__
string for each model is designed to allow lossless reconstruction of the model. This is very useful when building test cases.
>>> GE.to_T_xs(T=400.0, xs=[.1, .9])
UNIFAC(T=400.0, xs=[0.1, 0.9], rs=[4.4998000000000005, 3.2479], qs=[3.856, 2.876], Qs=[0.848, 0.54, 1.488], vs=[[2, 1], [4, 1], [0, 1]], psi_abc=([[0.0, 0.0, 476.4], [0.0, 0.0, 476.4], [26.76, 26.76, 0.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]), version=0)
When working with small numbers of components (5 or under), PyPy offers the best performance and using the model with Python lists as inputs is the fastest way to perform the calculations even in CPython.
If working with many components or if Numpy arrays are desired as inputs and outputs, numpy arrays can be provided as inputs. This will have a negative impact on performance unless the numba interface is used:
>>> import numpy as np
>>> import thermo.numba
>>> N = 3
>>> T = 25.0 + 273.15
>>> xs = np.array([0.7273, 0.0909, 0.1818])
>>> rs = np.array([.92, 2.1055, 3.1878])
>>> qs = np.array([1.4, 1.972, 2.4])
>>> tausA = tausC = tausD = tausE = tausF = np.array([[0.0]*N for i in range(N)])
>>> tausB = np.array([[0, -526.02, -309.64], [318.06, 0, 91.532], [-1325.1, -302.57, 0]])
>>> ABCDEF = (tausA, tausB, tausC, tausD, tausE, tausF)
>>> from thermo import UNIQUAC
>>> GE2 = UNIQUAC(T=T, xs=xs, rs=rs, qs=qs, ABCDEF=ABCDEF)
>>> GE2.gammas()
array([ 1.57039333, 0.29482416, 18.11432905])
The numba interface will speed code up and allow calculations with dozens of components. The numba interface requires all inputs to be numpy arrays and all of its outputs are also numba arrays.
>>> GE3 = thermo.numba.UNIQUAC(T=T, xs=xs, rs=rs, qs=qs, ABCDEF=ABCDEF)
>>> GE3.gammas()
array([ 1.57039333, 0.29482416, 18.11432905])
As an example of the performance benefits, a 200-component UNIFAC gamma calculation takes 10.6 ms in CPython and 318 µs when accelerated by Numba. In this case PyPy takes at 664 µs.
When the same benchmark is performed with 10 components, the calculation takes 387 µs in CPython, 88.6 µs with numba, and 36.2 µs with PyPy.
It can be quite important to use the to_T_xs
method re-use parts of the calculation; for UNIFAC, several terms depends only on temperature. If the 200 component calculation is repeated with those already calculated, the timings are 3.26 ms in CPython, 127 µs with numba, and 125 µs with PyPy.
Other features¶
The limiting infinite-dilution activity coefficients can be obtained with a call to gammas_infinite_dilution
>>> GE.gammas_infinite_dilution()
[3.5659995166, 4.32849696]
All activity coefficient models offer a as_json
method and a from_json
to serialize the object state for transport over a network, storing to disk, and passing data between processes.
>>> from thermo import IdealSolution
>>> import json
>>> model = IdealSolution(T=300.0, xs=[.1, .2, .3, .4])
>>> json_view = model.as_json()
>>> json_str = json.dumps(json_view)
>>> model_copy = IdealSolution.from_json(json.loads(json_str))
>>> assert model_copy == model
Other json libraries can be used besides the standard json library by design.
Storing and recreating objects with Python’s pickle.dumps
library is also tested; this can be faster than using JSON at the cost of being binary data.
All models have a __hash__
method that can be used to compare different models to see if they are absolutely identical (including which values have been calculated already).
They also have a model_hash
method that can be used to compare different models to see if they have identical model parameters.
They also have a state_hash
method that can be used to compare different models to see if they have identical temperature, composition, and model parameters.
Activity Coefficient Identities¶
A set of useful equations are as follows. For more information, the reader is directed to 1, 2, 3, 4, and 5; no one source contains all this information.
References¶
- 1
Poling, Bruce E., John M. Prausnitz, and John P. O’Connell. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
- 2(1,2)
Gmehling, Jürgen, Michael Kleiber, Bärbel Kolbe, and Jürgen Rarey. Chemical Thermodynamics for Process Simulation. John Wiley & Sons, 2019.
- 3
Nevers, Noel de. Physical and Chemical Equilibrium for Chemical Engineers. 2nd edition. Wiley, 2012.
- 4
Elliott, J., and Carl Lira. Introductory Chemical Engineering Thermodynamics. 2nd edition. Upper Saddle River, NJ: Prentice Hall, 2012.
- 5
Walas, Dr Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.
Introduction to Property Objects¶
For every chemical property, there are lots and lots of methods. The methods can be grouped by which phase they apply to, although some methods are valid for both liquids and gases.
Properties calculations be separated into three categories:
Properties of chemicals that depend on temperature. Some properties have weak dependence on pressure, like surface tension, and others have no dependence on pressure like vapor pressure by definition.
Properties of chemicals that depend on temperature and pressure. Some properties have weak dependence on pressure like thermal conductivity, while other properties depend on pressure fundamentally, like gas volume.
Properties of mixtures, that depend on temperature and pressure and composition. Some properties like gas mixture heat capacity require the pressure as an input but do not use it.
These properties are implemented in an object oriented way, with the actual functional algorithms themselves having been separated out into the chemicals library. The goal of these objects is to make it easy to experiment with different methods.
The base classes for the three respective types of properties are:
The specific classes for the three respective types of properties are:
HeatCapacityGas
,HeatCapacityLiquid
,HeatCapacitySolid
,VolumeSolid
,VaporPressure
,SublimationPressure
,EnthalpyVaporization
,EnthalpySublimation
,Permittivity
,SurfaceTension
.VolumeGas
,VolumeLiquid
,ViscosityGas
,ViscosityLiquid
,ThermalConductivityGas
,ThermalConductivityLiquid
HeatCapacityGasMixture
,HeatCapacityLiquidMixture
,HeatCapacitySolidMixture
,VolumeGasMixture
,VolumeLiquidMixture
,VolumeSolidMixture
,ViscosityLiquidMixture
,ViscosityGasMixture
,ThermalConductivityLiquidMixture
,ThermalConductivityGasMixture
,SurfaceTensionMixture
Temperature Dependent Properties¶
The following examples introduce how to use some of the methods of the TDependentProperty
objects. The API documentation for TDependentProperty
as well as each specific property such as
VaporPressure
should be consulted for full details.
Creating Objects¶
All arguments and information the property object requires must be provided in the constructor of the object. If a piece of information is not provided, whichever methods require it will not be available for that object.
>>> from thermo import VaporPressure, HeatCapacityGas
>>> ethanol_psat = VaporPressure(Tb=351.39, Tc=514.0, Pc=6137000.0, omega=0.635, CASRN='64-17-5')
Various data files will be searched to see if information such as Antoine coefficients is available for the compound during the initialization. This behavior can be avoided by setting the optional load_data argument to False. Loading data requires pandas, uses more RAM, and is a once-per-process procedure that takes 20-1000 ms per property. For some applications it may be advantageous to provide your own data instead of using the provided data files.
>>> useless_psat = VaporPressure(CASRN='64-17-5', load_data=False)
Temperature-dependent Methods¶
As many methods may be available, a single method is always selected automatically during initialization. This method can be inspected with the method
property; if no methods are available, method will be None. method is also a valid parameter when constructing the object, but if the method specified is not available an exception will be raised.
>>> ethanol_psat.method, useless_psat.method
('WAGNER_MCGARRY', None)
All available methods can be found by inspecting the all_methods
attribute:
>>> ethanol_psat.all_methods
{'ANTOINE_POLING', 'EDALAT', 'WAGNER_POLING', 'SANJARI', 'COOLPROP', 'LEE_KESLER_PSAT', 'DIPPR_PERRY_8E', 'VDI_PPDS', 'WAGNER_MCGARRY', 'VDI_TABULAR', 'AMBROSE_WALTON', 'BOILING_CRITICAL'}
Changing the method is as easy as setting a new value to the attribute:
>>> ethanol_psat.method = 'ANTOINE_POLING'
>>> ethanol_psat.method
'ANTOINE_POLING'
>>> ethanol_psat.method = 'WAGNER_MCGARRY'
Calculating Properties¶
Calculation of the property at a specific temperature is as easy as calling the object which triggers the __call__
method:
>>> ethanol_psat(300.0)
8753.8160
This is actually a cached wrapper around the specific call, T_dependent_property
:
>>> ethanol_psat.T_dependent_property(300.0)
8753.8160
The caching of __call__
is quite basic - the previously specified temperature is stored, and if the new T is the same as the previous T the previously calculated result is returned.
There is a lower-level interface for calculating properties with a specified method by name, calculate
. T_dependent_property
is a wrapper around calculate
that includes validation of the result.
>>> ethanol_psat.calculate(T=300.0, method='WAGNER_MCGARRY')
8753.8160
>>> ethanol_psat.calculate(T=300.0, method='DIPPR_PERRY_8E')
8812.9812
Limits and Extrapolation¶
Each correlation is associated with temperature limits. These can be inspected as part of the T_limits
attribute which is loaded on creation of the property object.
>>> ethanol_psat.T_limits
{'WAGNER_MCGARRY': (293.0, 513.92), 'WAGNER_POLING': (159.05, 513.92), 'ANTOINE_POLING': (276.5, 369.54), 'DIPPR_PERRY_8E': (159.05, 514.0), 'COOLPROP': (159.1, 514.71), 'VDI_TABULAR': (300.0, 513.9), 'VDI_PPDS': (159.05, 513.9), 'BOILING_CRITICAL': (0.01, 514.0), 'LEE_KESLER_PSAT': (0.01, 514.0), 'AMBROSE_WALTON': (0.01, 514.0), 'SANJARI': (0.01, 514.0), 'EDALAT': (0.01, 514.0)}
Because there is often a need to obtain a property outside the range of the correlation, there are some extrapolation methods available; depending on the method these may be enabled by default.
The full list of extrapolation methods can be see here
.
For vapor pressure, there are actually two separate extrapolation techniques used, one for the low-pressure and thermodynamically reasonable region and another for extrapolating even past the critical point. This can be useful for obtaining initial estimates of phase equilibrium.
The low-pressure region uses \(\log(P_{sat}) = A - B/T\), where the coefficients A and B are calculated from the low-temperature limit and its temperature derivative. The default high-temperature extrapolation is \(P_{sat} = \exp\left(A + B/T + C\log(T)\right)\). The coefficients are also determined from the high-temperature limits and its first two temperature derivatives.
When extrapolation is turned on, it is used automatically if a property is requested out of range:
>>> ethanol_psat(100.0), ethanol_psat(1000)
(1.047582e-11, 1779196575.4962692)
The default extrapolation methods may be changed in the future, but can be manually specified also by changing the value of the extrapolation
attribute. For example, if the linear extrapolation method is set, extrapolation will be linear instead of using those fit equations. Because not all properties are suitable for linear extrapolation, some methods have a default transform to make the property behave as linearly as possible. This is also used in tabular interpolation:
>>> ethanol_psat.extrapolation = 'linear'
>>> ethanol_psat(100.0), ethanol_psat(1000)
(1.0475e-11, 385182009.4)
The low-temperature linearly extrapolated value is actually the same as before, because it performs a 1/T transform and a log(P) transform on the output, which results in the fit being the same as the default equation for vapor pressure.
To better understand what methods are available, the valid_methods
method checks all available correlations against their temperature limits.
>>> ethanol_psat.valid_methods(100)
['AMBROSE_WALTON', 'LEE_KESLER_PSAT', 'EDALAT', 'BOILING_CRITICAL', 'SANJARI']
If the temperature is not provided, all available methods are returned; the returned value favors the methods by the ranking defined in thermo, with the currently selected method as the first item.
>>> ethanol_psat.valid_methods()
['WAGNER_MCGARRY', 'WAGNER_POLING', 'DIPPR_PERRY_8E', 'VDI_PPDS', 'COOLPROP', 'ANTOINE_POLING', 'VDI_TABULAR', 'AMBROSE_WALTON', 'LEE_KESLER_PSAT', 'EDALAT', 'BOILING_CRITICAL', 'SANJARI']
Plotting¶
It is also possible to compare the correlations graphically with the method plot_T_dependent_property
.
>>> ethanol_psat.plot_T_dependent_property(Tmin=300)
(Source code, png, hires.png, pdf)
By default all methods are shown in the plot, but a smaller selection of methods can be specified. The following example compares 30 points in the temperature range 400 K to 500 K, with three of the best methods.
>>> ethanol_psat.plot_T_dependent_property(Tmin=400, Tmax=500, methods=['COOLPROP', 'WAGNER_MCGARRY', 'DIPPR_PERRY_8E'], pts=30)
(Source code, png, hires.png, pdf)
It is also possible to plot the nth derivative of the methods with the order parameter. The following plot shows the first derivative of vapor pressure of three estimation methods, a tabular source being interpolated, and ‘DIPPR_PERRY_8E’ as a reference method.
>>> ethanol_psat.plot_T_dependent_property(Tmin=400, Tmax=500, methods=['BOILING_CRITICAL', 'SANJARI', 'LEE_KESLER_PSAT', 'VDI_TABULAR', 'DIPPR_PERRY_8E'], pts=50, order=1)
(Source code, png, hires.png, pdf)
Plots show how the extrapolation methods work. By default plots do not show extrapolated values from methods, but this can be forced by setting only_valid to False. It is easy to see that extrapolation is designed to show the correct trend, but that individual methods will have very different extrapolations.
>>> ethanol_psat.plot_T_dependent_property(Tmin=1, Tmax=300, methods=['VDI_TABULAR', 'DIPPR_PERRY_8E', 'COOLPROP'], pts=50, only_valid=False)
(Source code, png, hires.png, pdf)
It may also be helpful to see the derivative with respect to temperature of methods. This can be done with the order keyword:
>>> ethanol_psat.plot_T_dependent_property(Tmin=1, Tmax=300, methods=['VDI_TABULAR', 'DIPPR_PERRY_8E', 'COOLPROP'], pts=50, only_valid=False, order=1)
(Source code, png, hires.png, pdf)
Higher order derivatives are also supported; most derivatives are numerically calculated, so there may be some noise. The derivative plot is particularly good at illustrating what happens at the critical point, when extrapolation takes over from the actual formulas.
>>> ethanol_psat.plot_T_dependent_property(Tmin=500, Tmax=525, methods=['VDI_TABULAR', 'DIPPR_PERRY_8E', 'AMBROSE_WALTON', 'VDI_PPDS', 'WAGNER_MCGARRY'], pts=50, only_valid=False, order=2)
(Source code, png, hires.png, pdf)
Calculating Temperature From Properties¶
There is also functionality for reversing the calculation - finding out which temperature produces a specific property value. The method is solve_property
. For vapor pressure, we can use this technique to find out the normal boiling point as follows:
>>> ethanol_psat.solve_property(101325)
351.43136
The experimentally reported value is 351.39 K.
Property Derivatives¶
Functionality for calculating the derivative of the property is also implemented as T_dependent_property_derivative
:
>>> ethanol_psat.T_dependent_property_derivative(300)
498.882
The derivatives are numerical unless a special implementation has been added to the property’s calculate_derivative
method.
Higher order derivatives are available as well with the order argument. All higher-order derivatives are numerical, and they tend to have reduced numerical precision due to floating point limitations.
>>> ethanol_psat.T_dependent_property_derivative(300.0, order=2)
24.74
>>> ethanol_psat.T_dependent_property_derivative(300.0, order=3)
2.75
Property Integrals¶
Functionality for integrating over a property is implemented as T_dependent_property_integral
.
When the property is heat capacity, this calculation represents a change in enthalpy:
>>> CH4_Cp = HeatCapacityGas(CASRN='74-82-8')
>>> CH4_Cp.method = 'POLING_POLY'
>>> CH4_Cp.T_dependent_property_integral(300, 500)
8158.64
Besides enthalpy, a commonly used integral is that of the property divided by T:
When the property is heat capacity, this calculation represents a change in entropy:
This integral, property over T, is implemented as T_dependent_property_integral_over_T
:
>>> CH4_Cp.T_dependent_property_integral_over_T(300, 500)
20.6088
Where speed has been important so far, these integrals have been implemented analytically in a property object’s calculate_integral
and calculate_integral_over_T
method; otherwise the integration is performed numerically.
Using Tabular Data¶
A common scenario is that there are no correlations available for a compound, and that estimation methods are not applicable. However, there may be a few experimental data points available in the literature. In this case, the data can be specified and used directly with the add_tabular_data
method. Extrapolation can often show the correct trends for these properties from even a few data points.
In the example below, we take 5 data points on the vapor pressure of water from 300 K to 350 K, and use them to extrapolate and estimate the triple temperature and critical temperature (assuming we know the triple and critical pressures).
>>> from thermo import *
>>> import numpy as np
>>> w = VaporPressure(Tb=373.124, Tc=647.14, Pc=22048320.0, omega=0.344, CASRN='7732-18-5', extrapolation='AntoineAB')
>>> Ts = np.linspace(300, 350, 5).tolist()
>>> Ps = [3533.9, 7125., 13514., 24287., 41619.]
>>> w.add_tabular_data(Ts=Ts, properties=Ps)
>>> w.solve_property(610.707), w.solve_property(22048320)
(272.83, 617.9)
The experimental values are 273.15 K and 647.14 K.
Adding New Methods¶
While a great many property methods have been implemented, there is always the case where a new one must be added. To support that, the method add_method
will add a user-specified method and switch the method selected to the newly added method.
As an example, we can compare the default vapor pressure formulation for n-hexane against a set of Antoine coefficients on the NIST WebBook.
>>> from chemicals import *
>>> from thermo import *
>>> obj = VaporPressure(CASRN= '110-54-3')
>>> obj(200)
20.742
>>> f = lambda T: Antoine(T=T, A=3.45604+5, B=1044.038, C=-53.893)
>>> obj.add_method(f=f, name='WebBook', Tmin=177.70, Tmax=264.93)
>>> obj.method
'WebBook'
>>> obj.extrapolation = 'AntoineAB'
>>> obj(200.0)
20.432
We can, again, extrapolate quite easily and estimate the triple temperature and critical temperature from these correlations (if we know the triple pressure and critical pressure).
>>> obj.solve_property(1.378), obj.solve_property(3025000.0)
(179.43, 508.04)
Optionally, some derivatives and integrals can be provided for new methods as well. This avoids having to compute derivatives or integrals numerically. SymPy may be helpful to find these analytical derivatives or integrals in many cases, as in the following example:
>>> from sympy import symbols, lambdify, diff
>>> T = symbols('T')
>>> A, B, C = 3.45604+5, 1044.038, -53.893
>>> expr = 10**(A - B/(T + C))
>>> f = lambdify(T, expr)
>>> f_der = lambdify(T, diff(expr, T))
>>> f_der2 = lambdify(T, diff(expr, T, 2))
>>> f_der3 = lambdify(T, diff(expr, T, 3))
>>> obj.add_method(f=f, f_der=f_der, f_der2=f_der2, f_der3=f_der3, name='WebBookSymPy', Tmin=177.70, Tmax=264.93)
>>> obj.method, obj(200), obj.T_dependent_property_derivative(200.0, order=2)
('WebBookSymPy', 20.43298036, 0.2276285)
Note that adding methods like this breaks the ability to export as json and the repr of the object is no longer complete.
Adding New Correlation Coefficient Methods¶
While adding entirely new methods is useful, it is more common to want to use different coefficients in an existing equation.
A number of different equations are recognized, and accept/require the parameters as per their function name in e.g. chemicals.vapor_pressure.Antoine
. More than one set of coefficients can be added for each model. After adding a new correlation the method is set to that method.
>>> obj = VaporPressure()
>>> obj.add_correlation(name='WebBook', model='Antoine', Tmin=177.70, Tmax=264.93, A=3.45604+5, B=1044.038, C=-53.893)
>>> obj(200)
20.43298036711
It is also possible to specify the parameters in the constructor of the object as well:
>>> obj = VaporPressure(Antoine_parameters={'WebBook': {'A': 8.45604, 'B': 1044.038, 'C': -53.893, 'Tmin': 177.7, 'Tmax': 264.93}})
>>> obj(200)
20.43298036711
More than one set of parameters and more than one model may be specified this way; the model name is the same, with ‘_parameters’ appended to it.
For a full list of supported correlations (and their names), see add_correlation
.
Fitting Correlation Coefficients¶
Thermo contains functionality for performing regression to obtain equation coefficients from experimental data.
Data is obtained from the DDBST for the vapor pressure of acetone (http://www.ddbst.com/en/EED/PCP/VAP_C4.php), and coefficients are regressed for several methods. There is data from five sources on that page, but no uncertainties are available; the fit will treat each data point equally.
>>> Ts = [203.65, 209.55, 212.45, 234.05, 237.04, 243.25, 249.35, 253.34, 257.25, 262.12, 264.5, 267.05, 268.95, 269.74, 272.95, 273.46, 275.97, 276.61, 277.23, 282.03, 283.06, 288.94, 291.49, 293.15, 293.15, 293.85, 294.25, 294.45, 294.6, 294.63, 294.85, 297.05, 297.45, 298.15, 298.15, 298.15, 298.15, 298.15, 299.86, 300.75, 301.35, 303.15, 303.15, 304.35, 304.85, 305.45, 306.25, 308.15, 308.15, 308.15, 308.22, 308.35, 308.45, 308.85, 309.05, 311.65, 311.85, 311.85, 311.95, 312.25, 314.68, 314.85, 317.75, 317.85, 318.05, 318.15, 318.66, 320.35, 320.35, 320.45, 320.65, 322.55, 322.65, 322.85, 322.95, 322.95, 323.35, 323.55, 324.65, 324.75, 324.85, 324.85, 325.15, 327.05, 327.15, 327.2, 327.25, 327.35, 328.22, 328.75, 328.85, 333.73, 338.95]
>>> Psats = [58.93, 94.4, 118.52, 797.1, 996.5, 1581.2, 2365, 3480, 3893, 5182, 6041, 6853, 7442, 7935, 9290, 9639, 10983, 11283, 13014, 14775, 15559, 20364, 22883, 24478, 24598, 25131, 25665, 25931, 25998, 26079, 26264, 29064, 29598, 30397, 30544, 30611, 30784, 30851, 32636, 33931, 34864, 37637, 37824, 39330, 40130, 41063, 42396, 45996, 46090, 46356, 45462, 46263, 46396, 47129, 47396, 52996, 52929, 53262, 53062, 53796, 58169, 59328, 66395, 66461, 67461, 67661, 67424, 72927, 73127, 73061, 73927, 79127, 79527, 80393, 79927, 80127, 81993, 80175, 85393, 85660, 85993, 86260, 86660, 92726, 92992, 92992, 93126, 93326, 94366, 98325, 98592, 113737, 136626]
>>> res, stats = TDependentProperty.fit_data_to_model(Ts=Ts, data=Psats, model='Antoine', do_statistics=True, multiple_tries=True, model_kwargs={'base': 10.0})
>>> res, stats['MAE']
({'A': 9.2515513342, 'B': 1230.099383065, 'C': -40.08076540233, 'base': 10.0}, 0.01059288655304)
The fitting function returns the regressed coefficients, and optionally some statistics. The mean absolute relative error or “MAE” is often a good parameter for determining the goodness of fit; Antoine yielded an error of about 1%.
There are lots of methods available; Antoine was just used (the returned coefficients are in units of K and Pa with a base of 10), but for comparison several more are as well. Note that some require the critical temperature and/or pressure.
>>> Tc, Pc = 508.1, 4700000.0
>>> res, stats = TDependentProperty.fit_data_to_model(Ts=Ts, data=Psats, model='Yaws_Psat', do_statistics=True, multiple_tries=True)
>>> res, stats['MAE']
({'A': 1650.7, 'B': -32673., 'C': -728.7, 'D': 1.1, 'E': -0.000609}, 0.0178)
>>> res, stats = TDependentProperty.fit_data_to_model(Ts=Ts, data=Psats, model='DIPPR101', do_statistics=True, multiple_tries=3)
>>> stats['MAE']
0.0106
>>> res, stats = TDependentProperty.fit_data_to_model(Ts=Ts, data=Psats, model='Wagner', do_statistics=True, multiple_tries=True, model_kwargs={'Tc': Tc, 'Pc': Pc})
>>> res, stats['MAE']
({'Tc': 508.1, 'Pc': 4700000.0, 'a': -15.7110, 'b': 23.63, 'c': -27.74, 'd': 25.152}, 0.0485)
>>> res, stats = TDependentProperty.fit_data_to_model(Ts=Ts, data=Psats, model='TRC_Antoine_extended', do_statistics=True, multiple_tries=True, model_kwargs={'Tc': Tc})
>>> res, stats['MAE']
({'Tc': 508.1, 'to': 67.0, 'A': 9.2515481, 'B': 1230.0976, 'C': -40.080954, 'n': 2.5, 'E': 333.0, 'F': -24950.0}, 0.01059)
A very common scenario is that some coefficients are desired to be fixed in the regression. This is supported with the model_kwargs attribute. For example, in the above DIPPR101 case we can fix the E coefficient to 1 as follows:
>>> res, stats = TDependentProperty.fit_data_to_model(Ts=Ts, data=Psats, model='DIPPR101', do_statistics=True, multiple_tries=3, model_kwargs={'E': -1})
>>> res['E'], stats['MAE']
(-1, 0.01310)
Similarly, the feature is often used to set unneeded coefficients to zero In this case the TDE_PVExpansion function has up to 8 parameters but only three are justified.
>>> res, stats = TDependentProperty.fit_data_to_model(Ts=Ts, data=Psats, model='TDE_PVExpansion', do_statistics=True, multiple_tries=True, model_kwargs={'a4': 0.0, 'a5': 0.0, 'a6': 0.0, 'a7': 0.0, 'a8': 0})
>>> res, stats['MAE']
({'a4': 0.0, 'a5': 0.0, 'a6': 0.0, 'a7': 0.0, 'a8': 0, 'a1': 48.396547, 'a2': -4914.1260, 'a3': -3.78894783}, 0.0131003)
Fitting coefficients is a complicated numerical problem. MINPACK’s lmfit implements Levenberg-Marquardt with a number of tricks, and is used through SciPy in the fitting by default. Other minimization algorithms are supported, but generally don’t do nearly as well. All minimization algorithms can only converge to a minima near points that they evaluate, and the choice of initial guesses is quite important. For many methods, there are several hardcoded guesses. By default, each of those guesses are evaluated and the minimization is initialized with the best guess. However, for maximum accuracy, multiple_tries should be set to True, and all initial guesses are converged, and the best fit is returned.
Initial guesses for parameters can also be provided. In the below example, the initial parameters from http://ddbonline.ddbst.com/AntoineCalculation/AntoineCalculationCGI.exe for acetone are provided as initial guesses (converting them to a Pa and K basis, from mmHg and deg C).
>>> from math import log10
>>> res, stats = TDependentProperty.fit_data_to_model(Ts=Ts, data=Psats, model='Antoine', do_statistics=True, multiple_tries=True, guesses={'A': 7.6313 +log10(101325/760), 'B': 1566.69 , 'C': 273.419 -273.15}, model_kwargs={'base': 10.0})
In this case the initial guesses are good, but different parameters are still obtained by the fitting algorithm.
To speed up these calculations, an interface to numba is available. Simply set use_numba to True. Note that the first regression per session may be slower as it has to compile the function.
Adding New Correlation Coefficient Methods From Data¶
In the following example, data for the molar volume of three phases of liquid oxygen are added, from Roder, H. M. “The Molar Volume (Density) of Solid Oxygen in Equilibrium with Vapor.” Journal of Physical and Chemical Reference Data 7, no. 3 (1978): 949–58.
Each of the phases is treated as a different method. After fitting the data to linear and quadratic fits, the results are plotted.
>>> Ts_alpha = [4.2, 10.0, 18.5, 20, 21, 22, 23.880]
>>> Vms_alpha = [20.75e-6, 20.75e-6, 20.75e-6, 20.75e-6, 20.75e-6, 20.78e-6, 20.82e-6]
>>> Ts_beta = [23.880, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 43.801]
>>> Vms_beta = [20.95e-6, 20.95e-6, 21.02e-6, 21.08e-6, 21.16e-6, 21.24e-6, 21.33e-6, 21.42e-6, 21.52e-6, 21.63e-6, 21.75e-6, 21.87e-6]
>>> Ts_gamma = [42.801, 44.0, 46.0, 48.0, 50.0, 52.0, 54.0, 54.361]
>>> Vms_gamma = [23.05e-6, 23.06e-6, 23.18e-6, 23.30e-6, 23.43e-6, 23.55e-6, 23.67e-6, 23.69e-6]
>>> obj = VolumeSolid(CASRN='7782-44-7')
>>> obj.fit_add_model(Ts=Ts_alpha, data=Vms_alpha, model='linear', name='alpha')
>>> obj.fit_add_model(Ts=Ts_beta, data=Vms_beta, model='quadratic', name='beta')
>>> obj.fit_add_model(Ts=Ts_gamma, data=Vms_gamma, model='quadratic', name='gamma')
>>> obj.plot_T_dependent_property(Tmin=4.2, Tmax=50)
Temperature and Pressure Dependent Properties¶
The pressure dependent objects work much like the temperature dependent ones; in fact, they subclass TDependentProperty
.
They have many new methods that require pressure as an input however. They work in two parts: a low-pressure correlation component, and a high-pressure correlation component. The high-pressure component usually but not always requires a low-pressure calculation to be performed first as its input.
Creating Objects¶
All arguments and information the property object requires must be provided in the constructor of the object. If a piece of information is not provided, whichever methods require it will not be available for that object. Many pressure-dependent property correlations are actually dependent on other properties being calculated first. A mapping of those dependencies is as follows:
Liquid molar volume: Depends on
VaporPressure
Gas viscosity: Depends on
VolumeGas
Liquid viscosity: Depends on
VaporPressure
Gas thermal conductivity: Depends on
VolumeGas
,HeatCapacityGas
,ViscosityGas
The required input objects should be created first, and provided as an input to the dependent object:
>>> water_psat = VaporPressure(Tb=373.124, Tc=647.14, Pc=22048320.0, omega=0.344, CASRN='7732-18-5')
>>> water_mu = ViscosityLiquid(CASRN="7732-18-5", MW=18.01528, Tm=273.15, Tc=647.14, Pc=22048320.0, Vc=5.6e-05, omega=0.344, method="DIPPR_PERRY_8E", Psat=water_psat, method_P="LUCAS")
Various data files will be searched to see if information such as DIPPR expression coefficients are available for the compound during the initialization. This behavior can be avoided by setting the optional load_data argument to False.
Pressure-dependent Methods¶
The pressure and temperature dependent object selects a low-pressure and a high-pressure method automatically during initialization.
These method can be inspected with the method
and method_P
properties.
If no low-pressure methods are available, method will be None. If no high-pressure methods are available, method_P will be None. method and method_P are also valid parameters when constructing the object, but if either of the methods specified is not available an exception will be raised.
>>> water_mu.method, water_mu.method_P
('DIPPR_PERRY_8E', 'LUCAS')
All available low-pressure methods can be found by inspecting the all_methods
attribute:
>>> water_mu.all_methods
{'COOLPROP', 'DIPPR_PERRY_8E', 'VISWANATH_NATARAJAN_3', 'VDI_PPDS', 'LETSOU_STIEL'}
All available high-pressure methods can be found by inspecting the all_methods_P
attribute:
>>> water_mu.all_methods_P
{'COOLPROP', 'LUCAS'}
Changing the low-pressure method or the high-pressure method is as easy as setting a new value to the attribute:
>>> water_mu.method = 'VDI_PPDS'
>>> water_mu.method
'VDI_PPDS'
>>> water_mu.method_P = 'COOLPROP'
>>> water_mu.method_P
'COOLPROP'
Calculating Properties¶
Calculation of the property at a specific temperature and pressure is as easy as calling the object which triggers the __call__
method:
>>> water_mu.method = 'VDI_PPDS'
>>> water_mu.method_P = 'COOLPROP'
>>> water_mu(T=300.0, P=1e5)
0.000853742
This is actually a cached wrapper around the specific call, TP_dependent_property
:
>>> water_mu.TP_dependent_property(300.0, P=1e5)
0.000853742
The caching of __call__
is quite basic - the previously specified temperature and pressure are stored, and if the new T and P are the same as the previous T and P the previously calculated result is returned.
There is a lower-level interface for calculating properties with a specified method by name, calculate_P
. TP_dependent_property
is a wrapper around calculate_P
that includes validation of the result.
>>> water_mu.calculate_P(T=300.0, P=1e5, method='COOLPROP')
0.000853742
>>> water_mu.calculate_P(T=300.0, P=1e5, method='LUCAS')
0.000865292
The above examples all show using calculating the property with a pressure specified. The same TDependentProperty
methods are available too, so all the low-pressure calculation calls are also available.
>>> water_mu.calculate(T=300.0, method='VISWANATH_NATARAJAN_3')
0.000856467
>>> water_mu.T_dependent_property(T=400.0)
0.000217346
Limits and Extrapolation¶
The same temperature limits and low-pressure extrapolation methods are available as for TDependentProperty
.
>>> water_mu.valid_methods(T=480)
['DIPPR_PERRY_8E', 'COOLPROP', 'VDI_PPDS', 'LETSOU_STIEL']
>>> water_mu.extrapolation
'linear'
To better understand what methods are available, the valid_methods_P
method checks all available high-pressure correlations against their temperature and pressure limits.
>>> water_mu.valid_methods_P(T=300, P=1e9)
['LUCAS', 'COOLPROP']
>>> water_mu.valid_methods_P(T=300, P=1e10)
['LUCAS']
>>> water_mu.valid_methods_P(T=900, P=1e6)
['LUCAS']
If the temperature and pressure are not provided, all available methods are returned; the returned value favors the methods by the ranking defined in thermo, with the currently selected method as the first item.
>>> water_mu.valid_methods_P()
['LUCAS', 'COOLPROP']
Plotting¶
It is possible to compare the correlations graphically with the method plot_TP_dependent_property
.
>>> water_mu.plot_TP_dependent_property(Tmin=400, Pmin=1e5, Pmax=1e8, methods_P=['COOLPROP','LUCAS'], pts=15, only_valid=False)
(Source code, png, hires.png, pdf)
This can be a little confusing; but isotherms and isobars can be plotted as well, which are more straight forward. The respective methods are plot_isotherm
and plot_isobar
:
>>> water_mu.plot_isotherm(T=350, Pmin=1e5, Pmax=1e7, pts=50)
(Source code, png, hires.png, pdf)
>>> water_mu.plot_isobar(P=1e7, Tmin=300, Tmax=600, pts=50)
(Source code, png, hires.png, pdf)
Calculating Conditions From Properties¶
The method is solve_property
works only on the low-pressure correlations.
>>> water_mu.solve_property(1e-3)
294.0711641
Property Derivatives¶
Functionality for calculating the temperature derivative of the property is implemented twice; as T_dependent_property_derivative
using the low-pressure correlations, and as TP_dependent_property_derivative_T
using the high-pressure correlations that require pressure as an input.
>>> water_mu.T_dependent_property_derivative(300)
-1.893961e-05
>>> water_mu.TP_dependent_property_derivative_T(300, P=1e7)
-1.927268e-05
The derivatives are numerical unless a special implementation has been added to the property’s calculate_derivative_T
and/or calculate_derivative
method.
Higher order derivatives are available as well with the order argument.
>>> water_mu.T_dependent_property_derivative(300.0, order=2)
5.923372e-07
>>> water_mu.TP_dependent_property_derivative_T(300.0, P=1e6, order=2)
-1.40946e-06
Functionality for calculating the pressure derivative of the property is also implemented as TP_dependent_property_derivative_P
:
>>> water_mu.TP_dependent_property_derivative_P(P=5e7, T=400)
4.27782809e-13
The derivatives are numerical unless a special implementation has been added to the property’s calculate_derivative_P
method.
Higher order derivatives are available as well with the order argument.
>>> water_mu.TP_dependent_property_derivative_P(P=5e7, T=400, order=2)
-1.1858461e-15
Property Integrals¶
The same functionality for integrating over a property as in temperature-dependent objects is available, but only for integrating over temperature using low pressure correlations. No other use cases have been identified requiring integration over high-pressure conditions, or integration over the pressure domain.
>>> water_mu.T_dependent_property_integral(300, 400) # Integrating over viscosity has no physical meaning
0.04243
Using Tabular Data¶
If there are experimentally available data for a property at high and low pressure, an interpolation table can be created and used as follows. The CoolProp method is used to generate a small table, and is then added as a new method in the example below.
>>> from thermo import *
>>> import numpy as np
>>> Ts = [300, 400, 500]
>>> Ps = [1e5, 1e6, 1e7]
>>> table = [[water_mu.calculate_P(T, P, "COOLPROP") for T in Ts] for P in Ps]
>>> water_mu.method_P
'LUCAS'
>>> water_mu.add_tabular_data_P(Ts, Ps, table)
>>> water_mu.method_P
'Tabular data series #0'
>>> water_mu(400, 1e7), water_mu.calculate_P(400, 1e7, "COOLPROP")
(0.000221166933349, 0.000221166933349)
>>> water_mu(450, 5e6), water_mu.calculate_P(450, 5e6, "COOLPROP")
(0.00011340, 0.00015423)
The more data points used, the closer a property will match.
Mixture Properties¶
Notes¶
There is also the challenge that there is no clear criteria for distinguishing liquids from gases in supercritical mixtures. If the same method is not used for liquids and gases, there will be a sudden discontinuity which can cause numerical issues in modeling.
Introduction to ChemicalConstantsPackage and PropertyCorrelationsPackage¶
These two objects are designed to contain information needed by flash algorithms. In the first iteration of thermo, data was automatically looked up in databases and there was no way to replace that data. Thermo now keeps data and algorithms completely separate. This has also been very helpful to make unit tests that do not change their results.
There are five places to configure the flash and phase infrastructure:
Constant data about chemicals, like melting point or boiling point or UNIFAC groups. This information needs to be put into an immutable
ChemicalConstantsPackage
object.Temperature-dependent data, like Antoine coefficients, Tait pressure-dependent volume parameters, or Laliberte electrolyte viscosity interaction parameters. These are stored in
TDependentProperty
,TPDependentProperty
, andMixtureProperty
objects. More information about configuring those to provide the desired properties can be found in property objects tutorial; this tutorial assumes you have already configured them as desired. These many objects are added to anPropertyCorrelationsPackage
object before being provided to the flash algorithms.Phase-specific parameters that are not general and depend on a specific phase configuration for meaning; such as a volume translation coefficient or a binary interaction parameter. This information is provided when configuring each
Phase
.Information about bulk mixing rules or bulk property calculation methods; these don’t have true thermodynamic definitions, and are configurable in the
BulkSettings
object.Settings of the
Flash
object; ideally no configuration would be required there. In some cases it might be useful to lower the tolerances or change an algorithm.
This tutorial covers the first two places, ChemicalConstantsPackage
and PropertyCorrelationsPackage
.
ChemicalConstantsPackage Object¶
Creating ChemicalConstantsPackage Objects¶
A ChemicalConstantsPackage
can be created by specifying the known constant values of each chemical. All values are technically optional; the requirements of each Flash
algorithm are different, but a minimum suggested amount is names, CASs, MWs, Tcs, Pcs, omegas, Tbs, and atomss. The list of all accepted properties can be found here
.
>>> from thermo import ChemicalConstantsPackage, PropertyCorrelationsPackage
>>> constants = ChemicalConstantsPackage(MWs=[18.01528, 106.165, 106.165, 106.165], names=['water', 'o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.344, 0.3118, 0.324, 0.331], Pcs=[22048320.0, 3732000.0, 3511000.0, 3541000.0], Tcs=[647.14, 630.3, 616.2, 617.0])
Using ChemicalConstantsPackage Objects¶
Once created, all properties, even missing ones, can be accessed as attributes using the same names as required by the constructor:
>>> constants.MWs
[18.01528, 106.165, 106.165, 106.165]
>>> constants.Vml_STPs
[None, None, None, None]
It is the intention for these ChemicalConstantsPackage
to be immutable. Python doesn’t easily allow this to be enforced, but unexpected behavior will probably result if they are edited. If different properties are desired; create new ChemicalConstantsPackage
objects.
The __repr__
of the ChemicalConstantsPackage
object returns a representation of the object that can be used to reconstruct it:
>>> constants
ChemicalConstantsPackage(MWs=[18.01528, 106.165, 106.165, 106.165], names=['water', 'o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.344, 0.3118, 0.324, 0.331], Pcs=[22048320.0, 3732000.0, 3511000.0, 3541000.0], Tcs=[647.14, 630.3, 616.2, 617.0])
>>> hash(eval(constants.__repr__())) == hash(constants)
True
Creating Smaller ChemicalConstantsPackage Objects¶
It is possible to create a new, smaller ChemicalConstantsPackage
with fewer components by using the subset
method, which accepts either indexes or slices and returns a new object:
>>> constants.subset([0, 1])
ChemicalConstantsPackage(MWs=[18.01528, 106.165], names=['water', 'o-xylene'], omegas=[0.344, 0.3118], Pcs=[22048320.0, 3732000.0], Tcs=[647.14, 630.3])
>>> constants.subset(slice(1,3))
ChemicalConstantsPackage(MWs=[106.165, 106.165], names=['o-xylene', 'p-xylene'], omegas=[0.3118, 0.324], Pcs=[3732000.0, 3511000.0], Tcs=[630.3, 616.2])
>>> constants.subset([0])
ChemicalConstantsPackage(MWs=[18.01528], names=['water'], omegas=[0.344], Pcs=[22048320.0], Tcs=[647.14])
It is also possible to reduce the number of properties set with the subset methods:
>>> constants.subset([1, 3], properties=('names', 'MWs'))
ChemicalConstantsPackage(MWs=[106.165, 106.165], names=['o-xylene', 'm-xylene'])
Adding or Replacing Constants¶
It is possible to create a new ChemicalConstantsPackage
with added properties and/or replacing the old properties, from an existing object. This is helpful if better values for select properties are known. The with_new_constants
method does this.
>>> constants.with_new_constants(Tcs=[650.0, 630.0, 620.0, 620.0], Tms=[20.0, 100.0, 50.0, 12.3])
ChemicalConstantsPackage(MWs=[18.01528, 106.165, 106.165, 106.165], names=['water', 'o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.344, 0.3118, 0.324, 0.331], Pcs=[22048320.0, 3732000.0, 3511000.0, 3541000.0], Tcs=[650.0, 630.0, 620.0, 620.0], Tms=[20.0, 100.0, 50.0, 12.3])
Creating ChemicalConstantsPackage Objects from chemicals¶
A convenience method exists to load these constants from a different data files exists. Some values for all properties are available; not all compounds have all properties.
>>> obj = ChemicalConstantsPackage.constants_from_IDs(['methanol', 'ethanol', 'isopropanol'])
>>> obj.Tbs
[337.65, 351.39, 355.36]
When working with a fixed set of components, it may be a good idea to take this generated package, select only those properties being used, convert it to a string, and then embed that new object in a program. This will remove the need to load various data files, and if chemicals updates data files, different results won’t be obtained from your constants package.
>>> small_obj = obj.subset(properties=('names', 'CASs', 'MWs', 'Tcs', 'Pcs', 'omegas', 'Tbs', 'Tms', 'atomss'))
>>> small_obj
ChemicalConstantsPackage(atomss=[{'C': 1, 'H': 4, 'O': 1}, {'C': 2, 'H': 6, 'O': 1}, {'C': 3, 'H': 8, 'O': 1}], CASs=['67-56-1', '64-17-5', '67-63-0'], MWs=[32.04186, 46.06844, 60.09502], names=['methanol', 'ethanol', 'isopropanol'], omegas=[0.559, 0.635, 0.665], Pcs=[8084000.0, 6137000.0, 4764000.0], Tbs=[337.65, 351.39, 355.36], Tcs=[512.5, 514.0, 508.3], Tms=[175.15, 159.05, 183.65])
Once the object is printed, the generated text can be copy/pasted as valid Python into a program:
>>> obj = ChemicalConstantsPackage(atomss=[{'C': 1, 'H': 4, 'O': 1}, {'C': 2, 'H': 6, 'O': 1}, {'C': 3, 'H': 8, 'O': 1}], CASs=['67-56-1', '64-17-5', '67-63-0'], MWs=[32.04186, 46.06844, 60.09502], names=['methanol', 'ethanol', 'isopropanol'], omegas=[0.5589999999999999, 0.635, 0.665], Pcs=[8084000.0, 6137000.0, 4764000.0], Tbs=[337.65, 351.39, 355.36], Tcs=[512.5, 514.0, 508.3], Tms=[175.15, 159.05, 183.65])
Warning
chemicals is a project with a focus on collecting data and correlations from various sources. In no way is it a project to critically evaluate these and provide recommendations. You are strongly encouraged to check values from it and modify them if you want different values. If you believe there is a value which has a typographical error please report it to the chemicals project. If data is missing or not as accuracte as you would like, and you know of a better method or source, new methods and sources can be added to chemicals fairly easily once the data entry is complete. It is not feasible to add individual components, so please submit a complete table of data from the source.
Storing and Loading ChemicalConstantsPackage Objects¶
For larger applications with many components, it is not as feasible to convert the ChemicalConstantsPackage
to a string and embed it in a program. For that application, the object can be converted back and forth from JSON:
>>> obj = ChemicalConstantsPackage(MWs=[106.165, 106.165], names=['o-xylene', 'm-xylene'])
>>> constants = ChemicalConstantsPackage(MWs=[18.01528, 106.165], names=['water', 'm-xylene'])
>>> string = constants.as_json()
>>> new_constants = ChemicalConstantsPackage.from_json(string)
>>> hash(new_constants) == hash(constants)
True
PropertyCorrelationsPackage¶
Introduction to Phase and Flash Calculations¶
The framework for performing phase and flash calculations is designed around the following principles:
Immutability
Calculations are completely independent from any databases or lookups - every input must be provided as input
Default to general-purpose algorithms that make no assumptions about specific systems
Inclusion of separate flashes algorithms wherever faster algorithms can be used for specific cases
Allow options to restart a flash from a nearby previously calculated result, with options to skip checking the result for stability
Use very tight tolerances on all calculations
Expose all constants used by algorithms
Phase Objects¶
A phase is designed to have a single state at any time, and contain all the information needed to compute phase-specific properties.
Phases should always be initialized at a specific molar composition zs, T and P; and new phase objects at different conditions should be created from the existing ones with the Phase.to
method (a little faster than creating them from scratch). That method also allows the new state to be set from any two of T, P, or V. When working in the T and P domain only, the Phase.to_TP_zs
method is a little faster.
Phases are designed to be able to calculate every thermodynamic property. T and P are always attributes of the phase, but all other properties are functions that need to be called. Some examples of these properties are V
, H
, S
, Cp
, dP_dT
, d2P_dV2
, fugacities
, lnphis
, dlnphis_dT
, and dlnphis_dP
.
If a system is already known to be single-phase, the phase framework can be used directly without performing flash calculations. This may offer a speed boost in some applications.
Available Phases¶
Although the underlying equations of state often don’t distinguish between liquid or vapor phase, it was convenient to create separate phase objects designed to hold gas, liquid, and solid phases separately.
The following phases can represent both a liquid and a vapor state. Their class is not a true indication that their properties are liquid or gas.
Cubic equations of state -
CEOSLiquid
andCEOSGas
IAPWS-95 Water and Steam -
IAPWS95Liquid
andIAPWS95Gas
Wrapper objects for CoolProp’s Helmholtz EOSs -
CoolPropLiquid
andCoolPropGas
The following phase objects can only represent a gas phase:
Ideal-gas law -
IdealGas
High-accuracy properties of dry air -
DryAirLemmon
The following phase objects can only represent a liquid phase:
Ideal-liquid and/or activity coefficient models -
GibbsExcessLiquid
Serialization¶
All phase models offer a as_json
method and a from_json
to serialize the object state for transport over a network, storing to disk, and passing data between processes.
>>> import json
>>> from scipy.constants import R
>>> from thermo import HeatCapacityGas, IdealGas, Phase
>>> HeatCapacityGases = [HeatCapacityGas(poly_fit=(50.0, 1000.0, [R*-9.9e-13, R*1.57e-09, R*7e-08, R*-0.000261, R*3.539])), HeatCapacityGas(poly_fit=(50.0, 1000.0, [R*1.79e-12, R*-6e-09, R*6.58e-06, R*-0.001794, R*3.63]))]
>>> phase = IdealGas(T=300, P=1e5, zs=[.79, .21], HeatCapacityGases=HeatCapacityGases)
>>> json_stuff = json.dumps(phase.as_json())
>>> new_phase = Phase.from_json(json.loads(json_stuff))
>>> assert new_phase == phase
Other json libraries can be used besides the standard json library by design.
Storing and recreating objects with Python’s pickle.dumps
library is also tested; this can be faster than using JSON at the cost of being binary data.
Hashing¶
All models have a __hash__
method that can be used to compare different phases to see if they are absolutely identical (including which values have been calculated already).
They also have a model_hash
method that can be used to compare different phases to see if they have identical model parameters.
They also have a state_hash
method that can be used to compare different phases to see if they have identical temperature, composition, and model parameters.
Flashes with Pure Compounds¶
Pure components are really nice to work with because they have nice boundaries between each state, and the mole fraction is always 1; there is no composition dependence. There is a separate flash interfaces for pure components. These flashes are very mature and should be quite reliable.
Vapor-Liquid Cubic Equation Of State Example¶
The following example illustrates some of the types of flashes supported using the component methanol, the stated critical properties, a heat capacity correlation from Poling et. al., and the Peng-Robinson equation of state.
Obtain a heat capacity object, and select a source:
>>> from thermo.heat_capacity import POLING_POLY
>>> CpObj = HeatCapacityGas(CASRN='67-56-1')
>>> CpObj.method = POLING_POLY
>>> CpObj.POLING_coefs # Show the coefficients
[4.714, -0.006986, 4.211e-05, -4.443e-08, 1.535e-11]
>>> HeatCapacityGases = [CpObj]
Create a ChemicalConstantsPackage
object which holds constant properties of the object, using a minimum of values:
>>> from thermo import ChemicalConstantsPackage, PropertyCorrelationsPackage, PRMIX, SRKMIX, CEOSLiquid, CEOSGas, FlashPureVLS
>>> constants = ChemicalConstantsPackage(Tcs=[512.5], Pcs=[8084000.0], omegas=[0.559], MWs=[32.04186], CASs=['67-56-1'])
Create a PropertyCorrelationsPackage
object which holds temperature-dependent property objects, also setting skip_missing to True so no database lookups are performed:
>>> correlations = PropertyCorrelationsPackage(constants, HeatCapacityGases=HeatCapacityGases, skip_missing=True)
Create liquid and gas cubic phase objects using the Peng-Robinson equation of state
:
>>> eos_kwargs = dict(Tcs=constants.Tcs, Pcs=constants.Pcs, omegas=constants.omegas)
>>> liquid = CEOSLiquid(PRMIX, HeatCapacityGases=HeatCapacityGases, eos_kwargs=eos_kwargs)
>>> gas = CEOSGas(PRMIX, HeatCapacityGases=HeatCapacityGases, eos_kwargs=eos_kwargs)
Create the Flash object FlashPureVLS
for pure components:
>>> flasher = FlashPureVLS(constants, correlations, gas=gas, liquids=[liquid], solids=[])
Do a T-P flash:
>>> res = flasher.flash(T=300, P=1e5)
>>> res.phase, res.liquid0
('L', CEOSLiquid(eos_class=PRMIX, eos_kwargs={"Tcs": [512.5], "Pcs": [8084000.0], "omegas": [0.559]}, HeatCapacityGases=[HeatCapacityGas(CASRN="67-56-1", extrapolation="linear", method="POLING_POLY")], T=300.0, P=100000.0, zs=[1.0]))
Do a temperature and vapor-fraction flash:
>>> res = flasher.flash(T=300, VF=.3)
Do a pressure and vapor-fraction flash:
>>> res = flasher.flash(P=1e5, VF=.5)
Do a pressure and enthalpy flash:
>>> res = flasher.flash(P=1e5, H=100)
Do a pressure and entropy flash:
>>> res = flasher.flash(P=1e5, S=30)
Do a temperature and entropy flash:
>>> res = flasher.flash(T=400.0, S=30)
Do a temperature and enthalpy flash:
>>> res = flasher.flash(T=400.0, H=1000)
Do a volume and internal energy flash:
>>> res = flasher.flash(V=1e-4, U=1000)
As you can see, the interface is convenient and supports most types of flashes. In fact, the algorithms are generic; any of H, S, U, and can be combined with any combination of T, P, and V. Although most of the flashes shown above except TS and TH are usually well behaved, depending on the EOS combination there may be multiple solutions. No real guarantees can be made about which solution will be returned in those cases.
Flashes with two of H, S, and U are not implemented at present.
It is not necessary to use the same phase model for liquid and gas phases; the below example shows a flash switching the gas phase model to SRK.
>>> SRK_gas = CEOSGas(SRKMIX, HeatCapacityGases=HeatCapacityGases, eos_kwargs=eos_kwargs)
>>> flasher_inconsistent = FlashPureVLS(constants, correlations, gas=SRK_gas, liquids=[liquid], solids=[])
>>> res = flasher_inconsistent.flash(T=400.0, VF=1)
Choosing to use an inconsistent model will slow down many calculations as more checks are required; and some flashes may have issues with discontinuities in some conditions, and simply a lack of solution in other conditions.
Vapor-Liquid Steam Example¶
The IAPWS-95 standard is implemented and available for easy use:
>>> from thermo import FlashPureVLS, IAPWS95Liquid, IAPWS95Gas, iapws_constants, iapws_correlations
>>> liquid = IAPWS95Liquid(T=300, P=1e5, zs=[1])
>>> gas = IAPWS95Gas(T=300, P=1e5, zs=[1])
>>> flasher = FlashPureVLS(iapws_constants, iapws_correlations, gas, [liquid], [])
>>> PT = flasher.flash(T=800.0, P=1e7)
>>> PT.rho_mass()
29.1071839176
>>> print(flasher.flash(T=600, VF=.5))
<EquilibriumState, T=600.0000, P=12344824.3572, zs=[1.0], betas=[0.5, 0.5], phases=[<IAPWS95Gas, T=600 K, P=1.23448e+07 Pa>, <IAPWS95Liquid, T=600 K, P=1.23448e+07 Pa>]>
>>> print(flasher.flash(T=600.0, H=50802))
<EquilibriumState, T=600.0000, P=10000469.1288, zs=[1.0], betas=[1.0], phases=[<IAPWS95Gas, T=600 K, P=1.00005e+07 Pa>]>
>>> print(flasher.flash(P=1e7, S=104.))
<EquilibriumState, T=599.6790, P=10000000.0000, zs=[1.0], betas=[1.0], phases=[<IAPWS95Gas, T=599.679 K, P=1e+07 Pa>]>
>>> print(flasher.flash(V=.00061, U=55850))
<EquilibriumState, T=800.5922, P=10144789.0899, zs=[1.0], betas=[1.0], phases=[<IAPWS95Gas, T=800.592 K, P=1.01448e+07 Pa>]>
Not all flash calculations have been fully optimized, but the basic flashes are quite fast.
Details of GibbsExcessLiquid Phase Model¶
There are lots of options that get called “ideal”. The GibbsExcessLiquid object implements many of them, which means the configuration is complicated and the defaults may not act as expected.
API Reference¶
Activity Coefficients (thermo.activity)¶
This module contains a base class GibbsExcess
for handling activity
coefficient based
models. The design is for a sub-class to provide the minimum possible number of
derivatives of Gibbs energy, and for this base class to provide the rest of the
methods. An ideal-liquid class with no excess Gibbs energy
IdealSolution
is also available.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Base Class¶
- class thermo.activity.GibbsExcess[source]¶
Bases:
object
Class for representing an activity coefficient model. While these are typically presented as tools to compute activity coefficients, in truth they are excess Gibbs energy models and activity coefficients are just one derived aspect of them.
This class does not implement any activity coefficient models itself; it must be subclassed by another model. All properties are derived with the CAS SymPy, not relying on any derivations previously published, and checked numerically for consistency.
Different subclasses have different parameter requirements for initialization;
IdealSolution
is available as a simplest model with activity coefficients of 1 to show what needs to be implemented in subclasses. It is also intended subclasses implement the method to_T_xs, which creates a new object at the specified temperature and composition but with the same parameters.These objects are intended to lazy-calculate properties as much as possible, and for the temperature and composition of an object to be immutable.
Methods
CpE
()Calculate and return the first temperature derivative of excess enthalpy of a liquid phase using an activity coefficient model.
HE
()Calculate and return the excess entropy of a liquid phase using an activity coefficient model.
SE
()Calculates the excess entropy of a liquid phase using an activity coefficient model.
as_json
()Method to create a JSON-friendly representation of the Gibbs Excess model which can be stored, and reloaded later.
Calculate and return the mole number derivative of the first temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
Calculate and return the partial mole number derivative of the first temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
Calculate and return the second partial mole number derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
dGE_dns
()Calculate and return the mole number derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
dHE_dT
()Calculate and return the first temperature derivative of excess enthalpy of a liquid phase using an activity coefficient model.
dHE_dns
()Calculate and return the mole number derivative of excess enthalpy of a liquid phase using an activity coefficient model.
dHE_dxs
()Calculate and return the mole fraction derivative of excess enthalpy of a liquid phase using an activity coefficient model.
dSE_dT
()Calculate and return the first temperature derivative of excess entropy of a liquid phase using an activity coefficient model.
dSE_dns
()Calculate and return the mole number derivative of excess entropy of a liquid phase using an activity coefficient model.
dSE_dxs
()Calculate and return the mole fraction derivative of excess entropy of a liquid phase using an activity coefficient model.
Calculate and return the temperature derivatives of activity coefficients of a liquid phase using an activity coefficient model.
Calculate and return the mole number derivative of activity coefficients of a liquid phase using an activity coefficient model.
dnGE_dns
()Calculate and return the partial mole number derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
dnHE_dns
()Calculate and return the partial mole number derivative of excess enthalpy of a liquid phase using an activity coefficient model.
dnSE_dns
()Calculate and return the partial mole number derivative of excess entropy of a liquid phase using an activity coefficient model.
from_json
(json_repr)Method to create a Gibbs Excess model from a JSON-friendly serialization of another Gibbs Excess model.
gammas
()Calculate and return the activity coefficients of a liquid phase using an activity coefficient model.
Calculate and return the infinite dilution activity coefficients of each component.
Basic method to calculate a hash of the non-state parts of the model This is useful for comparing to models to determine if they are the same, i.e. in a VLL flash it is important to know if both liquids have the same model.
Basic method to calculate a hash of the state of the model and its model parameters.
- CpE()¶
Calculate and return the first temperature derivative of excess enthalpy of a liquid phase using an activity coefficient model.
\[\frac{\partial h^E}{\partial T} = -T \frac{\partial^2 g^E} {\partial T^2} \]- Returns
- dHE_dTfloat
First temperature derivative of excess enthalpy of the liquid phase, [J/mol/K]
- HE()[source]¶
Calculate and return the excess entropy of a liquid phase using an activity coefficient model.
\[h^E = -T \frac{\partial g^E}{\partial T} + g^E \]- Returns
- HEfloat
Excess enthalpy of the liquid phase, [J/mol]
- SE()[source]¶
Calculates the excess entropy of a liquid phase using an activity coefficient model.
\[s^E = \frac{h^E - g^E}{T} \]- Returns
- SEfloat
Excess entropy of the liquid phase, [J/mol/K]
Notes
Note also the relationship of the expressions for partial excess entropy:
\[S_i^E = -R\left(T \frac{\partial \ln \gamma_i}{\partial T} + \ln \gamma_i\right) \]
- __hash__()[source]¶
Method to calculate and return a hash representing the exact state of the object. This includes T, xs, the model class, and which values have already been calculated.
- Returns
- hashint
Hash of the object, [-]
- __repr__()[source]¶
Method to create a string representation of the state of the model. Included is T, xs, and all constants necessary to create the model. This can be passed into
exec
to re-create the model. Note that parsing strings like this can be slow.- Returns
- reprstr
String representation of the object, [-]
Examples
>>> IdealSolution(T=300.0, xs=[.1, .2, .3, .4]) IdealSolution(T=300.0, xs=[.1, .2, .3, .4])
- as_json()[source]¶
Method to create a JSON-friendly representation of the Gibbs Excess model which can be stored, and reloaded later.
- Returns
- json_reprdict
JSON-friendly representation, [-]
Examples
>>> import json >>> model = IdealSolution(T=300.0, xs=[.1, .2, .3, .4]) >>> json_view = model.as_json() >>> json_str = json.dumps(json_view) >>> assert type(json_str) is str >>> model_copy = IdealSolution.from_json(json.loads(json_str)) >>> assert model_copy == model
- d2GE_dTdns()[source]¶
Calculate and return the mole number derivative of the first temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
\[\frac{\partial^2 G^E}{\partial n_i \partial T} \]- Returns
- d2GE_dTdnslist[float]
First mole number derivative of the temperature derivative of excess Gibbs entropy of the liquid phase, [J/(mol^2*K)]
- d2nGE_dTdns()[source]¶
Calculate and return the partial mole number derivative of the first temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
\[\frac{\partial^2 n G^E}{\partial n_i \partial T} \]- Returns
- d2nGE_dTdnslist[float]
First partial mole number derivative of the temperature derivative of excess Gibbs entropy of the liquid phase, [J/(mol*K)]
- d2nGE_dninjs()[source]¶
Calculate and return the second partial mole number derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
\[\frac{\partial^2 n G^E}{\partial n_i \partial n_i} \]- Returns
- d2nGE_dninjslist[list[float]]
Second partial mole number derivative of excess Gibbs energy of a liquid phase, [J/(mol^2)]
- dGE_dns()[source]¶
Calculate and return the mole number derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
\[\frac{\partial G^E}{\partial n_i} \]- Returns
- dGE_dnslist[float]
First mole number derivative of excess Gibbs entropy of the liquid phase, [J/(mol^2*K)]
- dHE_dT()[source]¶
Calculate and return the first temperature derivative of excess enthalpy of a liquid phase using an activity coefficient model.
\[\frac{\partial h^E}{\partial T} = -T \frac{\partial^2 g^E} {\partial T^2} \]- Returns
- dHE_dTfloat
First temperature derivative of excess enthalpy of the liquid phase, [J/mol/K]
- dHE_dns()[source]¶
Calculate and return the mole number derivative of excess enthalpy of a liquid phase using an activity coefficient model.
\[\frac{\partial h^E}{\partial n_i} \]- Returns
- dHE_dnslist[float]
First mole number derivative of excess enthalpy of the liquid phase, [J/mol^2]
- dHE_dxs()[source]¶
Calculate and return the mole fraction derivative of excess enthalpy of a liquid phase using an activity coefficient model.
\[\frac{\partial h^E}{\partial x_i} = -T \frac{\partial^2 g^E} {\partial T \partial x_i} + \frac{\partial g^E}{\partial x_i} \]- Returns
- dHE_dxslist[float]
First mole fraction derivative of excess enthalpy of the liquid phase, [J/mol]
- dSE_dT()[source]¶
Calculate and return the first temperature derivative of excess entropy of a liquid phase using an activity coefficient model.
\[\frac{\partial s^E}{\partial T} = \frac{1}{T} \left(\frac{-\partial g^E}{\partial T} + \frac{\partial h^E}{\partial T} - \frac{(G + H)}{T}\right) \]- Returns
- dSE_dTfloat
First temperature derivative of excess entropy of the liquid phase, [J/mol/K]
- dSE_dns()[source]¶
Calculate and return the mole number derivative of excess entropy of a liquid phase using an activity coefficient model.
\[\frac{\partial S^E}{\partial n_i} \]- Returns
- dSE_dnslist[float]
First mole number derivative of excess entropy of the liquid phase, [J/(mol^2*K)]
- dSE_dxs()[source]¶
Calculate and return the mole fraction derivative of excess entropy of a liquid phase using an activity coefficient model.
\[\frac{\partial S^E}{\partial x_i} = \frac{1}{T}\left( \frac{\partial h^E} {\partial x_i} - \frac{\partial g^E}{\partial x_i}\right) = -\frac{\partial^2 g^E}{\partial x_i \partial T} \]- Returns
- dSE_dxslist[float]
First mole fraction derivative of excess entropy of the liquid phase, [J/(mol*K)]
- dgammas_dT()[source]¶
Calculate and return the temperature derivatives of activity coefficients of a liquid phase using an activity coefficient model.
\[\frac{\partial \gamma_i}{\partial T} = \left(\frac{\frac{\partial^2 n G^E}{\partial T \partial n_i}}{RT} - \frac{{\frac{\partial n_i G^E}{\partial n_i }}}{RT^2}\right) \exp\left(\frac{\frac{\partial n_i G^E}{\partial n_i }}{RT}\right) \]- Returns
- dgammas_dTlist[float]
Temperature derivatives of activity coefficients, [1/K]
- dgammas_dns()[source]¶
Calculate and return the mole number derivative of activity coefficients of a liquid phase using an activity coefficient model.
\[\frac{\partial \gamma_i}{\partial n_i} = \gamma_i \left(\frac{\frac{\partial^2 G^E}{\partial x_i \partial x_j}}{RT}\right) \]- Returns
- dgammas_dnslist[list[float]]
Mole number derivatives of activity coefficients, [1/mol]
- dnGE_dns()[source]¶
Calculate and return the partial mole number derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
\[\frac{\partial n G^E}{\partial n_i} \]- Returns
- dnGE_dnslist[float]
First partial mole number derivative of excess Gibbs entropy of the liquid phase, [J/(mol)]
- dnHE_dns()[source]¶
Calculate and return the partial mole number derivative of excess enthalpy of a liquid phase using an activity coefficient model.
\[\frac{\partial n h^E}{\partial n_i} \]- Returns
- dnHE_dnslist[float]
First partial mole number derivative of excess enthalpy of the liquid phase, [J/mol]
- dnSE_dns()[source]¶
Calculate and return the partial mole number derivative of excess entropy of a liquid phase using an activity coefficient model.
\[\frac{\partial n S^E}{\partial n_i} \]- Returns
- dnSE_dnslist[float]
First partial mole number derivative of excess entropy of the liquid phase, [J/(mol*K)]
- classmethod from_json(json_repr)[source]¶
Method to create a Gibbs Excess model from a JSON-friendly serialization of another Gibbs Excess model.
- Parameters
- json_reprdict
JSON-friendly representation, [-]
- Returns
- model
GibbsExcess
Newly created object from the json serialization, [-]
- model
Notes
It is important that the input string be in the same format as that created by
GibbsExcess.as_json
.Examples
>>> model = IdealSolution(T=300.0, xs=[.1, .2, .3, .4]) >>> json_view = model.as_json() >>> new_model = IdealSolution.from_json(json_view) >>> assert model == new_model
- gammas()[source]¶
Calculate and return the activity coefficients of a liquid phase using an activity coefficient model.
\[\gamma_i = \exp\left(\frac{\frac{\partial n_i G^E}{\partial n_i }}{RT}\right) \]- Returns
- gammaslist[float]
Activity coefficients, [-]
- gammas_infinite_dilution()[source]¶
Calculate and return the infinite dilution activity coefficients of each component.
- Returns
- gammas_infinitelist[float]
Infinite dilution activity coefficients, [-]
Notes
The algorithm is as follows. For each component, set its composition to zero. Normalize the remaining compositions to 1. Create a new object with that composition, and calculate the activity coefficient of the component whose concentration was set to zero.
- model_hash()[source]¶
Basic method to calculate a hash of the non-state parts of the model This is useful for comparing to models to determine if they are the same, i.e. in a VLL flash it is important to know if both liquids have the same model.
Note that the hashes should only be compared on the same system running in the same process!
- Returns
- model_hashint
Hash of the object’s model parameters, [-]
Ideal Liquid Class¶
- class thermo.activity.IdealSolution(T=None, xs=None)[source]¶
Bases:
thermo.activity.GibbsExcess
Class for representing an ideal liquid, with no excess gibbs energy and thus activity coefficients of 1.
- Parameters
- Tfloat
Temperature, [K]
- xslist[float]
Mole fractions, [-]
Examples
>>> model = IdealSolution(T=300.0, xs=[.1, .2, .3, .4]) >>> model.GE() 0.0 >>> model.gammas() [1.0, 1.0, 1.0, 1.0] >>> model.dgammas_dT() [0.0, 0.0, 0.0, 0.0]
- Attributes
- Tfloat
Temperature, [K]
- xslist[float]
Mole fractions, [-]
Methods
GE
()Calculate and return the excess Gibbs energy of a liquid phase using an activity coefficient model.
d2GE_dT2
()Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy of an ideal liquid.
Calculate and return the second mole fraction derivatives of excess Gibbs energy of an ideal liquid.
d3GE_dT3
()Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
Calculate and return the third mole fraction derivatives of excess Gibbs energy of an ideal liquid.
dGE_dT
()Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
dGE_dxs
()Calculate and return the mole fraction derivatives of excess Gibbs energy of an ideal liquid.
to_T_xs
(T, xs)Method to construct a new
IdealSolution
instance at temperature T, and mole fractions xs with the same parameters as the existing object.- GE()[source]¶
Calculate and return the excess Gibbs energy of a liquid phase using an activity coefficient model.
\[g^E = 0 \]- Returns
- GEfloat
Excess Gibbs energy of an ideal liquid, [J/mol]
- d2GE_dT2()[source]¶
Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
\[\frac{\partial^2 g^E}{\partial T^2} = 0 \]- Returns
- d2GE_dT2float
Second temperature derivative of excess Gibbs energy of an ideal liquid, [J/(mol*K^2)]
- d2GE_dTdxs()[source]¶
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy of an ideal liquid.
\[\frac{\partial^2 g^E}{\partial x_i \partial T} = 0 \]- Returns
- d2GE_dTdxslist[float]
Temperature derivative of mole fraction derivatives of excess Gibbs energy of an ideal liquid, [J/(mol*K)]
- d2GE_dxixjs()[source]¶
Calculate and return the second mole fraction derivatives of excess Gibbs energy of an ideal liquid.
\[\frac{\partial^2 g^E}{\partial x_i \partial x_j} = 0 \]- Returns
- d2GE_dxixjslist[list[float]]
Second mole fraction derivatives of excess Gibbs energy of an ideal liquid, [J/mol]
- d3GE_dT3()[source]¶
Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
\[\frac{\partial^3 g^E}{\partial T^3} = 0 \]- Returns
- d3GE_dT3float
Third temperature derivative of excess Gibbs energy of an ideal liquid, [J/(mol*K^3)]
- d3GE_dxixjxks()[source]¶
Calculate and return the third mole fraction derivatives of excess Gibbs energy of an ideal liquid.
\[\frac{\partial^3 g^E}{\partial x_i \partial x_j \partial x_k} = 0 \]- Returns
- d3GE_dxixjxkslist[list[list[float]]]
Third mole fraction derivatives of excess Gibbs energy of an ideal liquid, [J/mol]
- dGE_dT()[source]¶
Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase using an activity coefficient model.
\[\frac{\partial g^E}{\partial T} = 0 \]- Returns
- dGE_dTfloat
First temperature derivative of excess Gibbs energy of an ideal liquid, [J/(mol*K)]
- dGE_dxs()[source]¶
Calculate and return the mole fraction derivatives of excess Gibbs energy of an ideal liquid.
\[\frac{\partial g^E}{\partial x_i} = 0 \]- Returns
- dGE_dxslist[float]
Mole fraction derivatives of excess Gibbs energy of an ideal liquid, [J/mol]
- to_T_xs(T, xs)[source]¶
Method to construct a new
IdealSolution
instance at temperature T, and mole fractions xs with the same parameters as the existing object.- Parameters
- Tfloat
Temperature, [K]
- xslist[float]
Mole fractions of each component, [-]
- Returns
- objIdealSolution
New
IdealSolution
object at the specified conditions [-]
Examples
>>> p = IdealSolution(T=300.0, xs=[.1, .2, .3, .4]) >>> p.to_T_xs(T=500.0, xs=[.25, .25, .25, .25]) IdealSolution(T=500.0, xs=[0.25, 0.25, 0.25, 0.25])
Notes¶
Excellent references for working with activity coefficient models are [1] and [2].
References¶
Bulk Phases (thermo.bulk)¶
This module contains a phase wrapper for obtaining properties of a pseudo-phase made of multiple other phases. This is useful in the context of multiple liquid phases; or multiple solid phases; or looking at all the phases together.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Bulk Class¶
- class thermo.bulk.Bulk(T, P, zs, phases, phase_fractions, phase_bulk=None)[source]¶
Bases:
thermo.phases.phase.Phase
Class to encapsulate multiple
Phase
objects and provide a unified interface for obtaining properties from a group of phases.This class exists for three purposes:
Providing a common interface for obtaining properties like Cp - whether there is one phase or 100, calling Cp on the bulk will retrieve that value.
Retrieving “bulk” properties that do make sense to be calculated for a combination of phases together.
Allowing configurable estimations of non-bulk properties like isothermal compressibility or speed of sound for the group of phases together.
- Parameters
- Tfloat
Temperature of the bulk, [K]
- Pfloat
Pressure of the bulk, [Pa]
- zslist[float]
Mole fractions of the bulk, [-]
- phaseslist[
Phase
] Phase objects, [-]
- phase_fractionslist[float]
Molar fractions of each phase, [-]
- phase_bulkstr, optional
None to represent a bulk of all present phases; ‘l’ to represent a bulk of only liquid phases; s to represent a bulk of only solid phases, [-]
Notes
Please think carefully when retrieving a property of the bulk. If there are two liquid phases in a bulk, and a single viscosity value is retrieved, can that be used directly for a single phase pressure drop calculation? Not with any theoretical consistency, that’s for sure.
- Attributes
beta
Phase fraction of the bulk phase.
betas_mass
Method to calculate and return the mass fraction of all of the phases in the bulk.
betas_volume
Method to calculate and return the volume fraction of all of the phases in the bulk.
Methods
Cp
()Method to calculate and return the constant-temperature and constant phase-fraction heat capacity of the bulk phase.
Method to calculate and return the ideal-gas heat capacity of the phase.
H
()Method to calculate and return the constant-temperature and constant phase-fraction enthalpy of the bulk phase.
Method to calculate and return the ideal-gas enthalpy of the phase.
Method to calculate and return the constant-temperature and constant phase-fraction reactive enthalpy of the bulk phase.
Method to calculate and return the Joule-Thomson coefficient of the bulk according to the selected calculation methodology.
MW
()Method to calculate and return the molecular weight of the bulk phase.
Pmc
()Method to calculate and return the mechanical critical pressure of the phase.
S
()Method to calculate and return the constant-temperature and constant phase-fraction entropy of the bulk phase.
Method to calculate and return the ideal-gas entropy of the phase.
Method to calculate and return the constant-temperature and constant phase-fraction reactive entropy of the bulk phase.
Tmc
()Method to calculate and return the mechanical critical temperature of the phase.
V
()Method to calculate and return the molar volume of the bulk phase.
V_iter
([force])Method to calculate and return the molar volume of the bulk phase, with precision suitable for a TV calculation to calculate a matching pressure.
Vmc
()Method to calculate and return the mechanical critical volume of the phase.
Zmc
()Method to calculate and return the mechanical critical compressibility of the phase.
d2P_dT2
()Method to calculate and return the second temperature derivative of pressure of the bulk according to the selected calculation methodology.
Method to calculate and return the second constant-volume derivative of pressure with respect to temperature of the bulk phase, at constant phase fractions and phase compositions.
d2P_dTdV
()Method to calculate and return the second derivative of pressure with respect to temperature and volume of the bulk according to the selected calculation methodology.
Method to calculate and return the second derivative of pressure with respect to volume and temperature of the bulk phase, at constant phase fractions and phase compositions.
d2P_dV2
()Method to calculate and return the second volume derivative of pressure of the bulk according to the selected calculation methodology.
Method to calculate and return the constant-temperature second derivative of pressure with respect to volume of the bulk phase, at constant phase fractions and phase compositions.
dA_dP
()Method to calculate and return the constant-temperature pressure derivative of Helmholtz energy.
dA_dT
()Method to calculate and return the constant-pressure temperature derivative of Helmholtz energy.
dG_dP
()Method to calculate and return the constant-temperature pressure derivative of Gibbs free energy.
dG_dT
()Method to calculate and return the constant-pressure temperature derivative of Gibbs free energy.
dP_dT
()Method to calculate and return the first temperature derivative of pressure of the bulk according to the selected calculation methodology.
Method to calculate and return the constant-volume derivative of pressure with respect to temperature of the bulk phase, at constant phase fractions and phase compositions.
dP_dV
()Method to calculate and return the first volume derivative of pressure of the bulk according to the selected calculation methodology.
Method to calculate and return the constant-temperature derivative of pressure with respect to volume of the bulk phase, at constant phase fractions and phase compositions.
dU_dP
()Method to calculate and return the constant-temperature pressure derivative of internal energy.
dU_dT
()Method to calculate and return the constant-pressure temperature derivative of internal energy.
Method to calculate and return the isobatic expansion coefficient of the bulk according to the selected calculation methodology.
k
()Calculate and return the thermal conductivity of the bulk according to the selected thermal conductivity settings in
BulkSettings
, the settings inThermalConductivityGasMixture
andThermalConductivityLiquidMixture
, and the configured pure-component settings inThermalConductivityGas
andThermalConductivityLiquid
.kappa
()Method to calculate and return the isothermal compressibility of the bulk according to the selected calculation methodology.
mu
()Calculate and return the viscosity of the bulk according to the selected viscosity settings in
BulkSettings
, the settings inViscosityGasMixture
andViscosityLiquidMixture
, and the configured pure-component settings inViscosityGas
andViscosityLiquid
.sigma
()Calculate and return the surface tension of the bulk according to the selected surface tension settings in
BulkSettings
, the settings inSurfaceTensionMixture
and the configured pure-component settings inSurfaceTension
.Method to calculate and return the molar speed of sound of the bulk according to the selected calculation methodology.
- Cp()[source]¶
Method to calculate and return the constant-temperature and constant phase-fraction heat capacity of the bulk phase. This is a phase-fraction weighted calculation.
\[C_p = \sum_i^p C_{p,i} \beta_i \]- Returns
- Cpfloat
Molar heat capacity, [J/(mol*K)]
- Cp_ideal_gas()[source]¶
Method to calculate and return the ideal-gas heat capacity of the phase.
\[C_p^{ig} = \sum_i z_i {C_{p,i}^{ig}} \]- Returns
- Cpfloat
Ideal gas heat capacity, [J/(mol*K)]
- H()[source]¶
Method to calculate and return the constant-temperature and constant phase-fraction enthalpy of the bulk phase. This is a phase-fraction weighted calculation.
\[H = \sum_i^p H_{i} \beta_i \]- Returns
- Hfloat
Molar enthalpy, [J/(mol)]
- H_ideal_gas()[source]¶
Method to calculate and return the ideal-gas enthalpy of the phase.
\[H^{ig} = \sum_i z_i {H_{i}^{ig}} \]- Returns
- Hfloat
Ideal gas enthalpy, [J/(mol)]
- H_reactive()[source]¶
Method to calculate and return the constant-temperature and constant phase-fraction reactive enthalpy of the bulk phase. This is a phase-fraction weighted calculation.
\[H_{\text{reactive}} = \sum_i^p H_{\text{reactive}, i} \beta_i \]- Returns
- H_reactivefloat
Reactive molar enthalpy, [J/(mol)]
- Joule_Thomson()[source]¶
Method to calculate and return the Joule-Thomson coefficient of the bulk according to the selected calculation methodology.
\[\mu_{JT} = \left(\frac{\partial T}{\partial P}\right)_H \]- Returns
- mu_JTfloat
Joule-Thomson coefficient [K/Pa]
- MW()[source]¶
Method to calculate and return the molecular weight of the bulk phase. This is a phase-fraction weighted calculation.
\[\text{MW} = \sum_i^p \text{MW}_i \beta_i \]- Returns
- MWfloat
Molecular weight, [g/mol]
- Pmc()[source]¶
Method to calculate and return the mechanical critical pressure of the phase.
- Returns
- Pmcfloat
Mechanical critical pressure, [Pa]
- S()[source]¶
Method to calculate and return the constant-temperature and constant phase-fraction entropy of the bulk phase. This is a phase-fraction weighted calculation.
\[S = \sum_i^p S_{i} \beta_i \]- Returns
- Sfloat
Molar entropy, [J/(mol*K)]
- S_ideal_gas()[source]¶
Method to calculate and return the ideal-gas entropy of the phase.
\[S^{ig} = \sum_i z_i S_{i}^{ig} - R\ln\left(\frac{P}{P_{ref}}\right) - R\sum_i z_i \ln(z_i) \]- Returns
- Sfloat
Ideal gas molar entropy, [J/(mol*K)]
- S_reactive()[source]¶
Method to calculate and return the constant-temperature and constant phase-fraction reactive entropy of the bulk phase. This is a phase-fraction weighted calculation.
\[S_{\text{reactive}} = \sum_i^p S_{\text{reactive}, i} \beta_i \]- Returns
- S_reactivefloat
Reactive molar entropy, [J/(mol*K)]
- Tmc()[source]¶
Method to calculate and return the mechanical critical temperature of the phase.
- Returns
- Tmcfloat
Mechanical critical temperature, [K]
- V()[source]¶
Method to calculate and return the molar volume of the bulk phase. This is a phase-fraction weighted calculation.
\[V = \sum_i^p V_i \beta_i \]- Returns
- Vfloat
Molar volume, [m^3/mol]
- V_iter(force=False)[source]¶
Method to calculate and return the molar volume of the bulk phase, with precision suitable for a TV calculation to calculate a matching pressure. This is a phase-fraction weighted calculation.
\[V = \sum_i^p V_i \beta_i \]- Returns
- Vfloat or mpf
Molar volume, [m^3/mol]
- Vmc()[source]¶
Method to calculate and return the mechanical critical volume of the phase.
- Returns
- Vmcfloat
Mechanical critical volume, [m^3/mol]
- Zmc()[source]¶
Method to calculate and return the mechanical critical compressibility of the phase.
- Returns
- Zmcfloat
Mechanical critical compressibility, [-]
- property beta¶
Phase fraction of the bulk phase. Should always be 1 when representing all phases of a flash; but can be less than one if representing multiple solids or liquids as a single phase in a larger mixture.
- Returns
- betafloat
Phase fraction of bulk, [-]
- property betas_mass¶
Method to calculate and return the mass fraction of all of the phases in the bulk.
- Returns
- betas_masslist[float]
Mass phase fractions of all the phases in the bulk object, ordered vapor, liquid, then solid, [-]
- property betas_volume¶
Method to calculate and return the volume fraction of all of the phases in the bulk.
- Returns
- betas_volumelist[float]
Volume phase fractions of all the phases in the bulk, ordered vapor, liquid, then solid , [-]
- d2P_dT2()[source]¶
Method to calculate and return the second temperature derivative of pressure of the bulk according to the selected calculation methodology.
- Returns
- d2P_dT2float
Second temperature derivative of pressure, [Pa/K^2]
- d2P_dT2_frozen()[source]¶
Method to calculate and return the second constant-volume derivative of pressure with respect to temperature of the bulk phase, at constant phase fractions and phase compositions. This is a molar phase-fraction weighted calculation.
\[\left(\frac{\partial^2 P}{\partial T^2}\right)_{V, \beta, {zs}} = \sum_{i}^{\text{phases}} \beta_i \left(\frac{\partial^2 P} {\partial T^2}\right)_{i, V_i, \beta_i, {zs}_i} \]- Returns
- d2P_dT2_frozenfloat
Frozen constant-volume second derivative of pressure with respect to temperature of the bulk phase, [Pa/K^2]
- d2P_dTdV()[source]¶
Method to calculate and return the second derivative of pressure with respect to temperature and volume of the bulk according to the selected calculation methodology.
- Returns
- d2P_dTdVfloat
Second volume derivative of pressure, [mol*Pa^2/(J*K)]
- d2P_dTdV_frozen()[source]¶
Method to calculate and return the second derivative of pressure with respect to volume and temperature of the bulk phase, at constant phase fractions and phase compositions. This is a molar phase-fraction weighted calculation.
\[\left(\frac{\partial^2 P}{\partial V \partial T}\right)_{\beta, {zs}} = \sum_{i}^{\text{phases}} \beta_i \left(\frac{\partial^2 P} {\partial V \partial T}\right)_{i, \beta_i, {zs}_i} \]- Returns
- d2P_dTdV_frozenfloat
Frozen second derivative of pressure with respect to volume and temperature of the bulk phase, [Pa*mol^2/m^6]
- d2P_dV2()[source]¶
Method to calculate and return the second volume derivative of pressure of the bulk according to the selected calculation methodology.
- Returns
- d2P_dV2float
Second volume derivative of pressure, [Pa*mol^2/m^6]
- d2P_dV2_frozen()[source]¶
Method to calculate and return the constant-temperature second derivative of pressure with respect to volume of the bulk phase, at constant phase fractions and phase compositions. This is a molar phase-fraction weighted calculation.
\[\left(\frac{\partial^2 P}{\partial V^2}\right)_{T, \beta, {zs}} = \sum_{i}^{\text{phases}} \beta_i \left(\frac{\partial^2 P} {\partial V^2}\right)_{i, T, \beta_i, {zs}_i} \]- Returns
- d2P_dV2_frozenfloat
Frozen constant-temperature second derivative of pressure with respect to volume of the bulk phase, [Pa*mol^2/m^6]
- dA_dP()[source]¶
Method to calculate and return the constant-temperature pressure derivative of Helmholtz energy.
\[\left(\frac{\partial A}{\partial P}\right)_{T} = -T \left(\frac{\partial S}{\partial P}\right)_{T} + \left(\frac{\partial U}{\partial P}\right)_{T} \]- Returns
- dA_dPfloat
Constant-temperature pressure derivative of Helmholtz energy, [J/(mol*Pa)]
- dA_dT()[source]¶
Method to calculate and return the constant-pressure temperature derivative of Helmholtz energy.
\[\left(\frac{\partial A}{\partial T}\right)_{P} = -T \left(\frac{\partial S}{\partial T}\right)_{P} - S + \left(\frac{\partial U}{\partial T}\right)_{P} \]- Returns
- dA_dTfloat
Constant-pressure temperature derivative of Helmholtz energy, [J/(mol*K)]
- dG_dP()[source]¶
Method to calculate and return the constant-temperature pressure derivative of Gibbs free energy.
\[\left(\frac{\partial G}{\partial P}\right)_{T} = -T\left(\frac{\partial S}{\partial P}\right)_{T} + \left(\frac{\partial H}{\partial P}\right)_{T} \]- Returns
- dG_dPfloat
Constant-temperature pressure derivative of Gibbs free energy, [J/(mol*Pa)]
- dG_dT()[source]¶
Method to calculate and return the constant-pressure temperature derivative of Gibbs free energy.
\[\left(\frac{\partial G}{\partial T}\right)_{P} = -T\left(\frac{\partial S}{\partial T}\right)_{P} - S + \left(\frac{\partial H}{\partial T}\right)_{P} \]- Returns
- dG_dTfloat
Constant-pressure temperature derivative of Gibbs free energy, [J/(mol*K)]
- dP_dT()[source]¶
Method to calculate and return the first temperature derivative of pressure of the bulk according to the selected calculation methodology.
- Returns
- dP_dTfloat
First temperature derivative of pressure, [Pa/K]
- dP_dT_frozen()[source]¶
Method to calculate and return the constant-volume derivative of pressure with respect to temperature of the bulk phase, at constant phase fractions and phase compositions. This is a molar phase-fraction weighted calculation.
\[\left(\frac{\partial P}{\partial T}\right)_{V, \beta, {zs}} = \sum_{i}^{\text{phases}} \beta_i \left(\frac{\partial P} {\partial T}\right)_{i, V_i, \beta_i, {zs}_i} \]- Returns
- dP_dT_frozenfloat
Frozen constant-volume derivative of pressure with respect to temperature of the bulk phase, [Pa/K]
- dP_dV()[source]¶
Method to calculate and return the first volume derivative of pressure of the bulk according to the selected calculation methodology.
- Returns
- dP_dVfloat
First volume derivative of pressure, [Pa*mol/m^3]
- dP_dV_frozen()[source]¶
Method to calculate and return the constant-temperature derivative of pressure with respect to volume of the bulk phase, at constant phase fractions and phase compositions. This is a molar phase-fraction weighted calculation.
\[\left(\frac{\partial P}{\partial V}\right)_{T, \beta, {zs}} = \sum_{i}^{\text{phases}} \beta_i \left(\frac{\partial P} {\partial V}\right)_{i, T, \beta_i, {zs}_i} \]- Returns
- dP_dV_frozenfloat
Frozen constant-temperature derivative of pressure with respect to volume of the bulk phase, [Pa*mol/m^3]
- dU_dP()[source]¶
Method to calculate and return the constant-temperature pressure derivative of internal energy.
\[\left(\frac{\partial U}{\partial P}\right)_{T} = -P \left(\frac{\partial V}{\partial P}\right)_{T} - V + \left(\frac{\partial H}{\partial P}\right)_{T} \]- Returns
- dU_dPfloat
Constant-temperature pressure derivative of internal energy, [J/(mol*Pa)]
- dU_dT()[source]¶
Method to calculate and return the constant-pressure temperature derivative of internal energy.
\[\left(\frac{\partial U}{\partial T}\right)_{P} = -P \left(\frac{\partial V}{\partial T}\right)_{P} + \left(\frac{\partial H}{\partial T}\right)_{P} \]- Returns
- dU_dTfloat
Constant-pressure temperature derivative of internal energy, [J/(mol*K)]
- isobaric_expansion()[source]¶
Method to calculate and return the isobatic expansion coefficient of the bulk according to the selected calculation methodology.
\[\beta = \frac{1}{V}\left(\frac{\partial V}{\partial T} \right)_P \]- Returns
- betafloat
Isobaric coefficient of a thermal expansion, [1/K]
- k()[source]¶
Calculate and return the thermal conductivity of the bulk according to the selected thermal conductivity settings in
BulkSettings
, the settings inThermalConductivityGasMixture
andThermalConductivityLiquidMixture
, and the configured pure-component settings inThermalConductivityGas
andThermalConductivityLiquid
.- Returns
- kfloat
Thermal Conductivity of bulk phase calculated with mixing rules, [Pa*s]
- kappa()[source]¶
Method to calculate and return the isothermal compressibility of the bulk according to the selected calculation methodology.
\[\kappa = -\frac{1}{V}\left(\frac{\partial V}{\partial P} \right)_T \]- Returns
- kappafloat
Isothermal coefficient of compressibility, [1/Pa]
- mu()[source]¶
Calculate and return the viscosity of the bulk according to the selected viscosity settings in
BulkSettings
, the settings inViscosityGasMixture
andViscosityLiquidMixture
, and the configured pure-component settings inViscosityGas
andViscosityLiquid
.- Returns
- mufloat
Viscosity of bulk phase calculated with mixing rules, [Pa*s]
- sigma()[source]¶
Calculate and return the surface tension of the bulk according to the selected surface tension settings in
BulkSettings
, the settings inSurfaceTensionMixture
and the configured pure-component settings inSurfaceTension
.- Returns
- sigmafloat
Surface tension of bulk phase calculated with mixing rules, [N/m]
Notes
A value is only returned if all phases in the bulk are liquids; this property is for a liquid-ideal gas calculation, not the interfacial tension between two liquid phases.
- speed_of_sound()[source]¶
Method to calculate and return the molar speed of sound of the bulk according to the selected calculation methodology.
\[w = \left[-V^2 \left(\frac{\partial P}{\partial V}\right)_T \frac{C_p} {C_v}\right]^{1/2} \]A similar expression based on molar density is:
\[w = \left[\left(\frac{\partial P}{\partial \rho}\right)_T \frac{C_p} {C_v}\right]^{1/2} \]- Returns
- wfloat
Speed of sound for a real gas, [m*kg^0.5/(s*mol^0.5)]
Bulk Settings Class¶
- class thermo.bulk.BulkSettings(dP_dT='MOLE_WEIGHTED', dP_dV='MOLE_WEIGHTED', d2P_dV2='MOLE_WEIGHTED', d2P_dT2='MOLE_WEIGHTED', d2P_dTdV='MOLE_WEIGHTED', mu_LL='LOG_PROP_MASS_WEIGHTED', mu_LL_power_exponent=0.4, mu_VL='McAdams', mu_VL_power_exponent=0.4, k_LL='MASS_WEIGHTED', k_LL_power_exponent=0.4, k_VL='MASS_WEIGHTED', k_VL_power_exponent=0.4, sigma_LL='MASS_WEIGHTED', sigma_LL_power_exponent=0.4, T_liquid_volume_ref=298.15, T_normal=273.15, P_normal=101325.0, T_standard=288.15, P_standard=101325.0, T_gas_ref=288.15, P_gas_ref=101325.0, speed_of_sound='MOLE_WEIGHTED', kappa='MOLE_WEIGHTED', isobaric_expansion='MOLE_WEIGHTED', Joule_Thomson='MOLE_WEIGHTED', VL_ID='PIP', VL_ID_settings=None, S_ID='d2P_dVdT', S_ID_settings=None, solid_sort_method='prop', liquid_sort_method='prop', liquid_sort_cmps=[], solid_sort_cmps=[], liquid_sort_cmps_neg=[], solid_sort_cmps_neg=[], liquid_sort_prop='DENSITY_MASS', solid_sort_prop='DENSITY_MASS', phase_sort_higher_first=True, water_sort='water not special', equilibrium_perturbation=1e-07)[source]¶
Bases:
object
Class containing configuration methods for determining how properties of a Bulk phase made of different phases are handled. All parameters are also attributes.
- Parameters
- dP_dTstr, optional
The method used to calculate the constant-volume temperature derivative of pressure of the bulk. One of
DP_DT_METHODS
, [-]- dP_dVstr, optional
The method used to calculate the constant-temperature volume derivative of pressure of the bulk. One of
DP_DV_METHODS
, [-]- d2P_dV2str, optional
The method used to calculate the second constant-temperature volume derivative of pressure of the bulk. One of
D2P_DV2_METHODS
, [-]- d2P_dT2str, optional
The method used to calculate the second constant-volume temperature derivative of pressure of the bulk. One of
D2P_DT2_METHODS
, [-]- d2P_dTdVstr, optional
The method used to calculate the temperature and volume derivative of pressure of the bulk. One of
D2P_DTDV_METHODS
, [-]- T_liquid_volume_reffloat, optional
Liquid molar volume reference temperature; if this is 298.15 K exactly, the molar volumes in
Vml_STPs
will be used, and if it is 288.7055555555555 K exactly,Vml_60Fs
will be used, and otherwise the molar liquid volumes will be obtained from the temperature-dependent correlations specified, [K]- T_gas_reffloat, optional
Reference temperature to use for the calculation of ideal-gas molar volume and flow rate, [K]
- P_gas_reffloat, optional
Reference pressure to use for the calculation of ideal-gas molar volume and flow rate, [Pa]
- T_normalfloat, optional
“Normal” gas reference temperature for the calculation of ideal-gas molar volume in the “normal” reference state; default 273.15 K (0 C) according to [1], [K]
- P_normalfloat, optional
“Normal” gas reference pressure for the calculation of ideal-gas molar volume in the “normal” reference state; default 101325 Pa (1 atm) according to [1], [Pa]
- T_standardfloat, optional
“Standard” gas reference temperature for the calculation of ideal-gas molar volume in the “standard” reference state; default 288.15 K (15° C) according to [2]; 288.7055555555555 is also often used (60° F), [K]
- P_standardfloat, optional
“Standard” gas reference pressure for the calculation of ideal-gas molar volume in the “standard” reference state; default 101325 Pa (1 atm) according to [2], [Pa]
- mu_LLstr, optional
Mixing rule for multiple liquid phase liquid viscosity calculations; see
MU_LL_METHODS
for available options, [-]- mu_LL_power_exponentfloat, optional
Liquid-liquid viscosity power-law mixing parameter, used only when a power law mixing rule is selected, [-]
- mu_VLstr, optional
Mixing rule for vapor-liquid viscosity calculations; see
MU_VL_METHODS
for available options, [-]- mu_VL_power_exponentfloat, optional
Vapor-liquid viscosity power-law mixing parameter, used only when a power law mixing rule is selected, [-]
- k_LLstr, optional
Mixing rule for multiple liquid phase liquid thermal conductivity calculations; see
K_LL_METHODS
for available options, [-]- k_LL_power_exponentfloat, optional
Liquid-liquid thermal conductivity power-law mixing parameter, used only when a power law mixing rule is selected, [-]
- k_VLstr, optional
Mixing rule for vapor-liquid thermal conductivity calculations; see
K_VL_METHODS
for available options, [-]- k_VL_power_exponentfloat, optional
Vapor-liquid thermal conductivity power-law mixing parameter, used only when a power law mixing rule is selected, [-]
- sigma_LLstr, optional
Mixing rule for multiple liquid phase, air-liquid surface tension calculations; see
SIGMA_LL_METHODS
for available options, [-]- sigma_LL_power_exponentfloat, optional
Air-liquid Liquid-liquid surface tension power-law mixing parameter, used only when a power law mixing rule is selected, [-]
- equilibrium_perturbationfloat, optional
The relative perturbation to use when calculating equilibrium derivatives numerically; for example if this is 1e-3 and T is the perturbation variable and the statis is 500 K, the perturbation calculation temperature will be 500.5 K, [various]
- isobaric_expansionstr, optional
Mixing rule for multiphase isobaric expansion calculations; see
BETA_METHODS
for available options, [-]- speed_of_soundstr, optional
Mixing rule for multiphase speed of sound calculations; see
SPEED_OF_SOUND_METHODS
for available options, [-]- kappastr, optional
Mixing rule for multiphase kappa calculations; see
KAPPA_METHODS
for available options, [-]- Joule_Thomsonstr, optional
Mixing rule for multiphase Joule-Thomson calculations; see
JT_METHODS
for available options, [-]
Notes
The linear mixing rules “MOLE_WEIGHTED”, “MASS_WEIGHTED”, and “VOLUME_WEIGHTED” have the following formula, with \(\beta\) representing molar, mass, or volume phase fraction:
\[\text{bulk property} = \left(\sum_i^{phases} \beta_i \text{property} \right) \]The power mixing rules “POWER_PROP_MOLE_WEIGHTED”, “POWER_PROP_MASS_WEIGHTED”, and “POWER_PROP_VOLUME_WEIGHTED” have the following formula, with \(\beta\) representing molar, mass, or volume phase fraction:
\[\text{bulk property} = \left(\sum_i^{phases} \beta_i \text{property }^{\text{exponent}} \right)^{1/\text{exponent}} \]The logarithmic mixing rules “LOG_PROP_MOLE_WEIGHTED”, “LOG_PROP_MASS_WEIGHTED”, and “LOG_PROP_VOLUME_WEIGHTED” have the following formula, with \(\beta\) representing molar, mass, or volume phase fraction:
\[\text{bulk property} = \exp\left(\sum_i^{phases} \beta_i \ln(\text{property })\right) \]The mixing rule “MINIMUM_PHASE_PROP” selects the lowest phase value of the property, always. The mixing rule “MAXIMUM_PHASE_PROP” selects the highest phase value of the property, always.
The mixing rule “AS_ONE_LIQUID” calculates a property using the bulk composition but applied to the liquid model only. The mixing rule “AS_ONE_GAS” calculates a property using the bulk composition but applied to the gas model only.
The mixing rule “FROM_DERIVATIVE_SETTINGS” is used to indicate that the property depends on other configurable properties; and when this is the specified option, those configurations will be used in the calculation of this property.
The mixing rule “EQUILIBRIUM_DERIVATIVE” performs derivative calculations on flashes themselves. This is quite slow in comparison to other methods.
References
- 1(1,2,3)
14:00-17:00. “ISO 10780:1994.” ISO. Accessed March 29, 2021. https://www.iso.org/cms/render/live/en/sites/isoorg/contents/data/standard/01/88/18855.html.
- 2(1,2,3)
14:00-17:00. “ISO 13443:1996.” ISO. Accessed March 29, 2021. https://www.iso.org/cms/render/live/en/sites/isoorg/contents/data/standard/02/04/20461.html.
Methods
as_json
- thermo.bulk.DP_DT_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'EQUILIBRIUM_DERIVATIVE', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP']¶
List of all valid and implemented calculation methods for the DP_DT bulk setting
- thermo.bulk.DP_DV_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'EQUILIBRIUM_DERIVATIVE', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP']¶
List of all valid and implemented calculation methods for the DP_DV bulk setting
- thermo.bulk.D2P_DV2_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP']¶
List of all valid and implemented calculation methods for the D2P_DV2 bulk setting
- thermo.bulk.D2P_DT2_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP']¶
List of all valid and implemented calculation methods for the D2P_DT2 bulk setting
- thermo.bulk.D2P_DTDV_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP']¶
List of all valid and implemented calculation methods for the D2P_DTDV bulk setting
- thermo.bulk.MU_LL_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'AS_ONE_LIQUID', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'POWER_PROP_MOLE_WEIGHTED', 'POWER_PROP_MASS_WEIGHTED', 'POWER_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP']¶
List of all valid and implemented mixing rules for the MU_LL setting
- thermo.bulk.MU_VL_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'AS_ONE_LIQUID', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'POWER_PROP_MOLE_WEIGHTED', 'POWER_PROP_MASS_WEIGHTED', 'POWER_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP', 'AS_ONE_GAS', 'Beattie Whalley', 'McAdams', 'Cicchitti', 'Lin Kwok', 'Fourar Bories', 'Duckler']¶
List of all valid and implemented mixing rules for the MU_VL setting
- thermo.bulk.K_LL_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'AS_ONE_LIQUID', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'POWER_PROP_MOLE_WEIGHTED', 'POWER_PROP_MASS_WEIGHTED', 'POWER_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP']¶
List of all valid and implemented mixing rules for the K_LL setting
- thermo.bulk.K_VL_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'AS_ONE_LIQUID', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'POWER_PROP_MOLE_WEIGHTED', 'POWER_PROP_MASS_WEIGHTED', 'POWER_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP', 'AS_ONE_GAS']¶
List of all valid and implemented mixing rules for the K_VL setting
- thermo.bulk.SIGMA_LL_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'AS_ONE_LIQUID', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'POWER_PROP_MOLE_WEIGHTED', 'POWER_PROP_MASS_WEIGHTED', 'POWER_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP']¶
List of all valid and implemented mixing rules for the SIGMA_LL setting
- thermo.bulk.BETA_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP', 'EQUILIBRIUM_DERIVATIVE', 'FROM_DERIVATIVE_SETTINGS']¶
List of all valid and implemented calculation methods for the isothermal_compressibility bulk setting
- thermo.bulk.SPEED_OF_SOUND_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP', 'FROM_DERIVATIVE_SETTINGS', 'EQUILIBRIUM_DERIVATIVE', 'FIROOZABADI_PAN']¶
List of all valid and implemented calculation methods for the speed_of_sound bulk setting
- thermo.bulk.KAPPA_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP', 'EQUILIBRIUM_DERIVATIVE', 'FROM_DERIVATIVE_SETTINGS']¶
List of all valid and implemented calculation methods for the kappa bulk setting
- thermo.bulk.JT_METHODS = ['MOLE_WEIGHTED', 'MASS_WEIGHTED', 'VOLUME_WEIGHTED', 'LOG_PROP_MOLE_WEIGHTED', 'LOG_PROP_MASS_WEIGHTED', 'LOG_PROP_VOLUME_WEIGHTED', 'MINIMUM_PHASE_PROP', 'MAXIMUM_PHASE_PROP', 'EQUILIBRIUM_DERIVATIVE', 'FROM_DERIVATIVE_SETTINGS']¶
List of all valid and implemented calculation methods for the JT bulk setting
Legacy Chemicals (thermo.chemical)¶
- class thermo.chemical.Chemical(ID, T=298.15, P=101325, autocalc=True)[source]¶
Bases:
object
Creates a Chemical object which contains basic information such as molecular weight and the structure of the species, as well as thermodynamic and transport properties as a function of temperature and pressure.
- Parameters
- IDstr
- One of the following [-]:
Name, in IUPAC form or common form or a synonym registered in PubChem
InChI name, prefixed by ‘InChI=1S/’ or ‘InChI=1/’
InChI key, prefixed by ‘InChIKey=’
PubChem CID, prefixed by ‘PubChem=’
SMILES (prefix with ‘SMILES=’ to ensure smiles parsing)
CAS number
- Tfloat, optional
Temperature of the chemical (default 298.15 K), [K]
- Pfloat, optional
Pressure of the chemical (default 101325 Pa) [Pa]
Notes
Warning
The Chemical class is not designed for high-performance or the ability to use different thermodynamic models. It is especially limited in its multiphase support and the ability to solve with specifications other than temperature and pressure. It is impossible to change constant properties such as a compound’s critical temperature in this interface.
It is recommended to switch over to the
thermo.flash
interface which solves those problems and is better positioned to grow. That interface also requires users to be responsible for their chemical constants and pure component correlations; while default values can easily be loaded for most compounds, the user is ultimately responsible for them.Examples
Creating chemical objects:
>>> Chemical('hexane') <Chemical [hexane], T=298.15 K, P=101325 Pa>
>>> Chemical('CCCCCCCC', T=500, P=1E7) <Chemical [octane], T=500.00 K, P=10000000 Pa>
>>> Chemical('7440-36-0', P=1000) <Chemical [antimony], T=298.15 K, P=1000 Pa>
Getting basic properties:
>>> N2 = Chemical('Nitrogen') >>> N2.Tm, N2.Tb, N2.Tc # melting, boiling, and critical points [K] (63.15, 77.355, 126.2) >>> N2.Pt, N2.Pc # sublimation and critical pressure [Pa] (12526.9697368421, 3394387.5) >>> N2.CAS, N2.formula, N2.InChI, N2.smiles, N2.atoms # CAS number, formula, InChI string, smiles string, dictionary of atomic elements and their count ('7727-37-9', 'N2', 'N2/c1-2', 'N#N', {'N': 2})
Changing the T/P of the chemical, and gettign temperature-dependent properties:
>>> N2.Cp, N2.rho, N2.mu # Heat capacity [J/kg/K], density [kg/m^3], viscosity [Pa*s] (1039., 1.14, 1.78e-05) >>> N2.calculate(T=65, P=1E6) # set it to a liquid at 65 K and 1 MPa >>> N2.phase 'l' >>> N2.Cp, N2.rho, N2.mu # properties are now of the liquid phase (2002., 861., 0.000285)
Molar units are also available for properties:
>>> N2.Cpm, N2.Vm, N2.Hvapm # heat capacity [J/mol/K], molar volume [m^3/mol], enthalpy of vaporization [J/mol] (56., 3.25e-05, 5982.)
A great deal of properties are available; for a complete list look at the attributes list.
>>> N2.alpha, N2.JT # thermal diffusivity [m^2/s], Joule-Thompson coefficient [K/Pa] (9.87e-08, -4.0e-07)
>>> N2.isentropic_exponent, N2.isobaric_expansion (1.4, 0.0047)
For pure species, the phase is easily identified, allowing for properties to be obtained without needing to specify the phase. However, the properties are also available in the hypothetical gas phase (when under the boiling point) and in the hypothetical liquid phase (when above the boiling point) as these properties are needed to evaluate mixture properties. Specify the phase of a property to be retrieved by appending ‘l’ or ‘g’ or ‘s’ to the property.
>>> C50 = Chemical('pentacontane')
>>> C50.rhog, C50.Cpg, C50.kg, C50.mug (4.241646701894199, 1126.5533755283168, 0.00941385692301755, 6.973325939594919e-06)
Temperature dependent properties are calculated by objects which provide many useful features related to the properties. To determine the temperature at which nitrogen has a saturation pressure of 1 MPa:
>>> N2.VaporPressure.solve_property(1E6) 103.73528598652341
To compute an integral of the ideal-gas heat capacity of nitrogen to determine the enthalpy required for a given change in temperature. Note the thermodynamic objects calculate values in molar units always.
>>> N2.HeatCapacityGas.T_dependent_property_integral(100, 120) # J/mol/K 582.0121860897898
Derivatives of properties can be calculated as well, as may be needed by for example heat transfer calculations:
>>> N2.SurfaceTension.T_dependent_property_derivative(77) -0.00022695346296730534
If a property is needed at multiple temperatures or pressures, it is faster to use the object directly to perform the calculation rather than setting the conditions for the chemical.
>>> [N2.VaporPressure(T) for T in range(80, 120, 10)] [136979.4840843189, 360712.5746603142, 778846.276691705, 1466996.7208525643]
These objects are also how the methods by which the properties are calculated can be changed. To see the available methods for a property:
>>> N2.VaporPressure.all_methods set(['VDI_PPDS', 'BOILING_CRITICAL', 'WAGNER_MCGARRY', 'AMBROSE_WALTON', 'COOLPROP', 'LEE_KESLER_PSAT', 'EOS', 'ANTOINE_POLING', 'SANJARI', 'DIPPR_PERRY_8E', 'Edalat', 'WAGNER_POLING'])
To specify the method which should be used for calculations of a property. In the example below, the Lee-kesler correlation for vapor pressure is specified.
>>> N2.calculate(80) >>> N2.Psat 136979.4840843189 >>> N2.VaporPressure.method = 'LEE_KESLER_PSAT' >>> N2.Psat 134987.76815364443
For memory reduction, these objects are shared by all chemicals which are the same; new instances will use the same specified methods.
>>> N2_2 = Chemical('nitrogen') >>> N2_2.VaporPressure.user_methods ['LEE_KESLER_PSAT']
To disable this behavior, set thermo.chemical.caching to False.
>>> import thermo >>> thermo.chemical.caching = False >>> N2_3 = Chemical('nitrogen') >>> N2_3.VaporPressure.user_methods []
Properties may also be plotted via these objects:
>>> N2.VaporPressure.plot_T_dependent_property() >>> N2.VolumeLiquid.plot_isotherm(T=77, Pmin=1E5, Pmax=1E7) >>> N2.VolumeLiquid.plot_isobar(P=1E6, Tmin=66, Tmax=120) >>> N2.VolumeLiquid.plot_TP_dependent_property(Tmin=60, Tmax=100, Pmin=1E5, Pmax=1E7)
- Attributes
- Tfloat
Temperature of the chemical, [K]
- Pfloat
Pressure of the chemical, [Pa]
- phasestr
Phase of the chemical; one of ‘s’, ‘l’, ‘g’, or ‘l/g’.
- IDstr
User specified string by which the chemical’s CAS was looked up.
- CASstr
The CAS number of the chemical.
- PubChemint
PubChem Compound identifier (CID) of the chemical; all chemicals are sourced from their database. Chemicals can be looked at online at https://pubchem.ncbi.nlm.nih.gov.
- MWfloat
Molecular weight of the compound, [g/mol]
- formulastr
Molecular formula of the compound.
- atomsdict
dictionary of counts of individual atoms, indexed by symbol with proper capitalization, [-]
- similarity_variablefloat
Similarity variable, see
chemicals.elements.similarity_variable
for the definition, [mol/g]- smilesstr
Simplified molecular-input line-entry system representation of the compound.
- InChIstr
IUPAC International Chemical Identifier of the compound.
- InChI_Keystr
25-character hash of the compound’s InChI.
- IUPAC_namestr
Preferred IUPAC name for a compound.
- synonymslist of strings
All synonyms for the compound found in PubChem, sorted by popularity.
- Tmfloat
Melting temperature [K]
- Tbfloat
Boiling temperature [K]
- Tcfloat
Critical temperature [K]
- Pcfloat
Critical pressure [Pa]
- Vcfloat
Critical volume [m^3/mol]
- Zcfloat
Critical compressibility [-]
- rhocfloat
Critical density [kg/m^3]
- rhocmfloat
Critical molar density [mol/m^3]
- omegafloat
Acentric factor [-]
- StielPolarfloat
Stiel Polar factor, see
chemicals.acentric.Stiel_polar_factor
for the definition [-]- Ttfloat
Triple temperature, [K]
- Ptfloat
Triple pressure, [Pa]
- Hfusfloat
Enthalpy of fusion [J/kg]
- Hfusmfloat
Molar enthalpy of fusion [J/mol]
- Hsubfloat
Enthalpy of sublimation [J/kg]
- Hsubmfloat
Molar enthalpy of sublimation [J/mol]
- Hfmfloat
Standard state molar enthalpy of formation, [J/mol]
- Hffloat
Standard enthalpy of formation in a mass basis, [J/kg]
- Hfgmfloat
Ideal-gas molar enthalpy of formation, [J/mol]
- Hfgfloat
Ideal-gas enthalpy of formation in a mass basis, [J/kg]
- Hcmfloat
Molar higher heat of combustion [J/mol]
- Hcfloat
Higher Heat of combustion [J/kg]
- Hcm_lowerfloat
Molar lower heat of combustion [J/mol]
- Hc_lowerfloat
Lower Heat of combustion [J/kg]
- S0mfloat
Standard state absolute molar entropy of the chemical, [J/mol/K]
- S0float
Standard state absolute entropy of the chemical, [J/kg/K]
- S0gmfloat
Absolute molar entropy in an ideal gas state of the chemical, [J/mol/K]
- S0gfloat
Absolute mass entropy in an ideal gas state of the chemical, [J/kg/K]
- Gfmfloat
Standard state molar change of Gibbs energy of formation [J/mol]
- Gffloat
Standard state change of Gibbs energy of formation [J/kg]
- Gfgmfloat
Ideal-gas molar change of Gibbs energy of formation [J/mol]
- Gfgfloat
Ideal-gas change of Gibbs energy of formation [J/kg]
- Sfmfloat
Standard state molar change of entropy of formation, [J/mol/K]
- Sffloat
Standard state change of entropy of formation, [J/kg/K]
- Sfgmfloat
Ideal-gas molar change of entropy of formation, [J/mol/K]
- Sfgfloat
Ideal-gas change of entropy of formation, [J/kg/K]
- Hcgmfloat
Higher molar heat of combustion of the chemical in the ideal gas state, [J/mol]
- Hcgfloat
Higher heat of combustion of the chemical in the ideal gas state, [J/kg]
- Hcgm_lowerfloat
Lower molar heat of combustion of the chemical in the ideal gas state, [J/mol]
- Hcg_lowerfloat
Lower heat of combustion of the chemical in the ideal gas state, [J/kg]
- Tflashfloat
Flash point of the chemical, [K]
- Tautoignitionfloat
Autoignition point of the chemical, [K]
- LFLfloat
Lower flammability limit of the gas in an atmosphere at STP, mole fraction [-]
- UFLfloat
Upper flammability limit of the gas in an atmosphere at STP, mole fraction [-]
- TWAtuple[quantity, unit]
Time-Weighted Average limit on worker exposure to dangerous chemicals.
- STELtuple[quantity, unit]
Short-term Exposure limit on worker exposure to dangerous chemicals.
- Ceilingtuple[quantity, unit]
Ceiling limits on worker exposure to dangerous chemicals.
- Skinbool
Whether or not a chemical can be absorbed through the skin.
- Carcinogenstr or dict
Carcinogen status information.
- dipolefloat
Dipole moment in debye, [3.33564095198e-30 ampere*second^2]
- Stockmayerfloat
Lennard-Jones depth of potential-energy minimum over k, [K]
- molecular_diameterfloat
Lennard-Jones molecular diameter, [angstrom]
- GWPfloat
Global warming potential (default 100-year outlook) (impact/mass chemical)/(impact/mass CO2), [-]
- ODPfloat
Ozone Depletion potential (impact/mass chemical)/(impact/mass CFC-11), [-]
- logPfloat
Octanol-water partition coefficient, [-]
legal_status
str or dictDictionary of legal status indicators for the chemical.
economic_status
listDictionary of economic status indicators for the chemical.
- RIfloat
Refractive Index on the Na D line, [-]
- RITfloat
Temperature at which refractive index reading was made
- conductivityfloat
Electrical conductivity of the fluid, [S/m]
- conductivityTfloat
Temperature at which conductivity measurement was made
- VaporPressureobject
Instance of
thermo.vapor_pressure.VaporPressure
, with data and methods loaded for the chemical; performs the actual calculations of vapor pressure of the chemical.- EnthalpyVaporizationobject
Instance of
thermo.phase_change.EnthalpyVaporization
, with data and methods loaded for the chemical; performs the actual calculations of molar enthalpy of vaporization of the chemical.- VolumeSolidobject
Instance of
thermo.volume.VolumeSolid
, with data and methods loaded for the chemical; performs the actual calculations of molar volume of the solid phase of the chemical.- VolumeLiquidobject
Instance of
thermo.volume.VolumeLiquid
, with data and methods loaded for the chemical; performs the actual calculations of molar volume of the liquid phase of the chemical.- VolumeGasobject
Instance of
thermo.volume.VolumeGas
, with data and methods loaded for the chemical; performs the actual calculations of molar volume of the gas phase of the chemical.- HeatCapacitySolidobject
Instance of
thermo.heat_capacity.HeatCapacitySolid
, with data and methods loaded for the chemical; performs the actual calculations of molar heat capacity of the solid phase of the chemical.- HeatCapacityLiquidobject
Instance of
thermo.heat_capacity.HeatCapacityLiquid
, with data and methods loaded for the chemical; performs the actual calculations of molar heat capacity of the liquid phase of the chemical.- HeatCapacityGasobject
Instance of
thermo.heat_capacity.HeatCapacityGas
, with data and methods loaded for the chemical; performs the actual calculations of molar heat capacity of the gas phase of the chemical.- ViscosityLiquidobject
Instance of
thermo.viscosity.ViscosityLiquid
, with data and methods loaded for the chemical; performs the actual calculations of viscosity of the liquid phase of the chemical.- ViscosityGasobject
Instance of
thermo.viscosity.ViscosityGas
, with data and methods loaded for the chemical; performs the actual calculations of viscosity of the gas phase of the chemical.- ThermalConductivityLiquidobject
Instance of
thermo.thermal_conductivity.ThermalConductivityLiquid
, with data and methods loaded for the chemical; performs the actual calculations of thermal conductivity of the liquid phase of the chemical.- ThermalConductivityGasobject
Instance of
thermo.thermal_conductivity.ThermalConductivityGas
, with data and methods loaded for the chemical; performs the actual calculations of thermal conductivity of the gas phase of the chemical.- SurfaceTensionobject
Instance of
thermo.interface.SurfaceTension
, with data and methods loaded for the chemical; performs the actual calculations of surface tension of the chemical.- Permittivityobject
Instance of
thermo.permittivity.PermittivityLiquid
, with data and methods loaded for the chemical; performs the actual calculations of permittivity of the chemical.- Psat_298float
Vapor pressure of the chemical at 298.15 K, [Pa]
- phase_STPstr
Phase of the chemical at 298.15 K and 101325 Pa; one of ‘s’, ‘l’, ‘g’, or ‘l/g’.
- Vml_Tbfloat
Molar volume of liquid phase at the normal boiling point [m^3/mol]
- Vml_Tmfloat
Molar volume of liquid phase at the melting point [m^3/mol]
- Vml_STPfloat
Molar volume of liquid phase at 298.15 K and 101325 Pa [m^3/mol]
- rhoml_STPfloat
Molar density of liquid phase at 298.15 K and 101325 Pa [mol/m^3]
- Vmg_STPfloat
Molar volume of gas phase at 298.15 K and 101325 Pa according to the ideal gas law, [m^3/mol]
- Vms_Tmfloat
Molar volume of solid phase at the melting point [m^3/mol]
- rhos_Tmfloat
Mass density of solid phase at the melting point [kg/m^3]
- Hvap_Tbmfloat
Molar enthalpy of vaporization at the normal boiling point [J/mol]
- Hvap_Tbfloat
Mass enthalpy of vaporization at the normal boiling point [J/kg]
- Hvapm_298float
Molar enthalpy of vaporization at 298.15 K [J/mol]
- Hvap_298float
Mass enthalpy of vaporization at 298.15 K [J/kg]
alpha
Thermal diffusivity of the chemical at its current temperature, pressure, and phase in units of [m^2/s].
alphag
Thermal diffusivity of the gas phase of the chemical at its current temperature and pressure, in units of [m^2/s].
alphal
Thermal diffusivity of the liquid phase of the chemical at its current temperature and pressure, in units of [m^2/s].
API
API gravity of the liquid phase of the chemical, [degrees].
aromatic_rings
Number of aromatic rings in a chemical, computed with RDKit from a chemical’s SMILES.
atom_fractions
Dictionary of atom:fractional occurence of the elements in a chemical.
Bvirial
Second virial coefficient of the gas phase of the chemical at its current temperature and pressure, in units of [mol/m^3].
charge
Charge of a chemical, computed with RDKit from a chemical’s SMILES.
Cp
Mass heat capacity of the chemical at its current phase and temperature, in units of [J/kg/K].
Cpg
Gas-phase heat capacity of the chemical at its current temperature, in units of [J/kg/K].
Cpgm
Gas-phase ideal gas heat capacity of the chemical at its current temperature, in units of [J/mol/K].
Cpl
Liquid-phase heat capacity of the chemical at its current temperature, in units of [J/kg/K].
Cplm
Liquid-phase heat capacity of the chemical at its current temperature, in units of [J/mol/K].
Cpm
Molar heat capacity of the chemical at its current phase and temperature, in units of [J/mol/K].
Cps
Solid-phase heat capacity of the chemical at its current temperature, in units of [J/kg/K].
Cpsm
Solid-phase heat capacity of the chemical at its current temperature, in units of [J/mol/K].
Cvg
Gas-phase ideal-gas contant-volume heat capacity of the chemical at its current temperature, in units of [J/kg/K].
Cvgm
Gas-phase ideal-gas contant-volume heat capacity of the chemical at its current temperature, in units of [J/mol/K].
eos
Equation of state object held by the chemical; used to calculate excess thermodynamic quantities, and also provides a vapor pressure curve, enthalpy of vaporization curve, fugacity, thermodynamic partial derivatives, and more; see
thermo.eos
for a full listing.Hill
Hill formula of a compound.
Hvap
Enthalpy of vaporization of the chemical at its current temperature, in units of [J/kg].
Hvapm
Enthalpy of vaporization of the chemical at its current temperature, in units of [J/mol].
isentropic_exponent
Gas-phase ideal-gas isentropic exponent of the chemical at its current temperature, [dimensionless].
isobaric_expansion
Isobaric (constant-pressure) expansion of the chemical at its current phase and temperature, in units of [1/K].
isobaric_expansion_g
Isobaric (constant-pressure) expansion of the gas phase of the chemical at its current temperature and pressure, in units of [1/K].
isobaric_expansion_l
Isobaric (constant-pressure) expansion of the liquid phase of the chemical at its current temperature and pressure, in units of [1/K].
JT
Joule Thomson coefficient of the chemical at its current phase and temperature, in units of [K/Pa].
JTg
Joule Thomson coefficient of the chemical in the gas phase at its current temperature and pressure, in units of [K/Pa].
JTl
Joule Thomson coefficient of the chemical in the liquid phase at its current temperature and pressure, in units of [K/Pa].
k
Thermal conductivity of the chemical at its current phase, temperature, and pressure in units of [W/m/K].
kg
Thermal conductivity of the chemical in the gas phase at its current temperature and pressure, in units of [W/m/K].
kl
Thermal conductivity of the chemical in the liquid phase at its current temperature and pressure, in units of [W/m/K].
mass_fractions
Dictionary of atom:mass-weighted fractional occurence of elements.
mu
Viscosity of the chemical at its current phase, temperature, and pressure in units of [Pa*s].
mug
Viscosity of the chemical in the gas phase at its current temperature and pressure, in units of [Pa*s].
mul
Viscosity of the chemical in the liquid phase at its current temperature and pressure, in units of [Pa*s].
nu
Kinematic viscosity of the the chemical at its current temperature, pressure, and phase in units of [m^2/s].
nug
Kinematic viscosity of the gas phase of the chemical at its current temperature and pressure, in units of [m^2/s].
nul
Kinematic viscosity of the liquid phase of the chemical at its current temperature and pressure, in units of [m^2/s].
Parachor
Parachor of the chemical at its current temperature and pressure, in units of [N^0.25*m^2.75/mol].
permittivity
Relative permittivity (dielectric constant) of the chemical at its current temperature, [dimensionless].
Poynting
Poynting correction factor [dimensionless] for use in phase equilibria methods based on activity coefficients or other reference states.
Pr
Prandtl number of the chemical at its current temperature, pressure, and phase; [dimensionless].
Prg
Prandtl number of the gas phase of the chemical at its current temperature and pressure, [dimensionless].
Prl
Prandtl number of the liquid phase of the chemical at its current temperature and pressure, [dimensionless].
Psat
Vapor pressure of the chemical at its current temperature, in units of [Pa].
PSRK_groups
Dictionary of PSRK subgroup: count groups for the PSRK subgroups, as determined by DDBST’s online service.
rdkitmol
RDKit object of the chemical, without hydrogen.
rdkitmol_Hs
RDKit object of the chemical, with hydrogen.
rho
Mass density of the chemical at its current phase and temperature and pressure, in units of [kg/m^3].
rhog
Gas-phase mass density of the chemical at its current temperature and pressure, in units of [kg/m^3].
rhogm
Molar density of the chemical in the gas phase at the current temperature and pressure, in units of [mol/m^3].
rhol
Liquid-phase mass density of the chemical at its current temperature and pressure, in units of [kg/m^3].
rholm
Molar density of the chemical in the liquid phase at the current temperature and pressure, in units of [mol/m^3].
rhom
Molar density of the chemical at its current phase and temperature and pressure, in units of [mol/m^3].
rhos
Solid-phase mass density of the chemical at its current temperature, in units of [kg/m^3].
rhosm
Molar density of the chemical in the solid phase at the current temperature and pressure, in units of [mol/m^3].
rings
Number of rings in a chemical, computed with RDKit from a chemical’s SMILES.
SG
Specific gravity of the chemical, [dimensionless].
SGg
Specific gravity of the gas phase of the chemical, [dimensionless].
SGl
Specific gravity of the liquid phase of the chemical at the specified temperature and pressure, [dimensionless].
SGs
Specific gravity of the solid phase of the chemical at the specified temperature and pressure, [dimensionless].
sigma
Surface tension of the chemical at its current temperature, in units of [N/m].
solubility_parameter
Solubility parameter of the chemical at its current temperature and pressure, in units of [Pa^0.5].
UNIFAC_Dortmund_groups
Dictionary of Dortmund UNIFAC subgroup: count groups for the Dortmund UNIFAC subgroups, as determined by DDBST’s online service.
UNIFAC_groups
Dictionary of UNIFAC subgroup: count groups for the original UNIFAC subgroups, as determined by DDBST’s online service.
UNIFAC_R
UNIFAC R (normalized Van der Waals volume), dimensionless.
UNIFAC_Q
UNIFAC Q (normalized Van der Waals area), dimensionless.
Van_der_Waals_area
Unnormalized Van der Waals area, in units of [m^2/mol].
Van_der_Waals_volume
Unnormalized Van der Waals volume, in units of [m^3/mol].
Vm
Molar volume of the chemical at its current phase and temperature and pressure, in units of [m^3/mol].
Vmg
Gas-phase molar volume of the chemical at its current temperature and pressure, in units of [m^3/mol].
Vml
Liquid-phase molar volume of the chemical at its current temperature and pressure, in units of [m^3/mol].
Vms
Solid-phase molar volume of the chemical at its current temperature, in units of [m^3/mol].
Z
Compressibility factor of the chemical at its current phase and temperature and pressure, [dimensionless].
Zg
Compressibility factor of the chemical in the gas phase at the current temperature and pressure, [dimensionless].
Zl
Compressibility factor of the chemical in the liquid phase at the current temperature and pressure, [dimensionless].
Zs
Compressibility factor of the chemical in the solid phase at the current temperature and pressure, [dimensionless].
Methods
Reynolds
([V, D])draw_2d
([width, height, Hs])Interface for drawing a 2D image of the molecule.
draw_3d
([width, height, style, Hs, atom_labels])Interface for drawing an interactive 3D view of the molecule.
Bond
Capillary
Grashof
Jakob
Peclet_heat
Tsat
Weber
calc_H
calc_H_excess
calc_S
calc_S_excess
calculate
calculate_PH
calculate_PS
calculate_TH
calculate_TS
set_TP_sources
set_constant_sources
set_constants
set_eos
set_ref
set_thermo
- property A¶
Helmholtz energy of the chemical at its current temperature and pressure, in units of [J/kg].
This property requires that
thermo.chemical.set_thermo
ran successfully to be accurate. It also depends on the molar volume of the chemical at its current conditions.
- property API¶
API gravity of the liquid phase of the chemical, [degrees]. The reference condition is water at 15.6 °C (60 °F) and 1 atm (rho=999.016 kg/m^3, standardized).
Examples
>>> Chemical('water').API 10.
- property Am¶
Helmholtz energy of the chemical at its current temperature and pressure, in units of [J/mol].
This property requires that
thermo.chemical.set_thermo
ran successfully to be accurate. It also depends on the molar volume of the chemical at its current conditions.
- property Bvirial¶
Second virial coefficient of the gas phase of the chemical at its current temperature and pressure, in units of [mol/m^3].
This property uses the object-oriented interface
thermo.volume.VolumeGas
, converting its result withthermo.utils.B_from_Z
.Examples
>>> Chemical('water', T=500, P=1e5).Bvirial -0.00017
- property Cp¶
Mass heat capacity of the chemical at its current phase and temperature, in units of [J/kg/K].
Utilizes the object oriented interfaces
thermo.heat_capacity.HeatCapacitySolid
,thermo.heat_capacity.HeatCapacityLiquid
, andthermo.heat_capacity.HeatCapacityGas
to perform the actual calculation of each property. Note that those interfaces provide output in molar units (J/mol/K).Examples
>>> w = Chemical('water') >>> w.Cp, w.phase (4180., 'l') >>> Chemical('palladium').Cp 234.
- property Cpg¶
Gas-phase heat capacity of the chemical at its current temperature, in units of [J/kg/K]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.heat_capacity.HeatCapacityGas
; each Chemical instance creates one to actually perform the calculations. Note that that interface provides output in molar units.Examples
>>> w = Chemical('water', T=520) >>> w.Cpg 1967.
- property Cpgm¶
Gas-phase ideal gas heat capacity of the chemical at its current temperature, in units of [J/mol/K]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.heat_capacity.HeatCapacityGas
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('water').Cpgm 33.58 >>> Chemical('water').HeatCapacityGas.T_dependent_property(320) 33.67 >>> Chemical('water').HeatCapacityGas.T_dependent_property_integral(300, 320) 672.
- property Cpl¶
Liquid-phase heat capacity of the chemical at its current temperature, in units of [J/kg/K]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.heat_capacity.HeatCapacityLiquid
; each Chemical instance creates one to actually perform the calculations. Note that that interface provides output in molar units.Examples
>>> Chemical('water', T=320).Cpl 4177.
Ideal entropy change of water from 280 K to 340 K, output converted back to mass-based units of J/kg/K.
>>> dSm = Chemical('water').HeatCapacityLiquid.T_dependent_property_integral_over_T(280, 340) >>> property_molar_to_mass(dSm, Chemical('water').MW) 812.
- property Cplm¶
Liquid-phase heat capacity of the chemical at its current temperature, in units of [J/mol/K]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.heat_capacity.HeatCapacityLiquid
; each Chemical instance creates one to actually perform the calculations.Notes
Some methods give heat capacity along the saturation line, some at 1 atm but only up to the normal boiling point, and some give heat capacity at 1 atm up to the normal boiling point and then along the saturation line. Real-liquid heat capacity is pressure dependent, but this interface is not.
Examples
>>> Chemical('water').Cplm 75.3 >>> Chemical('water').HeatCapacityLiquid.T_dependent_property(320) 75.2 >>> Chemical('water').HeatCapacityLiquid.T_dependent_property_integral(300, 320) 1505.
- property Cpm¶
Molar heat capacity of the chemical at its current phase and temperature, in units of [J/mol/K].
Utilizes the object oriented interfaces
thermo.heat_capacity.HeatCapacitySolid
,thermo.heat_capacity.HeatCapacityLiquid
, andthermo.heat_capacity.HeatCapacityGas
to perform the actual calculation of each property.Examples
>>> Chemical('cubane').Cpm 137. >>> Chemical('ethylbenzene', T=550, P=3E6).Cpm 294.
- property Cps¶
Solid-phase heat capacity of the chemical at its current temperature, in units of [J/kg/K]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.heat_capacity.HeatCapacitySolid
; each Chemical instance creates one to actually perform the calculations. Note that that interface provides output in molar units.Examples
>>> Chemical('palladium', T=400).Cps 241. >>> Pd = Chemical('palladium', T=400) >>> Cpsms = [Pd.HeatCapacitySolid.T_dependent_property(T) for T in np.linspace(300, 500, 2)] >>> [property_molar_to_mass(Cps, Pd.MW) for Cps in Cpsms] [234., 248.]
- property Cpsm¶
Solid-phase heat capacity of the chemical at its current temperature, in units of [J/mol/K]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.heat_capacity.HeatCapacitySolid
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('palladium').Cpsm 24.9 >>> Chemical('palladium').HeatCapacitySolid.T_dependent_property(320) 25. >>> sorted(Chemical('palladium').HeatCapacitySolid.all_methods) ['CRCSTD', 'LASTOVKA_S', 'PERRY151']
- property Cvg¶
Gas-phase ideal-gas contant-volume heat capacity of the chemical at its current temperature, in units of [J/kg/K]. Subtracts R from the ideal-gas heat capacity; does not include pressure-compensation from an equation of state.
Examples
>>> w = Chemical('water', T=520) >>> w.Cvg 1506.
- property Cvgm¶
Gas-phase ideal-gas contant-volume heat capacity of the chemical at its current temperature, in units of [J/mol/K]. Subtracts R from the ideal-gas heat capacity; does not include pressure-compensation from an equation of state.
Examples
>>> w = Chemical('water', T=520) >>> w.Cvgm 27.1
- property Hill¶
Hill formula of a compound. For a description of the Hill system, see
chemicals.elements.atoms_to_Hill
.Examples
>>> Chemical('furfuryl alcohol').Hill 'C5H6O2'
- property Hvap¶
Enthalpy of vaporization of the chemical at its current temperature, in units of [J/kg].
This property uses the object-oriented interface
thermo.phase_change.EnthalpyVaporization
, but converts its results from molar to mass units.Examples
>>> Chemical('water', T=320).Hvap 2389540.
- property Hvapm¶
Enthalpy of vaporization of the chemical at its current temperature, in units of [J/mol]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.phase_change.EnthalpyVaporization
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('water', T=320).Hvapm 43048. >>> Chemical('water').EnthalpyVaporization.T_dependent_property(320) 43048. >>> sorted(Chemical('water').EnthalpyVaporization.all_methods) ['ALIBAKHSHI', 'CHEN', 'CLAPEYRON', 'COOLPROP', 'CRC_HVAP_298', 'CRC_HVAP_TB', 'DIPPR_PERRY_8E', 'LIU', 'MORGAN_KOBAYASHI', 'PITZER', 'RIEDEL', 'SIVARAMAN_MAGEE_KOBAYASHI', 'VDI_PPDS', 'VELASCO', 'VETERE']
- property JT¶
Joule Thomson coefficient of the chemical at its current phase and temperature, in units of [K/Pa].
\[\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) \]Examples
>>> Chemical('water').JT -2.21e-07
- property JTg¶
Joule Thomson coefficient of the chemical in the gas phase at its current temperature and pressure, in units of [K/Pa].
\[\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) \]Utilizes the temperature-derivative method of
thermo.volume.VolumeGas
and the temperature-dependent heat capacity methodthermo.heat_capacity.HeatCapacityGas
to obtain the properties required for the actual calculation.Examples
>>> Chemical('dodecane', T=400, P=1000).JTg 5.4e-05
- property JTl¶
Joule Thomson coefficient of the chemical in the liquid phase at its current temperature and pressure, in units of [K/Pa].
\[\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) \]Utilizes the temperature-derivative method of
thermo.volume.VolumeLiquid
and the temperature-dependent heat capacity methodthermo.heat_capacity.HeatCapacityLiquid
to obtain the properties required for the actual calculation.Examples
>>> Chemical('dodecane', T=400).JTl -3.1e-07
- property PSRK_groups¶
Dictionary of PSRK subgroup: count groups for the PSRK subgroups, as determined by DDBST’s online service.
Examples
>>> Chemical('Cumene').PSRK_groups {1: 2, 9: 5, 13: 1}
- property Parachor¶
Parachor of the chemical at its current temperature and pressure, in units of [N^0.25*m^2.75/mol].
\[P = \frac{\sigma^{0.25} MW}{\rho_L - \rho_V} \]Calculated based on surface tension, density of the liquid phase, and molecular weight. For uses of this property, see
thermo.utils.Parachor
.The gas density is calculated using the ideal-gas law.
Examples
>>> Chemical('octane').Parachor 6.2e-05
- property Poynting¶
Poynting correction factor [dimensionless] for use in phase equilibria methods based on activity coefficients or other reference states. Performs the shortcut calculation assuming molar volume is independent of pressure.
\[\text{Poy} = \exp\left[\frac{V_l (P-P^{sat})}{RT}\right] \]The full calculation normally returns values very close to the approximate ones. This property is defined in terms of pure components only.
Notes
The full equation shown below can be used as follows:
\[\text{Poy} = \exp\left[\frac{\int_{P_i^{sat}}^P V_i^l dP}{RT}\right] \]>>> from scipy.integrate import quad >>> c = Chemical('pentane', T=300, P=2e6) >>> exp(quad(lambda P : c.VolumeLiquid(c.T, P), c.Psat, c.P)[0]/R/c.T) 1.093
Examples
>>> Chemical('pentane', T=300, P=2e6).Poynting 1.09
- property Pr¶
Prandtl number of the chemical at its current temperature, pressure, and phase; [dimensionless].
\[Pr = \frac{C_p \mu}{k} \]Examples
>>> Chemical('acetone').Pr 4.1
- property Prg¶
Prandtl number of the gas phase of the chemical at its current temperature and pressure, [dimensionless].
\[Pr = \frac{C_p \mu}{k} \]Utilizes the temperature and pressure dependent object oriented interfaces
thermo.viscosity.ViscosityGas
,thermo.thermal_conductivity.ThermalConductivityGas
, andthermo.heat_capacity.HeatCapacityGas
to calculate the actual properties.Examples
>>> Chemical('NH3').Prg 0.84
- property Prl¶
Prandtl number of the liquid phase of the chemical at its current temperature and pressure, [dimensionless].
\[Pr = \frac{C_p \mu}{k} \]Utilizes the temperature and pressure dependent object oriented interfaces
thermo.viscosity.ViscosityLiquid
,thermo.thermal_conductivity.ThermalConductivityLiquid
, andthermo.heat_capacity.HeatCapacityLiquid
to calculate the actual properties.Examples
>>> Chemical('nitrogen', T=70).Prl 2.78
- property Psat¶
Vapor pressure of the chemical at its current temperature, in units of [Pa]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.vapor_pressure.VaporPressure
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('water', T=320).Psat 10545. >>> Chemical('water').VaporPressure.T_dependent_property(320) 10545. >>> sorted(Chemical('water').VaporPressure.all_methods) ['AMBROSE_WALTON', 'ANTOINE_POLING', 'ANTOINE_WEBBOOK', 'BOILING_CRITICAL', 'COOLPROP', 'DIPPR_PERRY_8E', 'EDALAT', 'EOS', 'IAPWS', 'LEE_KESLER_PSAT', 'SANJARI', 'VDI_PPDS', 'WAGNER_MCGARRY']
- property R_specific¶
Specific gas constant, in units of [J/kg/K].
Examples
>>> Chemical('water').R_specific 461.5
- property SG¶
Specific gravity of the chemical, [dimensionless].
For gas-phase conditions, this is calculated at 15.6 °C (60 °F) and 1 atm for the chemical and the reference fluid, air. For liquid and solid phase conditions, this is calculated based on a reference fluid of water at 4°C at 1 atm, but the with the liquid or solid chemical’s density at the currently specified conditions.
Examples
>>> Chemical('MTBE').SG 0.73
- property SGg¶
Specific gravity of the gas phase of the chemical, [dimensionless]. The reference condition is air at 15.6 °C (60 °F) and 1 atm (rho=1.223 kg/m^3). The definition for gases uses the compressibility factor of the reference gas and the chemical both at the reference conditions, not the conditions of the chemical.
Examples
>>> Chemical('argon').SGg 1.3
- property SGl¶
Specific gravity of the liquid phase of the chemical at the specified temperature and pressure, [dimensionless]. The reference condition is water at 4 °C and 1 atm (rho=999.017 kg/m^3). For liquids, SG is defined that the reference chemical’s T and P are fixed, but the chemical itself varies with the specified T and P.
Examples
>>> Chemical('water', T=365).SGl 0.965
- property SGs¶
Specific gravity of the solid phase of the chemical at the specified temperature and pressure, [dimensionless]. The reference condition is water at 4 °C and 1 atm (rho=999.017 kg/m^3). The SG varries with temperature and pressure but only very slightly.
Examples
>>> Chemical('iron').SGs 7.8
- property U¶
Internal energy of the chemical at its current temperature and pressure, in units of [J/kg].
This property requires that
thermo.chemical.set_thermo
ran successfully to be accurate. It also depends on the molar volume of the chemical at its current conditions.
- property UNIFAC_Dortmund_groups¶
Dictionary of Dortmund UNIFAC subgroup: count groups for the Dortmund UNIFAC subgroups, as determined by DDBST’s online service.
Examples
>>> Chemical('Cumene').UNIFAC_Dortmund_groups {1: 2, 9: 5, 13: 1}
- property UNIFAC_Q¶
UNIFAC Q (normalized Van der Waals area), dimensionless. Used in the UNIFAC model.
Examples
>>> Chemical('decane').UNIFAC_Q 6.016
- property UNIFAC_R¶
UNIFAC R (normalized Van der Waals volume), dimensionless. Used in the UNIFAC model.
Examples
>>> Chemical('benzene').UNIFAC_R 3.1878
- property UNIFAC_groups¶
Dictionary of UNIFAC subgroup: count groups for the original UNIFAC subgroups, as determined by DDBST’s online service.
Examples
>>> Chemical('Cumene').UNIFAC_groups {1: 2, 9: 5, 13: 1}
- property Um¶
Internal energy of the chemical at its current temperature and pressure, in units of [J/mol].
This property requires that
thermo.chemical.set_thermo
ran successfully to be accurate. It also depends on the molar volume of the chemical at its current conditions.
- property Van_der_Waals_area¶
Unnormalized Van der Waals area, in units of [m^2/mol].
Examples
>>> Chemical('hexane').Van_der_Waals_area 964000.0
- property Van_der_Waals_volume¶
Unnormalized Van der Waals volume, in units of [m^3/mol].
Examples
>>> Chemical('hexane').Van_der_Waals_volume 6.8261966e-05
- property Vm¶
Molar volume of the chemical at its current phase and temperature and pressure, in units of [m^3/mol].
Utilizes the object oriented interfaces
thermo.volume.VolumeSolid
,thermo.volume.VolumeLiquid
, andthermo.volume.VolumeGas
to perform the actual calculation of each property.Examples
>>> Chemical('ethylbenzene', T=550, P=3E6).Vm 0.00017
- property Vmg¶
Gas-phase molar volume of the chemical at its current temperature and pressure, in units of [m^3/mol]. For calculation of this property at other temperatures or pressures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.volume.VolumeGas
; each Chemical instance creates one to actually perform the calculations.Examples
Estimate the molar volume of the core of the sun, at 15 million K and 26.5 PetaPascals, assuming pure helium (actually 68% helium):
>>> Chemical('helium', T=15E6, P=26.5E15).Vmg 4.7e-07
- property Vmg_ideal¶
Gas-phase molar volume of the chemical at its current temperature and pressure calculated with the ideal-gas law, in units of [m^3/mol].
Examples
>>> Chemical('helium', T=300.0, P=1e5).Vmg_ideal 0.0249433878544
- property Vml¶
Liquid-phase molar volume of the chemical at its current temperature and pressure, in units of [m^3/mol]. For calculation of this property at other temperatures or pressures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.volume.VolumeLiquid
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('cyclobutane', T=225).Vml 7.42395423425395e-05
- property Vms¶
Solid-phase molar volume of the chemical at its current temperature, in units of [m^3/mol]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.volume.VolumeSolid
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('iron').Vms 7.09e-06
- property Z¶
Compressibility factor of the chemical at its current phase and temperature and pressure, [dimensionless].
Examples
>>> Chemical('MTBE', T=900, P=1E-2).Z 1.
- property Zg¶
Compressibility factor of the chemical in the gas phase at the current temperature and pressure, [dimensionless].
Utilizes the object oriented interface and
thermo.volume.VolumeGas
to perform the actual calculation of molar volume.Examples
>>> Chemical('sulfur hexafluoride', T=700, P=1E9).Zg 11.14
- property Zl¶
Compressibility factor of the chemical in the liquid phase at the current temperature and pressure, [dimensionless].
Utilizes the object oriented interface and
thermo.volume.VolumeLiquid
to perform the actual calculation of molar volume.Examples
>>> Chemical('water').Zl 0.00073
- property Zs¶
Compressibility factor of the chemical in the solid phase at the current temperature and pressure, [dimensionless].
Utilizes the object oriented interface and
thermo.volume.VolumeSolid
to perform the actual calculation of molar volume.Examples
>>> Chemical('palladium').Z 0.000362
- property absolute_permittivity¶
Absolute permittivity of the chemical at its current temperature, in units of [farad/meter]. Those units are equivalent to ampere^2*second^4/kg/m^3.
Examples
>>> Chemical('water', T=293.15).absolute_permittivity 7.1e-10
- property alpha¶
Thermal diffusivity of the chemical at its current temperature, pressure, and phase in units of [m^2/s].
\[\alpha = \frac{k}{\rho Cp} \]Examples
>>> Chemical('furfural').alpha 8.7e-08
- property alphag¶
Thermal diffusivity of the gas phase of the chemical at its current temperature and pressure, in units of [m^2/s].
\[\alpha = \frac{k}{\rho Cp} \]Utilizes the temperature and pressure dependent object oriented interfaces
thermo.volume.VolumeGas
,thermo.thermal_conductivity.ThermalConductivityGas
, andthermo.heat_capacity.HeatCapacityGas
to calculate the actual properties.Examples
>>> Chemical('ammonia').alphag 1.69e-05
- property alphal¶
Thermal diffusivity of the liquid phase of the chemical at its current temperature and pressure, in units of [m^2/s].
\[\alpha = \frac{k}{\rho Cp} \]Utilizes the temperature and pressure dependent object oriented interfaces
thermo.volume.VolumeLiquid
,thermo.thermal_conductivity.ThermalConductivityLiquid
, andthermo.heat_capacity.HeatCapacityLiquid
to calculate the actual properties.Examples
>>> Chemical('nitrogen', T=70).alphal 9.4e-08
- property aromatic_rings¶
Number of aromatic rings in a chemical, computed with RDKit from a chemical’s SMILES. If RDKit is not available, holds None.
Examples
>>> Chemical('Paclitaxel').aromatic_rings 3
- property atom_fractions¶
Dictionary of atom:fractional occurence of the elements in a chemical. Useful when performing element balances. For mass-fraction occurences, see
mass_fractions
.Examples
>>> Chemical('Ammonium aluminium sulfate').atom_fractions {'Al': 0.0625, 'H': 0.25, 'N': 0.0625, 'O': 0.5, 'S': 0.125}
- property charge¶
Charge of a chemical, computed with RDKit from a chemical’s SMILES. If RDKit is not available, holds None.
Examples
>>> Chemical('sodium ion').charge 1
- draw_2d(width=300, height=300, Hs=False)[source]¶
Interface for drawing a 2D image of the molecule. Requires an HTML5 browser, and the libraries RDKit and IPython. An exception is raised if either of these libraries is absent.
- Parameters
- widthint
Number of pixels wide for the view
- heightint
Number of pixels tall for the view
- Hsbool
Whether or not to show hydrogen
Examples
>>> Chemical('decane').draw_2d() <PIL.PngImagePlugin.PngImageFile image mode=RGB size=300x300 at 0x...>
- draw_3d(width=300, height=500, style='stick', Hs=True, atom_labels=True)[source]¶
Interface for drawing an interactive 3D view of the molecule. Requires an HTML5 browser, and the libraries RDKit, pymol3D, and IPython. An exception is raised if all three of these libraries are not installed.
- Parameters
- widthint
Number of pixels wide for the view, [pixels]
- heightint
Number of pixels tall for the view, [pixels]
- stylestr
One of ‘stick’, ‘line’, ‘cross’, or ‘sphere’, [-]
- Hsbool
Whether or not to show hydrogen, [-]
- atom_labelsbool
Whether or not to label the atoms, [-]
Examples
>>> Chemical('cubane').draw_3d() None
- property economic_status¶
Dictionary of economic status indicators for the chemical.
Examples
>>> Chemical('benzene').economic_status ["US public: {'Manufactured': 6165232.1, 'Imported': 463146.474, 'Exported': 271908.252}", '1,000,000 - 10,000,000 tonnes per annum', 'Intermediate Use Only', 'OECD HPV Chemicals']
- property eos¶
Equation of state object held by the chemical; used to calculate excess thermodynamic quantities, and also provides a vapor pressure curve, enthalpy of vaporization curve, fugacity, thermodynamic partial derivatives, and more; see
thermo.eos
for a full listing.Examples
>>> Chemical('methane').eos.V_g 0.0244
- property is_acid¶
Method to return whether or not this chemical is in the category acid, [-]
- property is_acyl_halide¶
Method to return whether or not this chemical is in the category acyl_halide, [-]
- property is_alcohol¶
Method to return whether or not this chemical is in the category alcohol, [-]
- property is_aldehyde¶
Method to return whether or not this chemical is in the category aldehyde, [-]
- property is_alkane¶
Method to return whether or not this chemical is in the category alkane, [-]
- property is_alkene¶
Method to return whether or not this chemical is in the category alkene, [-]
- property is_alkylaluminium¶
Method to return whether or not this chemical is in the category alkylaluminium, [-]
- property is_alkyllithium¶
Method to return whether or not this chemical is in the category alkyllithium, [-]
- property is_alkylmagnesium_halide¶
Method to return whether or not this chemical is in the category alkylmagnesium_halide, [-]
- property is_alkyne¶
Method to return whether or not this chemical is in the category alkyne, [-]
- property is_amide¶
Method to return whether or not this chemical is in the category amide, [-]
- property is_amidine¶
Method to return whether or not this chemical is in the category amidine, [-]
- property is_amine¶
Method to return whether or not this chemical is in the category amine, [-]
- property is_anhydride¶
Method to return whether or not this chemical is in the category anhydride, [-]
- property is_aromatic¶
Method to return whether or not this chemical is in the category aromatic, [-]
- property is_azide¶
Method to return whether or not this chemical is in the category azide, [-]
- property is_azo¶
Method to return whether or not this chemical is in the category azo, [-]
- property is_borinic_acid¶
Method to return whether or not this chemical is in the category borinic_acid, [-]
- property is_borinic_ester¶
Method to return whether or not this chemical is in the category borinic_ester, [-]
- property is_boronic_acid¶
Method to return whether or not this chemical is in the category boronic_acid, [-]
- property is_boronic_ester¶
Method to return whether or not this chemical is in the category boronic_ester, [-]
- property is_branched_alkane¶
Method to return whether or not this chemical is in the category branched_alkane, [-]
- property is_bromoalkane¶
Method to return whether or not this chemical is in the category bromoalkane, [-]
- property is_carbamate¶
Method to return whether or not this chemical is in the category carbamate, [-]
- property is_carbodithio¶
Method to return whether or not this chemical is in the category carbodithio, [-]
- property is_carbodithioic_acid¶
Method to return whether or not this chemical is in the category carbodithioic_acid, [-]
- property is_carbonate¶
Method to return whether or not this chemical is in the category carbonate, [-]
- property is_carbothioic_o_acid¶
Method to return whether or not this chemical is in the category carbothioic_o_acid, [-]
- property is_carbothioic_s_acid¶
Method to return whether or not this chemical is in the category carbothioic_s_acid, [-]
- property is_carboxylate¶
Method to return whether or not this chemical is in the category carboxylate, [-]
- property is_carboxylic_acid¶
Method to return whether or not this chemical is in the category carboxylic_acid, [-]
- property is_carboxylic_anhydride¶
Method to return whether or not this chemical is in the category carboxylic_anhydride, [-]
- property is_chloroalkane¶
Method to return whether or not this chemical is in the category chloroalkane, [-]
- property is_cyanate¶
Method to return whether or not this chemical is in the category cyanate, [-]
- property is_cycloalkane¶
Method to return whether or not this chemical is in the category cycloalkane, [-]
- property is_disulfide¶
Method to return whether or not this chemical is in the category disulfide, [-]
- property is_ester¶
Method to return whether or not this chemical is in the category ester, [-]
- property is_ether¶
Method to return whether or not this chemical is in the category ether, [-]
- property is_fluoroalkane¶
Method to return whether or not this chemical is in the category fluoroalkane, [-]
- property is_haloalkane¶
Method to return whether or not this chemical is in the category haloalkane, [-]
- property is_hydroperoxide¶
Method to return whether or not this chemical is in the category hydroperoxide, [-]
- property is_imide¶
Method to return whether or not this chemical is in the category imide, [-]
- property is_imine¶
Method to return whether or not this chemical is in the category imine, [-]
- property is_inorganic¶
Method to return whether or not this chemical is in the category inorganic, [-]
- property is_iodoalkane¶
Method to return whether or not this chemical is in the category iodoalkane, [-]
- property is_is_hydrocarbon¶
Method to return whether or not this chemical is in the category is_hydrocarbon, [-]
- property is_isocyanate¶
Method to return whether or not this chemical is in the category isocyanate, [-]
- property is_isonitrile¶
Method to return whether or not this chemical is in the category isonitrile, [-]
- property is_isothiocyanate¶
Method to return whether or not this chemical is in the category isothiocyanate, [-]
- property is_ketone¶
Method to return whether or not this chemical is in the category ketone, [-]
- property is_mercaptan¶
Method to return whether or not this chemical is in the category mercaptan, [-]
- property is_methylenedioxy¶
Method to return whether or not this chemical is in the category methylenedioxy, [-]
- property is_nitrate¶
Method to return whether or not this chemical is in the category nitrate, [-]
- property is_nitrile¶
Method to return whether or not this chemical is in the category nitrile, [-]
- property is_nitrite¶
Method to return whether or not this chemical is in the category nitrite, [-]
- property is_nitro¶
Method to return whether or not this chemical is in the category nitro, [-]
- property is_nitroso¶
Method to return whether or not this chemical is in the category nitroso, [-]
- property is_organic¶
Method to return whether or not this chemical is in the category organic, [-]
- property is_orthocarbonate_ester¶
Method to return whether or not this chemical is in the category orthocarbonate_ester, [-]
- property is_orthoester¶
Method to return whether or not this chemical is in the category orthoester, [-]
- property is_oxime¶
Method to return whether or not this chemical is in the category oxime, [-]
- property is_peroxide¶
Method to return whether or not this chemical is in the category peroxide, [-]
- property is_phenol¶
Method to return whether or not this chemical is in the category phenol, [-]
- property is_phosphate¶
Method to return whether or not this chemical is in the category phosphate, [-]
- property is_phosphine¶
Method to return whether or not this chemical is in the category phosphine, [-]
- property is_phosphodiester¶
Method to return whether or not this chemical is in the category phosphodiester, [-]
- property is_phosphonic_acid¶
Method to return whether or not this chemical is in the category phosphonic_acid, [-]
- property is_polyol¶
Method to return whether or not this chemical is in the category polyol, [-]
- property is_primary_aldimine¶
Method to return whether or not this chemical is in the category primary_aldimine, [-]
- property is_primary_amine¶
Method to return whether or not this chemical is in the category primary_amine, [-]
- property is_primary_ketimine¶
Method to return whether or not this chemical is in the category primary_ketimine, [-]
- property is_pyridyl¶
Method to return whether or not this chemical is in the category pyridyl, [-]
- property is_quat¶
Method to return whether or not this chemical is in the category quat, [-]
- property is_secondary_aldimine¶
Method to return whether or not this chemical is in the category secondary_aldimine, [-]
- property is_secondary_amine¶
Method to return whether or not this chemical is in the category secondary_amine, [-]
- property is_secondary_ketimine¶
Method to return whether or not this chemical is in the category secondary_ketimine, [-]
- property is_siloxane¶
Method to return whether or not this chemical is in the category siloxane, [-]
- property is_silyl_ether¶
Method to return whether or not this chemical is in the category silyl_ether, [-]
- property is_sulfide¶
Method to return whether or not this chemical is in the category sulfide, [-]
- property is_sulfinic_acid¶
Method to return whether or not this chemical is in the category sulfinic_acid, [-]
- property is_sulfonate_ester¶
Method to return whether or not this chemical is in the category sulfonate_ester, [-]
- property is_sulfone¶
Method to return whether or not this chemical is in the category sulfone, [-]
- property is_sulfonic_acid¶
Method to return whether or not this chemical is in the category sulfonic_acid, [-]
- property is_sulfoxide¶
Method to return whether or not this chemical is in the category sulfoxide, [-]
- property is_tertiary_amine¶
Method to return whether or not this chemical is in the category tertiary_amine, [-]
- property is_thial¶
Method to return whether or not this chemical is in the category thial, [-]
- property is_thiocyanate¶
Method to return whether or not this chemical is in the category thiocyanate, [-]
- property is_thioketone¶
Method to return whether or not this chemical is in the category thioketone, [-]
- property is_thiolester¶
Method to return whether or not this chemical is in the category thiolester, [-]
- property is_thionoester¶
Method to return whether or not this chemical is in the category thionoester, [-]
- property isentropic_exponent¶
Gas-phase ideal-gas isentropic exponent of the chemical at its current temperature, [dimensionless]. Does not include pressure-compensation from an equation of state.
Examples
>>> Chemical('hydrogen').isentropic_exponent 1.40
- property isobaric_expansion¶
Isobaric (constant-pressure) expansion of the chemical at its current phase and temperature, in units of [1/K].
\[\beta = \frac{1}{V}\left(\frac{\partial V}{\partial T} \right)_P \]Examples
Radical change in value just above and below the critical temperature of water:
>>> Chemical('water', T=647.1, P=22048320.0).isobaric_expansion 0.77
>>> Chemical('water', T=647.2, P=22048320.0).isobaric_expansion 0.39
- property isobaric_expansion_g¶
Isobaric (constant-pressure) expansion of the gas phase of the chemical at its current temperature and pressure, in units of [1/K].
\[\beta = \frac{1}{V}\left(\frac{\partial V}{\partial T} \right)_P \]Utilizes the temperature-derivative method of
thermo.VolumeGas
to perform the actual calculation. The derivatives are all numerical.Examples
>>> Chemical('Hexachlorobenzene', T=900).isobaric_expansion_g 0.00115
- property isobaric_expansion_l¶
Isobaric (constant-pressure) expansion of the liquid phase of the chemical at its current temperature and pressure, in units of [1/K].
\[\beta = \frac{1}{V}\left(\frac{\partial V}{\partial T} \right)_P \]Utilizes the temperature-derivative method of
thermo.volume.VolumeLiquid
to perform the actual calculation. The derivatives are all numerical.Examples
>>> Chemical('dodecane', T=400).isobaric_expansion_l 0.00116
- property k¶
Thermal conductivity of the chemical at its current phase, temperature, and pressure in units of [W/m/K].
Utilizes the object oriented interfaces
thermo.thermal_conductivity.ThermalConductivityLiquid
andthermo.thermal_conductivity.ThermalConductivityGas
to perform the actual calculation of each property.Examples
>>> Chemical('ethanol', T=300).kl 0.16 >>> Chemical('ethanol', T=400).kg 0.026
- property kg¶
Thermal conductivity of the chemical in the gas phase at its current temperature and pressure, in units of [W/m/K].
For calculation of this property at other temperatures and pressures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.thermal_conductivity.ThermalConductivityGas
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('water', T=320, P=100).kg 0.02
- property kl¶
Thermal conductivity of the chemical in the liquid phase at its current temperature and pressure, in units of [W/m/K].
For calculation of this property at other temperatures and pressures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.thermal_conductivity.ThermalConductivityLiquid
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('water', T=320).kl 0.63
- property legal_status¶
Dictionary of legal status indicators for the chemical.
Examples
>>> Chemical('benzene').legal_status {'DSL': 'LISTED', 'TSCA': 'LISTED', 'EINECS': 'LISTED', 'NLP': 'UNLISTED', 'SPIN': 'LISTED'}
- property mass_fractions¶
Dictionary of atom:mass-weighted fractional occurence of elements. Useful when performing mass balances. For atom-fraction occurences, see
atom_fractions
.Examples
>>> Chemical('water').mass_fractions {'H': 0.11189834407236524, 'O': 0.8881016559276347}
- property mu¶
Viscosity of the chemical at its current phase, temperature, and pressure in units of [Pa*s].
Utilizes the object oriented interfaces
thermo.viscosity.ViscosityLiquid
andthermo.viscosity.ViscosityGas
to perform the actual calculation of each property.Examples
>>> Chemical('ethanol', T=300).mu 0.0010 >>> Chemical('ethanol', T=400).mu 1.18e-05
- property mug¶
Viscosity of the chemical in the gas phase at its current temperature and pressure, in units of [Pa*s].
For calculation of this property at other temperatures and pressures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.viscosity.ViscosityGas
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('water', T=320, P=100).mug 1.04e-05
- property mul¶
Viscosity of the chemical in the liquid phase at its current temperature and pressure, in units of [Pa*s].
For calculation of this property at other temperatures and pressures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.viscosity.ViscosityLiquid
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('water', T=320).mul 0.000576
- property nu¶
Kinematic viscosity of the the chemical at its current temperature, pressure, and phase in units of [m^2/s].
\[\nu = \frac{\mu}{\rho} \]Examples
>>> Chemical('argon').nu 1.38e-05
- property nug¶
Kinematic viscosity of the gas phase of the chemical at its current temperature and pressure, in units of [m^2/s].
\[\nu = \frac{\mu}{\rho} \]Utilizes the temperature and pressure dependent object oriented interfaces
thermo.volume.VolumeGas
,thermo.viscosity.ViscosityGas
to calculate the actual properties.Examples
>>> Chemical('methane', T=115).nug 2.5e-06
- property nul¶
Kinematic viscosity of the liquid phase of the chemical at its current temperature and pressure, in units of [m^2/s].
\[\nu = \frac{\mu}{\rho} \]Utilizes the temperature and pressure dependent object oriented interfaces
thermo.volume.VolumeLiquid
,thermo.viscosity.ViscosityLiquid
to calculate the actual properties.Examples
>>> Chemical('methane', T=110).nul 2.858e-07
- property permittivity¶
Relative permittivity (dielectric constant) of the chemical at its current temperature, [dimensionless].
For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.permittivity.PermittivityLiquid
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('toluene', T=250).permittivity 2.497
- property rdkitmol¶
RDKit object of the chemical, without hydrogen. If RDKit is not available, holds None.
For examples of what can be done with RDKit, see their website.
- property rdkitmol_Hs¶
RDKit object of the chemical, with hydrogen. If RDKit is not available, holds None.
For examples of what can be done with RDKit, see their website.
- property rho¶
Mass density of the chemical at its current phase and temperature and pressure, in units of [kg/m^3].
Utilizes the object oriented interfaces
thermo.volume.VolumeSolid
,thermo.volume.VolumeLiquid
, andthermo.volume.VolumeGas
to perform the actual calculation of each property. Note that those interfaces provide output in units of m^3/mol.Examples
>>> Chemical('decane', T=550, P=2E6).rho 498.
- property rhog¶
Gas-phase mass density of the chemical at its current temperature and pressure, in units of [kg/m^3]. For calculation of this property at other temperatures or pressures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.volume.VolumeGas
; each Chemical instance creates one to actually perform the calculations. Note that that interface provides output in molar units.Examples
Estimate the density of the core of the sun, at 15 million K and 26.5 PetaPascals, assuming pure helium (actually 68% helium):
>>> Chemical('helium', T=15E6, P=26.5E15).rhog 8519.
Compared to a result on Wikipedia of 150000 kg/m^3, the fundamental equation of state performs poorly.
>>> He = Chemical('helium', T=15E6, P=26.5E15) >>> He.VolumeGas.method_P = 'IDEAL' >>> He.rhog 850477.
The ideal-gas law performs somewhat better, but vastly overshoots the density prediction.
- property rhogm¶
Molar density of the chemical in the gas phase at the current temperature and pressure, in units of [mol/m^3].
Utilizes the object oriented interface and
thermo.volume.VolumeGas
to perform the actual calculation of molar volume.Examples
>>> Chemical('tungsten hexafluoride').rhogm 42.
- property rhol¶
Liquid-phase mass density of the chemical at its current temperature and pressure, in units of [kg/m^3]. For calculation of this property at other temperatures and pressures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.volume.VolumeLiquid
; each Chemical instance creates one to actually perform the calculations. Note that that interface provides output in molar units.Examples
>>> Chemical('o-xylene', T=297).rhol 876.9946785618097
- property rholm¶
Molar density of the chemical in the liquid phase at the current temperature and pressure, in units of [mol/m^3].
Utilizes the object oriented interface and
thermo.volume.VolumeLiquid
to perform the actual calculation of molar volume.Examples
>>> Chemical('nitrogen', T=70).rholm 29937.
- property rhom¶
Molar density of the chemical at its current phase and temperature and pressure, in units of [mol/m^3].
Utilizes the object oriented interfaces
thermo.volume.VolumeSolid
,thermo.volume.VolumeLiquid
, andthermo.volume.VolumeGas
to perform the actual calculation of each property. Note that those interfaces provide output in units of m^3/mol.Examples
>>> Chemical('1-hexanol').rhom 7986.
- property rhos¶
Solid-phase mass density of the chemical at its current temperature, in units of [kg/m^3]. For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.volume.VolumeSolid
; each Chemical instance creates one to actually perform the calculations. Note that that interface provides output in molar units.Examples
>>> Chemical('iron').rhos 7870.
- property rhosm¶
Molar density of the chemical in the solid phase at the current temperature and pressure, in units of [mol/m^3].
Utilizes the object oriented interface and
thermo.volume.VolumeSolid
to perform the actual calculation of molar volume.Examples
>>> Chemical('palladium').rhosm 112760.
- property rings¶
Number of rings in a chemical, computed with RDKit from a chemical’s SMILES. If RDKit is not available, holds None.
Examples
>>> Chemical('Paclitaxel').rings 7
- property sigma¶
Surface tension of the chemical at its current temperature, in units of [N/m].
For calculation of this property at other temperatures, or specifying manually the method used to calculate it, and more - see the object oriented interface
thermo.interface.SurfaceTension
; each Chemical instance creates one to actually perform the calculations.Examples
>>> Chemical('water', T=320).sigma 0.068 >>> Chemical('water', T=320).SurfaceTension.solve_property(0.05) 417.2
- property solubility_parameter¶
Solubility parameter of the chemical at its current temperature and pressure, in units of [Pa^0.5].
\[\delta = \sqrt{\frac{\Delta H_{vap} - RT}{V_m}} \]Calculated based on enthalpy of vaporization and molar volume. Normally calculated at STP. For uses of this property, see
thermo.solubility.solubility_parameter
.Examples
>>> Chemical('NH3', T=200).solubility_parameter 31712.
Chemical Constants and Correlations (thermo.chemical_package)¶
This module contains classes for storing data and objects which are necessary for doing thermodynamic calculations. The intention for these classes is to serve as an in-memory storage layer between the disk and methods which do full thermodynamic calculations.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Chemical Constants Class¶
- class thermo.chemical_package.ChemicalConstantsPackage(CASs=None, names=None, MWs=None, Tms=None, Tbs=None, Tcs=None, Pcs=None, Vcs=None, omegas=None, Zcs=None, rhocs=None, rhocs_mass=None, Hfus_Tms=None, Hfus_Tms_mass=None, Hvap_Tbs=None, Hvap_Tbs_mass=None, Vml_STPs=None, rhol_STPs=None, rhol_STPs_mass=None, Vml_60Fs=None, rhol_60Fs=None, rhol_60Fs_mass=None, Vmg_STPs=None, rhog_STPs=None, rhog_STPs_mass=None, Hfgs=None, Hfgs_mass=None, Gfgs=None, Gfgs_mass=None, Sfgs=None, Sfgs_mass=None, S0gs=None, S0gs_mass=None, Hf_STPs=None, Hf_STPs_mass=None, Tts=None, Pts=None, Hsub_Tts=None, Hsub_Tts_mass=None, Hcs=None, Hcs_mass=None, Hcs_lower=None, Hcs_lower_mass=None, Tflashs=None, Tautoignitions=None, LFLs=None, UFLs=None, TWAs=None, STELs=None, Ceilings=None, Skins=None, Carcinogens=None, legal_statuses=None, economic_statuses=None, GWPs=None, ODPs=None, logPs=None, Psat_298s=None, Hvap_298s=None, Hvap_298s_mass=None, Vml_Tms=None, rhos_Tms=None, Vms_Tms=None, rhos_Tms_mass=None, sigma_STPs=None, sigma_Tbs=None, sigma_Tms=None, RIs=None, RI_Ts=None, conductivities=None, conductivity_Ts=None, charges=None, dipoles=None, Stockmayers=None, molecular_diameters=None, Van_der_Waals_volumes=None, Van_der_Waals_areas=None, Parachors=None, StielPolars=None, atomss=None, atom_fractions=None, similarity_variables=None, phase_STPs=None, solubility_parameters=None, PubChems=None, formulas=None, smiless=None, InChIs=None, InChI_Keys=None, aliases=None, UNIFAC_groups=None, UNIFAC_Dortmund_groups=None, PSRK_groups=None, UNIFAC_Rs=None, UNIFAC_Qs=None)[source]¶
Class for storing efficiently chemical constants for a group of components. This is intended as a base object from which a set of thermodynamic methods can access miscellaneous for purposes such as phase identification or initialization.
- Parameters
- Nint
Number of components in the package, [-].
- cmpsrange
Iterator over all components, [-].
- rhol_60Fslist[float]
Liquid molar densities for each component at 60 °F, [mol/m^3].
- atom_fractionslist[dict]
Breakdown of each component into its elemental fractions, as a dict, [-].
- atomsslist[dict]
Breakdown of each component into its elements and their counts, as a dict, [-].
- Carcinogenslist[dict]
Status of each component in cancer causing registries, [-].
- CASslist[str]
CAS registration numbers for each component, [-].
- Ceilingslist[tuple[(float, str)]]
Ceiling exposure limits to chemicals (and their units; ppm or mg/m^3), [various].
- chargeslist[float]
Charge number (valence) for each component, [-].
- conductivitieslist[float]
Electrical conductivities for each component, [S/m].
- conductivity_Tslist[float]
Temperatures at which the electrical conductivities for each component were measured, [K].
- dipoleslist[float]
Dipole moments for each component, [debye].
- economic_statuseslist[dict]
Status of each component in in relation to import and export from various regions, [-].
- formulaslist[str]
Formulas of each component, [-].
- Gfgslist[float]
Ideal gas standard molar Gibbs free energy of formation for each component, [J/mol].
- Gfgs_masslist[float]
Ideal gas standard Gibbs free energy of formation for each component, [J/kg].
- GWPslist[float]
Global Warming Potentials for each component (impact/mass chemical)/(impact/mass CO2), [-].
- Hcslist[float]
Higher standard molar heats of combustion for each component, [J/mol].
- Hcs_masslist[float]
Higher standard heats of combustion for each component, [J/kg].
- Hcs_lowerlist[float]
Lower standard molar heats of combustion for each component, [J/mol].
- Hcs_lower_masslist[float]
Lower standard heats of combustion for each component, [J/kg].
- Hfgslist[float]
Ideal gas standard molar enthalpies of formation for each component, [J/mol].
- Hfgs_masslist[float]
Ideal gas standard enthalpies of formation for each component, [J/kg].
- Hfus_Tmslist[float]
Molar heats of fusion for each component at their respective melting points, [J/mol].
- Hfus_Tms_masslist[float]
Heats of fusion for each component at their respective melting points, [J/kg].
- Hsub_Ttslist[float]
Heats of sublimation for each component at their respective triple points, [J/mol].
- Hsub_Tts_masslist[float]
Heats of sublimation for each component at their respective triple points, [J/kg].
- Hvap_298slist[float]
Molar heats of vaporization for each component at 298.15 K, [J/mol].
- Hvap_298s_masslist[float]
Heats of vaporization for each component at 298.15 K, [J/kg].
- Hvap_Tbslist[float]
Molar heats of vaporization for each component at their respective normal boiling points, [J/mol].
- Hvap_Tbs_masslist[float]
Heats of vaporization for each component at their respective normal boiling points, [J/kg].
- InChI_Keyslist[str]
InChI Keys for each component, [-].
- InChIslist[str]
InChI strings for each component, [-].
- legal_statuseslist[dict]
Status of each component in in relation to import and export rules from various regions, [-].
- LFLslist[float]
Lower flammability limits for each component, [-].
- logPslist[float]
Octanol-water partition coefficients for each component, [-].
- molecular_diameterslist[float]
Lennard-Jones molecular diameters for each component, [angstrom].
- MWslist[float]
Similatiry variables for each component, [g/mol].
- nameslist[str]
Names for each component, [-].
- aliaseslist[str]
Aliases for each component, [-].
- ODPslist[float]
Ozone Depletion Potentials for each component (impact/mass chemical)/(impact/mass CFC-11), [-].
- omegaslist[float]
Acentric factors for each component, [-].
- Parachorslist[float]
Parachors for each component, [N^0.25*m^2.75/mol].
- Pcslist[float]
Critical pressures for each component, [Pa].
- phase_STPslist[str]
Standard states (‘g’, ‘l’, or ‘s’) for each component, [-].
- Psat_298slist[float]
Vapor pressures for each component at 298.15 K, [Pa].
- PSRK_groupslist[dict]
PSRK subgroup: count groups for each component, [-].
- Ptslist[float]
Triple point pressures for each component, [Pa].
- PubChemslist[int]
Pubchem IDs for each component, [-].
- rhocslist[float]
Molar densities at the critical point for each component, [mol/m^3].
- rhocs_masslist[float]
Densities at the critical point for each component, [kg/m^3].
- rhol_STPslist[float]
Molar liquid densities at STP for each component, [mol/m^3].
- rhol_STPs_masslist[float]
Liquid densities at STP for each component, [kg/m^3].
- RIslist[float]
Refractive indexes for each component, [-].
- RI_Tslist[float]
Temperatures at which the refractive indexes were reported for each component, [K].
- S0gslist[float]
Ideal gas absolute molar entropies at 298.15 K at 1 atm for each component, [J/(mol*K)].
- S0gs_masslist[float]
Ideal gas absolute entropies at 298.15 K at 1 atm for each component, [J/(kg*K)].
- Sfgslist[float]
Ideal gas standard molar entropies of formation for each component, [J/(mol*K)].
- Sfgs_masslist[float]
Ideal gas standard entropies of formation for each component, [J/(kg*K)].
- solubility_parameterslist[float]
Solubility parameters for each component at 298.15 K, [Pa^0.5].
- similarity_variableslist[float]
Similarity variables for each component, [mol/g].
- Skinslist[bool]
Whether each compound can be absorbed through the skin or not, [-].
- smilesslist[str]
SMILES identifiers for each component, [-].
- STELslist[tuple[(float, str)]]
Short term exposure limits to chemicals (and their units; ppm or mg/m^3), [various].
- StielPolarslist[float]
Stiel polar factors for each component, [-].
- Stockmayerslist[float]
Lennard-Jones Stockmayer parameters (depth of potential-energy minimum over k) for each component, [K].
- Tautoignitionslist[float]
Autoignition temperatures for each component, [K].
- Tbslist[float]
Boiling temperatures for each component, [K].
- Tcslist[float]
Critical temperatures for each component, [K].
- Tmslist[float]
Melting temperatures for each component, [K].
- Tflashslist[float]
Flash point temperatures for each component, [K].
- Ttslist[float]
Triple point temperatures for each component, [K].
- TWAslist[tuple[(float, str)]]
Time-weighted average exposure limits to chemicals (and their units; ppm or mg/m^3), [various].
- UFLslist[float]
Upper flammability limits for each component, [-].
- UNIFAC_Dortmund_groupslist[dict]
UNIFAC_Dortmund_group: count groups for each component, [-].
- UNIFAC_groupslist[dict]
UNIFAC_group: count groups for each component, [-].
- UNIFAC_Rslist[float]
UNIFAC R parameters for each component, [-].
- UNIFAC_Qslist[float]
UNIFAC Q parameters for each component, [-].
- Van_der_Waals_areaslist[float]
Unnormalized Van der Waals areas for each component, [m^2/mol].
- Van_der_Waals_volumeslist[float]
Unnormalized Van der Waals volumes for each component, [m^3/mol].
- Vcslist[float]
Critical molar volumes for each component, [m^3/mol].
- Vml_STPslist[float]
Liquid molar volumes for each component at STP, [m^3/mol].
- Vml_Tmslist[float]
Liquid molar volumes for each component at their respective melting points, [m^3/mol].
- Vms_Tmslist[float]
Solid molar volumes for each component at their respective melting points, [m^3/mol].
- Vml_60Fslist[float]
Liquid molar volumes for each component at 60 °F, [m^3/mol].
- rhos_Tmslist[float]
Solid molar densities for each component at their respective melting points, [mol/m^3].
- rhol_60Fs_masslist[float]
Liquid mass densities for each component at 60 °F, [kg/m^3].
- rhos_Tms_masslist[float]
Solid mass densities for each component at their melting point, [kg/m^3].
- Zcslist[float]
Critical compressibilities for each component, [-].
- n_atomsint
Number of total atoms in a collection of 1 molecule of each species, [-].
- water_indexint
Index of water in the package, [-].
- Vmg_STPslist[float]
Gas molar volumes for each component at STP; metastable if normally another state, [m^3/mol].
- rhog_STPslist[float]
Molar gas densities at STP for each component; metastable if normally another state, [mol/m^3].
- rhog_STPs_masslist[float]
Gas densities at STP for each component; metastable if normally another state, [kg/m^3].
- sigma_STPslist[float]
Liquid-air surface tensions at 298.15 K and the higher of 101325 Pa or the saturation pressure, [N/m].
- sigma_Tmslist[float]
Liquid-air surface tensions at the melting point and 101325 Pa, [N/m].
- sigma_Tbslist[float]
Liquid-air surface tensions at the normal boiling point and 101325 Pa, [N/m].
- Hf_STPslist[float]
Standard state molar enthalpies of formation for each component, [J/mol].
- Hf_STPs_masslist[float]
Standard state mass enthalpies of formation for each component, [J/kg].
Notes
All parameters are also attributes.
Examples
Create a package with water and the xylenes, suitable for use with equations of state:
>>> ChemicalConstantsPackage(MWs=[18.01528, 106.165, 106.165, 106.165], names=['water', 'o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.344, 0.3118, 0.324, 0.331], Pcs=[22048320.0, 3732000.0, 3511000.0, 3541000.0], Tcs=[647.14, 630.3, 616.2, 617.0]) ChemicalConstantsPackage(MWs=[18.01528, 106.165, 106.165, 106.165], names=['water', 'o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.344, 0.3118, 0.324, 0.331], Pcs=[22048320.0, 3732000.0, 3511000.0, 3541000.0], Tcs=[647.14, 630.3, 616.2, 617.0])
Methods
as_json
()Method to create a JSON friendly serialization of the chemical constants package which can be stored, and reloaded later.
constants_from_IDs
(IDs)Method to construct a new ChemicalConstantsPackage with loaded parameters from the chemicals library, using whatever default methods and values happen to be in that library.
Method to construct a new PropertyCorrelationsPackage with loaded parameters from the chemicals library, using whatever default methods and values happen to be in that library.
from_IDs
(IDs)Method to construct a new ChemicalConstantsPackage and PropertyCorrelationsPackage with loaded parameters from the chemicals library, using whatever default methods and values happen to be in that library.
from_json
(json_repr)Method to create a ChemicalConstantsPackage from a JSON serialization of another ChemicalConstantsPackage.
subset
([idxs, properties])Method to construct a new ChemicalConstantsPackage that removes all components not specified in the idxs argument.
with_new_constants
(**kwargs)Method to construct a new ChemicalConstantsPackage that replaces or adds one or more properties for all components.
- __add__(b)[source]¶
Method to create a new
ChemicalConstantsPackage
object from two otherChemicalConstantsPackage
objects.- Returns
- new
ChemicalConstantsPackage
New object, [-]
- new
Examples
>>> a = ChemicalConstantsPackage.constants_from_IDs(IDs=['water', 'hexane']) >>> b = ChemicalConstantsPackage.constants_from_IDs(IDs=['toluene']) >>> c = a + b
- as_json()[source]¶
Method to create a JSON friendly serialization of the chemical constants package which can be stored, and reloaded later.
- Returns
- json_reprdict
Json friendly representation, [-]
Examples
>>> import json >>> constants = ChemicalConstantsPackage(MWs=[18.01528, 106.165], names=['water', 'm-xylene']) >>> string = json.dumps(constants.as_json())
- static constants_from_IDs(IDs)[source]¶
Method to construct a new ChemicalConstantsPackage with loaded parameters from the chemicals library, using whatever default methods and values happen to be in that library. Expect values to change over time.
- Parameters
- IDslist[str]
Identifying strings for each compound; most identifiers are accepted and all inputs are documented in
chemicals.identifiers.search_chemical
, [-]
- Returns
- constantsChemicalConstantsPackage
New ChemicalConstantsPackage with loaded values, [-]
Notes
Warning
chemicals is a project with a focus on collecting data and correlations from various sources. In no way is it a project to critically evaluate these and provide recommendations. You are strongly encouraged to check values from it and modify them if you want different values. If you believe there is a value which has a typographical error please report it to the chemicals project. If data is missing or not as accuracte as you would like, and you know of a better method or source, new methods and sources can be added to chemicals fairly easily once the data entry is complete. It is not feasible to add individual components, so please submit a complete table of data from the source.
Examples
>>> constants = ChemicalConstantsPackage.constants_from_IDs(IDs=['water', 'hexane'])
- static correlations_from_IDs(IDs)[source]¶
Method to construct a new PropertyCorrelationsPackage with loaded parameters from the chemicals library, using whatever default methods and values happen to be in that library. Expect values to change over time.
- Parameters
- IDslist[str]
Identifying strings for each compound; most identifiers are accepted and all inputs are documented in
chemicals.identifiers.search_chemical
, [-]
- Returns
- correlationsPropertyCorrelationsPackage
New PropertyCorrelationsPackage with loaded values, [-]
Notes
Warning
chemicals is a project with a focus on collecting data and correlations from various sources. In no way is it a project to critically evaluate these and provide recommendations. You are strongly encouraged to check values from it and modify them if you want different values. If you believe there is a value which has a typographical error please report it to the chemicals project. If data is missing or not as accuracte as you would like, and you know of a better method or source, new methods and sources can be added to chemicals fairly easily once the data entry is complete. It is not feasible to add individual components, so please submit a complete table of data from the source.
Examples
>>> correlations = ChemicalConstantsPackage.constants_from_IDs(IDs=['ethanol', 'methanol'])
- static from_IDs(IDs)[source]¶
Method to construct a new ChemicalConstantsPackage and PropertyCorrelationsPackage with loaded parameters from the chemicals library, using whatever default methods and values happen to be in that library. Expect values to change over time.
- Parameters
- IDslist[str]
Identifying strings for each compound; most identifiers are accepted and all inputs are documented in
chemicals.identifiers.search_chemical
, [-]
- Returns
- constantsPropertyCorrelationsPackage
New PropertyCorrelationsPackage with loaded values, [-]
- correlationsPropertyCorrelationsPackage
New PropertyCorrelationsPackage with loaded values, [-]
Notes
Warning
chemicals is a project with a focus on collecting data and correlations from various sources. In no way is it a project to critically evaluate these and provide recommendations. You are strongly encouraged to check values from it and modify them if you want different values. If you believe there is a value which has a typographical error please report it to the chemicals project. If data is missing or not as accuracte as you would like, and you know of a better method or source, new methods and sources can be added to chemicals fairly easily once the data entry is complete. It is not feasible to add individual components, so please submit a complete table of data from the source.
Examples
>>> constants, correlations = ChemicalConstantsPackage.from_IDs(IDs=['water', 'decane'])
- classmethod from_json(json_repr)[source]¶
Method to create a ChemicalConstantsPackage from a JSON serialization of another ChemicalConstantsPackage.
- Parameters
- json_reprdict
Json representation, [-]
- Returns
- constantsChemicalConstantsPackage
Newly created object from the json serialization, [-]
Notes
It is important that the input be in the same format as that created by
ChemicalConstantsPackage.as_json
.Examples
>>> import json >>> constants = ChemicalConstantsPackage(MWs=[18.01528, 106.165], names=['water', 'm-xylene']) >>> string = json.dumps(constants.as_json()) >>> new_constants = ChemicalConstantsPackage.from_json(json.loads(string)) >>> assert hash(new_constants) == hash(constants)
- properties = ('atom_fractions', 'atomss', 'Carcinogens', 'CASs', 'Ceilings', 'charges', 'conductivities', 'dipoles', 'economic_statuses', 'formulas', 'Gfgs', 'Gfgs_mass', 'GWPs', 'Hcs', 'Hcs_lower', 'Hcs_lower_mass', 'Hcs_mass', 'Hfgs', 'Hfgs_mass', 'Hfus_Tms', 'Hfus_Tms_mass', 'Hsub_Tts', 'Hsub_Tts_mass', 'Hvap_298s', 'Hvap_298s_mass', 'Hvap_Tbs', 'Hvap_Tbs_mass', 'InChI_Keys', 'InChIs', 'legal_statuses', 'LFLs', 'logPs', 'molecular_diameters', 'MWs', 'names', 'aliases', 'ODPs', 'omegas', 'Parachors', 'Pcs', 'phase_STPs', 'Psat_298s', 'PSRK_groups', 'Pts', 'PubChems', 'rhocs', 'rhocs_mass', 'rhol_STPs', 'rhol_STPs_mass', 'RIs', 'S0gs', 'S0gs_mass', 'Sfgs', 'Sfgs_mass', 'similarity_variables', 'Skins', 'smiless', 'STELs', 'StielPolars', 'Stockmayers', 'Tautoignitions', 'Tbs', 'Tcs', 'Tflashs', 'Tms', 'Tts', 'TWAs', 'UFLs', 'UNIFAC_Dortmund_groups', 'UNIFAC_groups', 'Van_der_Waals_areas', 'Van_der_Waals_volumes', 'Vcs', 'Vml_STPs', 'Vml_Tms', 'Zcs', 'UNIFAC_Rs', 'UNIFAC_Qs', 'rhos_Tms', 'Vms_Tms', 'rhos_Tms_mass', 'solubility_parameters', 'Vml_60Fs', 'rhol_60Fs', 'rhol_60Fs_mass', 'conductivity_Ts', 'RI_Ts', 'Vmg_STPs', 'rhog_STPs', 'rhog_STPs_mass', 'sigma_STPs', 'sigma_Tms', 'sigma_Tbs', 'Hf_STPs', 'Hf_STPs_mass')¶
Tuple of all properties that can be held by this object.
- subset(idxs=None, properties=None)[source]¶
Method to construct a new ChemicalConstantsPackage that removes all components not specified in the idxs argument. Although this class has a great many attributes, it is often sufficient to work with a subset of those properties; and if a list of properties is provided, only those properties will be added to the new object as well.
- Parameters
- idxslist[int] or Slice or None
Indexes of components that should be included; if None, all components will be included , [-]
- propertiestuple[str] or None
List of properties to be included; all properties will be included if this is not specified
- Returns
- subset_constsChemicalConstantsPackage
Object with reduced properties and or components, [-]
Notes
It is not intended for properties to be edited in this object! One optimization is that all entirely empty properties use the same list-of-Nones.
All properties should have been specified before constructing the first ChemicalConstantsPackage.
Examples
>>> base = ChemicalConstantsPackage(MWs=[18.01528, 106.165, 106.165, 106.165], names=['water', 'o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.344, 0.3118, 0.324, 0.331], Pcs=[22048320.0, 3732000.0, 3511000.0, 3541000.0], Tcs=[647.14, 630.3, 616.2, 617.0]) >>> base.subset([0]) ChemicalConstantsPackage(MWs=[18.01528], names=['water'], omegas=[0.344], Pcs=[22048320.0], Tcs=[647.14]) >>> base.subset(slice(1,4)) ChemicalConstantsPackage(MWs=[106.165, 106.165, 106.165], names=['o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.3118, 0.324, 0.331], Pcs=[3732000.0, 3511000.0, 3541000.0], Tcs=[630.3, 616.2, 617.0]) >>> base.subset(idxs=[0, 3], properties=('names', 'MWs')) ChemicalConstantsPackage(MWs=[18.01528, 106.165], names=['water', 'm-xylene'])
- with_new_constants(**kwargs)[source]¶
Method to construct a new ChemicalConstantsPackage that replaces or adds one or more properties for all components.
- Parameters
- kwargsdict[str: list[float]]
Properties specified by name [various]
- Returns
- new_constantsChemicalConstantsPackage
Object with new and/or replaced properties, [-]
Examples
>>> base = ChemicalConstantsPackage(MWs=[18.01528, 106.165, 106.165, 106.165], names=['water', 'o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.344, 0.3118, 0.324, 0.331], Pcs=[22048320.0, 3732000.0, 3511000.0, 3541000.0], Tcs=[647.14, 630.3, 616.2, 617.0]) >>> base.with_new_constants(Tms=[40.0, 20.0, 10.0, 30.0], omegas=[0.0, 0.1, 0.2, 0.3]) ChemicalConstantsPackage(MWs=[18.01528, 106.165, 106.165, 106.165], names=['water', 'o-xylene', 'p-xylene', 'm-xylene'], omegas=[0.0, 0.1, 0.2, 0.3], Pcs=[22048320.0, 3732000.0, 3511000.0, 3541000.0], Tcs=[647.14, 630.3, 616.2, 617.0], Tms=[40.0, 20.0, 10.0, 30.0])
Chemical Correlations Class¶
- class thermo.chemical_package.PropertyCorrelationsPackage(constants, VaporPressures=None, SublimationPressures=None, VolumeGases=None, VolumeLiquids=None, VolumeSolids=None, HeatCapacityGases=None, HeatCapacityLiquids=None, HeatCapacitySolids=None, ViscosityGases=None, ViscosityLiquids=None, ThermalConductivityGases=None, ThermalConductivityLiquids=None, EnthalpyVaporizations=None, EnthalpySublimations=None, SurfaceTensions=None, PermittivityLiquids=None, VolumeGasMixtureObj=None, VolumeLiquidMixtureObj=None, VolumeSolidMixtureObj=None, HeatCapacityGasMixtureObj=None, HeatCapacityLiquidMixtureObj=None, HeatCapacitySolidMixtureObj=None, ViscosityGasMixtureObj=None, ViscosityLiquidMixtureObj=None, ThermalConductivityGasMixtureObj=None, ThermalConductivityLiquidMixtureObj=None, SurfaceTensionMixtureObj=None, skip_missing=False)[source]¶
Class for creating and storing T and P and zs dependent chemical property objects. All parameters are also attributes.
This object can be used either to hold already-created property objects; or to create new ones and hold them.
- Parameters
- constants
ChemicalConstantsPackage
Object holding all constant properties, [-]
- VaporPressureslist[
thermo.vapor_pressure.VaporPressure
], optional Objects holding vapor pressure data and methods, [-]
- SublimationPressureslist[
thermo.vapor_pressure.SublimationPressure
], optional Objects holding sublimation pressure data and methods, [-]
- VolumeGaseslist[
thermo.volume.VolumeGas
], optional Objects holding gas volume data and methods, [-]
- VolumeLiquidslist[
thermo.volume.VolumeLiquid
], optional Objects holding liquid volume data and methods, [-]
- VolumeSolidslist[
thermo.volume.VolumeSolid
], optional Objects holding solid volume data and methods, [-]
- HeatCapacityGaseslist[
thermo.heat_capacity.HeatCapacityGas
], optional Objects holding gas heat capacity data and methods, [-]
- HeatCapacityLiquidslist[
thermo.heat_capacity.HeatCapacityLiquid
], optional Objects holding liquid heat capacity data and methods, [-]
- HeatCapacitySolidslist[
thermo.heat_capacity.HeatCapacitySolid
], optional Objects holding solid heat capacity data and methods, [-]
- ViscosityGaseslist[
thermo.viscosity.ViscosityGas
], optional Objects holding gas viscosity data and methods, [-]
- ViscosityLiquidslist[
thermo.viscosity.ViscosityLiquid
], optional Objects holding liquid viscosity data and methods, [-]
- ThermalConductivityGaseslist[
thermo.thermal_conductivity.ThermalConductivityGas
], optional Objects holding gas thermal conductivity data and methods, [-]
- ThermalConductivityLiquidslist[
thermo.thermal_conductivity.ThermalConductivityLiquid
], optional Objects holding liquid thermal conductivity data and methods, [-]
- EnthalpyVaporizationslist[
thermo.phase_change.EnthalpyVaporization
], optional Objects holding enthalpy of vaporization data and methods, [-]
- EnthalpySublimationslist[
thermo.phase_change.EnthalpySublimation
], optional Objects holding enthalpy of sublimation data and methods, [-]
- SurfaceTensionslist[
thermo.interface.SurfaceTension
], optional Objects holding surface tension data and methods, [-]
- PermittivityLiquidslist[
thermo.permittivity.PermittivityLiquid
], optional Objects holding permittivity data and methods, [-]
- skip_missingbool, optional
If False, any properties not provided will have objects created; if True, no extra objects will be created.
- VolumeSolidMixture
thermo.volume.VolumeSolidMixture
, optional Predictor object for the volume of solid mixtures, [-]
- VolumeLiquidMixture
thermo.volume.VolumeLiquidMixture
, optional Predictor object for the volume of liquid mixtures, [-]
- VolumeGasMixture
thermo.volume.VolumeGasMixture
, optional Predictor object for the volume of gas mixtures, [-]
- HeatCapacityLiquidMixture
thermo.heat_capacity.HeatCapacityLiquidMixture
, optional Predictor object for the heat capacity of liquid mixtures, [-]
- HeatCapacityGasMixture
thermo.heat_capacity.HeatCapacityGasMixture
, optional Predictor object for the heat capacity of gas mixtures, [-]
- HeatCapacitySolidMixture
thermo.heat_capacity.HeatCapacitySolidMixture
, optional Predictor object for the heat capacity of solid mixtures, [-]
- ViscosityLiquidMixture
thermo.viscosity.ViscosityLiquidMixture
, optional Predictor object for the viscosity of liquid mixtures, [-]
- ViscosityGasMixture
thermo.viscosity.ViscosityGasMixture
, optional Predictor object for the viscosity of gas mixtures, [-]
- ThermalConductivityLiquidMixture
thermo.thermal_conductivity.ThermalConductivityLiquidMixture
, optional Predictor object for the thermal conductivity of liquid mixtures, [-]
- ThermalConductivityGasMixture
thermo.thermal_conductivity.ThermalConductivityGasMixture
, optional Predictor object for the thermal conductivity of gas mixtures, [-]
- SurfaceTensionMixture
thermo.interface.SurfaceTensionMixture
, optional Predictor object for the surface tension of liquid mixtures, [-]
- constants
Examples
Create a package from CO2 and n-hexane, with ideal-gas heat capacities provided while excluding all other properties:
>>> constants = ChemicalConstantsPackage(CASs=['124-38-9', '110-54-3'], MWs=[44.0095, 86.17536], names=['carbon dioxide', 'hexane'], omegas=[0.2252, 0.2975], Pcs=[7376460.0, 3025000.0], Tbs=[194.67, 341.87], Tcs=[304.2, 507.6], Tms=[216.65, 178.075]) >>> correlations = PropertyCorrelationsPackage(constants=constants, skip_missing=True, HeatCapacityGases=[HeatCapacityGas(poly_fit=(50.0, 1000.0, [-3.1115474168865828e-21, 1.39156078498805e-17, -2.5430881416264243e-14, 2.4175307893014295e-11, -1.2437314771044867e-08, 3.1251954264658904e-06, -0.00021220221928610925, 0.000884685506352987, 29.266811602924644])), HeatCapacityGas(poly_fit=(200.0, 1000.0, [1.3740654453881647e-21, -8.344496203280677e-18, 2.2354782954548568e-14, -3.4659555330048226e-11, 3.410703030634579e-08, -2.1693611029230923e-05, 0.008373280796376588, -1.356180511425385, 175.67091124888998]))])
Create a package from various data files, creating all property objects:
>>> correlations = PropertyCorrelationsPackage(constants=constants, skip_missing=False)
- Attributes
- pure_correlationstuple(str)
List of all pure component property objects, [-]
Methods
subset
(idxs)Method to construct a new PropertyCorrelationsPackage that removes all components not specified in the idxs argument.
- __add__(b)[source]¶
Method to create a new
PropertyCorrelationsPackage
object from two otherPropertyCorrelationsPackage
objects.- Returns
- new
PropertyCorrelationsPackage
New object, [-]
- new
Examples
>>> a = ChemicalConstantsPackage.correlations_from_IDs(IDs=['water', 'hexane']) >>> b = ChemicalConstantsPackage.correlations_from_IDs(IDs=['toluene']) >>> c = a + b
- subset(idxs)[source]¶
Method to construct a new PropertyCorrelationsPackage that removes all components not specified in the idxs argument.
- Parameters
- idxslist[int] or Slice or None
Indexes of components that should be included; if None, all components will be included , [-]
- Returns
- subset_correlationsPropertyCorrelationsPackage
Object with components, [-]
Sample Constants and Correlations¶
- thermo.chemical_package.iapws_constants = ChemicalConstantsPackage(CASs=['7732-18-5'], MWs=[18.015268], omegas=[0.344], Pcs=[22064000.0], Tcs=[647.096])¶
ChemicalConstantsPackage
: Object intended to hold the IAPWS-95 water constants for use with thethermo.phases.IAPWS95
phase object.
- thermo.chemical_package.iapws_correlations = <thermo.chemical_package.PropertyCorrelationsPackage object>¶
PropertyCorrelationsPackage
: IAPWS correlations and properties, [-]
- thermo.chemical_package.lemmon2000_constants = ChemicalConstantsPackage(CASs=['132259-10-0'], MWs=[28.9586], omegas=[0.0335], Pcs=[3785020.0], Tcs=[132.6312])¶
ChemicalConstantsPackage
: Object intended to hold the Lemmon (2000) air constants for use with thethermo.phases.DryAirLemmon
phase object.
- thermo.chemical_package.lemmon2000_correlations = <thermo.chemical_package.PropertyCorrelationsPackage object>¶
PropertyCorrelationsPackage
: Lemmon (2000) air correlations and properties, [-]
Creating Property Datasheets (thermo.datasheet)¶
Electrochemistry (thermo.electrochem)¶
This module contains models for:
Pure substance electrical conductivity lookups
Correlations for aqueous electrolyte heat capacity, density, and viscosity
Aqueous electrolyte conductivity
Water equilibrium constants
Balancing experimental ion analysis results so as to meet the electroneutrality condition
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Aqueous Electrolyte Density¶
- thermo.electrochem.Laliberte_density(T, ws, CASRNs)[source]¶
Calculate the density of an aqueous electrolyte mixture using the form proposed by [1]. Parameters are loaded by the function as needed. Units are Kelvin and Pa*s.
\[\rho_m = \left(\frac{w_w}{\rho_w} + \sum_i \frac{w_i}{\rho_{app_i}}\right)^{-1} \]- Parameters
- Tfloat
Temperature of fluid [K]
- wsarray
Weight fractions of fluid components other than water
- CASRNsarray
CAS numbers of the fluid components other than water
- Returns
- rhofloat
Solution density, [kg/m^3]
Notes
Temperature range check is not used here.
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_density(273.15, [0.0037838838], ['7647-14-5']) 1002.62501201
- thermo.electrochem.Laliberte_density_mix(T, ws, c0s, c1s, c2s, c3s, c4s)[source]¶
Calculate the density of an aqueous electrolyte mixture using the form proposed by [1]. All parameters must be provided to the function. Units are Kelvin and Pa*s.
\[\rho_m = \left(\frac{w_w}{\rho_w} + \sum_i \frac{w_i}{\rho_{app_i}}\right)^{-1} \]- Parameters
- Tfloat
Temperature of fluid [K]
- wsarray
Weight fractions of fluid components other than water
- c0slist[float]
Fit coefficient, [-]
- c1slist[float]
Fit coefficient, [-]
- c2slist[float]
Fit coefficient, [-]
- c3slist[float]
Fit coefficient, [1/degC]
- c4slist[float]
Fit coefficient, [degC]
- Returns
- rhofloat
Solution density, [kg/m^3]
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_density_mix(T=278.15, ws=[0.00581, 0.002], c0s=[-0.00324112223655149, 0.967814929691928], c1s=[0.0636354335906616, 5.540434135986], c2s=[1.01371399467365, 1.10374669742622], c3s=[0.0145951015210159, 0.0123340782160061], c4s=[3317.34854426537, 2589.61875022366]) 1005.6947727219
- thermo.electrochem.Laliberte_density_i(T, w_w, c0, c1, c2, c3, c4)[source]¶
Calculate the density of a solute using the form proposed by Laliberte [1]. Parameters are needed, and a temperature, and water fraction. Units are Kelvin and Pa*s.
\[\rho_{app,i} = \frac{(c_0[1-w_w]+c_1)\exp(10^{-6}[t+c_4]^2)} {(1-w_w) + c_2 + c_3 t} \]- Parameters
- Tfloat
Temperature of fluid [K]
- w_wfloat
Weight fraction of water in the solution, [-]
- c0float
Fit coefficient, [-]
- c1float
Fit coefficient, [-]
- c2float
Fit coefficient, [-]
- c3float
Fit coefficient, [1/degC]
- c4float
Fit coefficient, [degC]
- Returns
- rho_ifloat
Solute partial density, [kg/m^3]
Notes
Temperature range check is not used here.
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> params = [-0.00324112223655149, 0.0636354335906616, 1.01371399467365, 0.0145951015210159, 3317.34854426537] >>> Laliberte_density_i(273.15+0, 1-0.0037838838, *params) 3761.8917585
- thermo.electrochem.Laliberte_density_w(T)[source]¶
Calculate the density of water using the form proposed by [1]. No parameters are needed, just a temperature. Units are Kelvin and kg/m^3.
\[\rho_w = \frac{\left\{\left([(-2.8054253\times 10^{-10}\cdot t + 1.0556302\times 10^{-7})t - 4.6170461\times 10^{-5}]t -0.0079870401\right)t + 16.945176 \right\}t + 999.83952} {1 + 0.01687985\cdot t} \]- Parameters
- Tfloat
Temperature of fluid [K]
- Returns
- rho_wfloat
Water density, [kg/m^3]
Notes
Original source not cited No temperature range is used.
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_density_w(298.15) 997.0448954179155 >>> Laliberte_density_w(273.15 + 50) 988.0362916114763
Aqueous Electrolyte Heat Capacity¶
- thermo.electrochem.Laliberte_heat_capacity(T, ws, CASRNs)[source]¶
Calculate the heat capacity of an aqueous electrolyte mixture using the form proposed by [1]. Parameters are loaded by the function as needed.
\[Cp_m = w_w Cp_w + \sum w_i Cp_i \]- Parameters
- Tfloat
Temperature of fluid [K]
- wsarray
Weight fractions of fluid components other than water
- CASRNsarray
CAS numbers of the fluid components other than water
- Returns
- Cpfloat
Solution heat capacity, [J/kg/K]
Notes
A temperature range check is not included in this function. Units are Kelvin and J/kg/K.
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_heat_capacity(273.15+1.5, [0.00398447], ['7647-14-5']) 4186.575407596064
- thermo.electrochem.Laliberte_heat_capacity_mix(T, ws, a1s, a2s, a3s, a4s, a5s, a6s)[source]¶
Calculate the heat capacity of an aqueous electrolyte mixture using the form proposed by [1]. All parameters must be provided to this function.
\[Cp_m = w_w Cp_w + \sum w_i Cp_i \]- Parameters
- Tfloat
Temperature of fluid [K]
- wsarray
Weight fractions of fluid components other than water
- CASRNsarray
CAS numbers of the fluid components other than water
- Returns
- Cpfloat
Solution heat capacity, [J/kg/K]
Notes
A temperature range check is not included in this function. Units are Kelvin and J/kg/K.
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_heat_capacity_mix(T=278.15, ws=[0.00581, 0.002], a1s=[-0.0693559668993322, -0.103713247177424], a2s=[-0.0782134167486952, -0.0647453826944371], a3s=[3.84798479408635, 2.92191453087969], a4s=[-11.2762109247072, -5.48799065938436], a5s=[8.73187698542672, 2.41768600041476], a6s=[1.81245930472755, 1.32062411084408]) 4154.788562680796
- thermo.electrochem.Laliberte_heat_capacity_i(T, w_w, a1, a2, a3, a4, a5, a6)[source]¶
Calculate the heat capacity of a solute using the form proposed by [1] Parameters are needed, and a temperature, and water fraction.
\[Cp_i = a_1 e^\alpha + a_5(1-w_w)^{a_6} \]\[\alpha = a_2 t + a_3 \exp(0.01t) + a_4(1-w_w) \]- Parameters
- Tfloat
Temperature of fluid [K]
- w_wfloat
Weight fraction of water in the solution
- a1-a6floats
Function fit parameters
- Returns
- Cp_ifloat
Solute partial heat capacity, [J/kg/K]
Notes
Units are Kelvin and J/kg/K. Temperature range check is not used here.
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> params = [-0.0693559668993322, -0.0782134167486952, 3.84798479408635, -11.2762109247072, 8.73187698542672, 1.81245930472755] >>> Laliberte_heat_capacity_i(1.5+273.15, 1-0.00398447, *params) -2930.73539458
- thermo.electrochem.Laliberte_heat_capacity_w(T)[source]¶
Calculate the heat capacity of pure water in a fast but similar way as in [1]. [1] suggested the following interpolatative scheme, using points calculated from IAPWS-97 at a pressure of 0.1 MPa up to 95 °C and then at saturation pressure. The maximum temperature of [1] is 140 °C.
\[Cp_w = Cp_1 + (Cp_2-Cp_1) \left( \frac{t-t_1}{t_2-t_1}\right) + \frac{(Cp_3 - 2Cp_2 + Cp_1)}{2}\left( \frac{t-t_1}{t_2-t_1}\right) \left( \frac{t-t_1}{t_2-t_1}-1\right) \]In this implementation, the heat capacity of water is calculated from a chebyshev approximation of the scheme of [1] up to ~92 °C and then the heat capacity comes directly from IAPWS-95 at higher temperatures, also at the saturation pressure. There is no discontinuity between the methods.
- Parameters
- Tfloat
Temperature of fluid [K]
- Returns
- Cp_wfloat
Water heat capacity, [J/kg/K]
Notes
Units are Kelvin and J/kg/K.
References
- 1(1,2,3,4,5)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_heat_capacity_w(273.15+3.56) 4208.878727051538
Aqueous Electrolyte Viscosity¶
- thermo.electrochem.Laliberte_viscosity(T, ws, CASRNs)[source]¶
Calculate the viscosity of an aqueous mixture using the form proposed by [1]. Parameters are loaded by the function as needed. Units are Kelvin and Pa*s.
\[\mu_m = \mu_w^{w_w} \Pi\mu_i^{w_i} \]- Parameters
- Tfloat
Temperature of fluid, [K]
- wsarray
Weight fractions of fluid components other than water, [-]
- CASRNsarray
CAS numbers of the fluid components other than water, [-]
- Returns
- mufloat
Viscosity of aqueous mixture, [Pa*s]
Notes
Temperature range check is not used here. Check is performed using NaCl at 5 degC from the first value in [1]’s spreadsheet.
References
- 1(1,2,3)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_viscosity(273.15+5, [0.005810], ['7647-14-5']) 0.0015285828581961414
- thermo.electrochem.Laliberte_viscosity_mix(T, ws, v1s, v2s, v3s, v4s, v5s, v6s)[source]¶
Calculate the viscosity of an aqueous mixture using the form proposed by [1]. All parameters must be provided in this implementation.
\[\mu_m = \mu_w^{w_w} \Pi\mu_i^{w_i} \]- Parameters
- Tfloat
Temperature of fluid, [K]
- wsarray
Weight fractions of fluid components other than water, [-]
- v1slist[float]
Fit parameter, [-]
- v2slist[float]
Fit parameter, [-]
- v3slist[float]
Fit parameter, [-]
- v4slist[float]
Fit parameter, [1/degC]
- v5slist[float]
Fit parameter, [-]
- v6slist[float]
Fit parameter, [-]
- Returns
- mufloat
Viscosity of aqueous mixture, [Pa*s]
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_viscosity_mix(T=278.15, ws=[0.00581, 0.002], v1s=[16.221788633396, 69.5769240055845], v2s=[1.32293086770011, 4.17047793905946], v3s=[1.48485985010431, 3.57817553622189], v4s=[0.00746912559657377, 0.0116677996754397], v5s=[30.7802007540575, 13897.6652650556], v6s=[2.05826852322558, 20.8027689840251]) 0.0015377348091189648
- thermo.electrochem.Laliberte_viscosity_i(T, w_w, v1, v2, v3, v4, v5, v6)[source]¶
Calculate the viscosity of a solute using the form proposed by [1] Parameters are needed, and a temperature. Units are Kelvin and Pa*s.
\[\mu_i = \frac{\exp\left( \frac{v_1(1-w_w)^{v_2}+v_3}{v_4 t +1}\right)} {v_5(1-w_w)^{v_6}+1} \]- Parameters
- Tfloat
Temperature of fluid, [K]
- w_wfloat
Weight fraction of water in the solution, [-]
- v1float
Fit parameter, [-]
- v2float
Fit parameter, [-]
- v3float
Fit parameter, [-]
- v4float
Fit parameter, [1/degC]
- v5float
Fit parameter, [-]
- v6float
Fit parameter, [-]
- Returns
- mu_ifloat
Solute partial viscosity, [Pa*s]
Notes
Temperature range check is outside of this function. Check is performed using NaCl at 5 degC from the first value in [1]’s spreadsheet.
References
- 1(1,2,3)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> params = [16.221788633396, 1.32293086770011, 1.48485985010431, 0.00746912559657377, 30.7802007540575, 2.05826852322558] >>> Laliberte_viscosity_i(273.15+5, 1-0.005810, *params) 0.004254025533308794
- thermo.electrochem.Laliberte_viscosity_w(T)[source]¶
Calculate the viscosity of a water using the form proposed by [1]. No parameters are needed, just a temperature. Units are Kelvin and Pa*s. t is temperature in degrees Celcius.
\[\mu_w = \frac{t + 246}{(0.05594t+5.2842)t + 137.37} \]- Parameters
- Tfloat
Temperature of fluid, [K]
- Returns
- mu_wfloat
Water viscosity, [Pa*s]
Notes
Original source or pure water viscosity is not cited. No temperature range is given for this equation.
References
- 1(1,2)
Laliberte, Marc. “A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data.” Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123
Examples
>>> Laliberte_viscosity_w(298) 0.000893226448703328
Aqueous Electrolyte Thermal Conductivity¶
- thermo.electrochem.thermal_conductivity_Magomedov(T, P, ws, CASRNs, k_w)[source]¶
Calculate the thermal conductivity of an aqueous mixture of electrolytes using the form proposed by Magomedov [1]. Parameters are loaded by the function as needed. Function will fail if an electrolyte is not in the database.
\[\lambda = \lambda_w\left[ 1 - \sum_{i=1}^n A_i (w_i + 2\times10^{-4} w_i^3)\right] - 2\times10^{-8} PT\sum_{i=1}^n w_i \]- Parameters
- Tfloat
Temperature of liquid [K]
- Pfloat
Pressure of the liquid [Pa]
- wsarray
Weight fractions of liquid components other than water
- CASRNsarray
CAS numbers of the liquid components other than water
- k_wfloat
Liquid thermal condiuctivity or pure water at T and P, [W/m/K]
- Returns
- klfloat
Liquid thermal condiuctivity, [W/m/K]
Notes
Range from 273 K to 473 K, P from 0.1 MPa to 100 MPa. C from 0 to 25 mass%. Internal untis are MPa for pressure and weight percent.
An example is sought for this function. It is not possible to reproduce the author’s values consistently.
References
- 1(1,2)
Magomedov, U. B. “The Thermal Conductivity of Binary and Multicomponent Aqueous Solutions of Inorganic Substances at High Parameters of State.” High Temperature 39, no. 2 (March 1, 2001): 221-26. doi:10.1023/A:1017518731726.
Examples
>>> thermal_conductivity_Magomedov(293., 1E6, [.25], ['7758-94-3'], k_w=0.59827) 0.548654049375
- thermo.electrochem.Magomedov_mix(T, P, ws, Ais, k_w)[source]¶
Calculate the thermal conductivity of an aqueous mixture of electrolytes using the correlation proposed by Magomedov [1]. All coefficients and the thermal conductivity of pure water must be provided.
\[\lambda = \lambda_w\left[ 1 - \sum_{i=1}^n A_i (w_i + 2\times10^{-4} w_i^3)\right] - 2\times10^{-8} PT\sum_{i=1}^n w_i \]- Parameters
- Tfloat
Temperature of liquid [K]
- Pfloat
Pressure of the liquid [Pa]
- wslist[float]
Weight fractions of liquid components other than water, [-]
- Aislist[float]
Ai coefficients which were regressed, [-]
- k_wfloat
Liquid thermal condiuctivity or pure water at T and P, [W/m/K]
- Returns
- klfloat
Liquid thermal condiuctivity, [W/m/K]
Notes
Range from 273 K to 473 K, P from 0.1 MPa to 100 MPa. C from 0 to 25 mass%. Internal untis are MPa for pressure and weight percent.
References
- 1(1,2)
Magomedov, U. B. “The Thermal Conductivity of Binary and Multicomponent Aqueous Solutions of Inorganic Substances at High Parameters of State.” High Temperature 39, no. 2 (March 1, 2001): 221-26. doi:10.1023/A:1017518731726.
Examples
>>> Magomedov_mix(293., 1E6, [.25], [0.00294], k_w=0.59827) 0.548654049375
Aqueous Electrolyte Electrical Conductivity¶
- thermo.electrochem.dilute_ionic_conductivity(ionic_conductivities, zs, rhom)[source]¶
This function handles the calculation of the electrical conductivity of a dilute electrolytic aqueous solution. Requires the mole fractions of each ion, the molar density of the whole mixture, and ionic conductivity coefficients for each ion.
\[\lambda = \sum_i \lambda_i^\circ z_i \rho_m \]- Parameters
- ionic_conductivitieslist[float]
Ionic conductivity coefficients of each ion in the mixture [m^2*S/mol]
- zslist[float]
Mole fractions of each ion in the mixture, [-]
- rhomfloat
Overall molar density of the solution, [mol/m^3]
- Returns
- kappafloat
Electrical conductivity of the fluid, [S/m]
Notes
The ionic conductivity coefficients should not be equivalent coefficients; for example, 0.0053 m^2*S/mol is the equivalent conductivity coefficient of Mg+2, but this method expects twice its value - 0.0106. Both are reported commonly in literature.
Water can be included in this caclulation by specifying a coefficient of 0. The conductivity of any electrolyte eclipses its own conductivity by many orders of magnitude. Any other solvents present will affect the conductivity extensively and there are few good methods to predict this effect.
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.
Examples
Complex mixture of electrolytes [‘Cl-’, ‘HCO3-’, ‘SO4-2’, ‘Na+’, ‘K+’, ‘Ca+2’, ‘Mg+2’]:
>>> ionic_conductivities = [0.00764, 0.00445, 0.016, 0.00501, 0.00735, 0.0119, 0.01061] >>> zs = [0.03104, 0.00039, 0.00022, 0.02413, 0.0009, 0.0024, 0.00103] >>> dilute_ionic_conductivity(ionic_conductivities=ionic_conductivities, zs=zs, rhom=53865.9) 22.05246783663
- thermo.electrochem.conductivity_McCleskey(T, M, lambda_coeffs, A_coeffs, B, multiplier, rho=1000.0)[source]¶
This function handles the calculation of the electrical conductivity of an electrolytic aqueous solution with one electrolyte in solution. It handles temperature dependency and concentrated solutions. Requires the temperature of the solution; its molality, and four sets of coefficients lambda_coeffs, A_coeffs, B, and multiplier.
\[\Lambda = \frac{\kappa}{C} \Lambda = \Lambda^0(t) - A(t) \frac{m^{1/2}}{1+Bm^{1/2}} \Lambda^\circ(t) = c_1 t^2 + c_2 t + c_3 A(t) = d_1 t^2 + d_2 t + d_3\]In the above equations, t is temperature in degrees Celcius; m is molality in mol/kg, and C is the concentration of the elctrolytes in mol/m^3, calculated as the product of density and molality.
- Parameters
- Tfloat
Temperature of the solution, [K]
- Mfloat
Molality of the solution with respect to one electrolyte (mol solute / kg solvent), [mol/kg]
- lambda_coeffslist[float]
List of coefficients for the polynomial used to calculate lambda; length-3 coefficients provided in [1], [-]
- A_coeffslist[float]
List of coefficients for the polynomial used to calculate A; length-3 coefficients provided in [1], [-]
- Bfloat
Empirical constant for an electrolyte, [-]
- multiplierfloat
The multiplier to obtain the absolute conductivity from the equivalent conductivity; ex 2 for CaCl2, [-]
- rhofloat, optional
The mass density of the aqueous mixture, [kg/m^3]
- Returns
- kappafloat
Electrical conductivity of the solution at the specified molality and temperature [S/m]
Notes
Coefficients provided in [1] result in conductivity being calculated in units of mS/cm; they are converted to S/m before returned.
References
- 1(1,2,3,4)
McCleskey, R. Blaine. “Electrical Conductivity of Electrolytes Found In Natural Waters from (5 to 90) °C.” Journal of Chemical & Engineering Data 56, no. 2 (February 10, 2011): 317-27. doi:10.1021/je101012n.
Examples
A 0.5 wt% solution of CaCl2, conductivity calculated in mS/cm
>>> conductivity_McCleskey(T=293.15, M=0.045053, A_coeffs=[.03918, 3.905, ... 137.7], lambda_coeffs=[0.01124, 2.224, 72.36], B=3.8, multiplier=2) 0.8482584585108555
- thermo.electrochem.ionic_strength(mis, zis)[source]¶
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.
\[I = \frac{1}{2} \sum M_i z_i^2 I = \frac{1}{2} \sum x_i z_i^2\]- Parameters
- mislist
Molalities of each ion, or mole fractions of each ion [mol/kg or -]
- zislist
Charges of each ion [-]
- Returns
- Ifloat
ionic strength, [?]
References
- 1
Chen, Chau-Chyun, H. I. Britt, J. F. Boston, and L. B. Evans. “Local Composition Model for Excess Gibbs Energy of Electrolyte Systems. Part I: Single Solvent, Single Completely Dissociated Electrolyte Systems.” AIChE Journal 28, no. 4 (July 1, 1982): 588-96. doi:10.1002/aic.690280410
- 2
Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012.
Examples
>>> ionic_strength([0.1393, 0.1393], [1, -1]) 0.1393
Pure Liquid Electrical Conductivity¶
- thermo.electrochem.conductivity(CASRN, method=None)[source]¶
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
- CASRNstring
CASRN [-]
- Returns
- kappafloat
Electrical conductivity of the fluid, [S/m]
- Tfloat or None
Temperature at which conductivity measurement was made or None if not available, [K]
- Other Parameters
- methodstring, optional
A string for the method name to use, as defined by constants in conductivity_methods
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 Liquids’, a compillation of data in [1]. The individual datapoints in this source are not cited at all.
References
Examples
>>> conductivity('7732-18-5') (4e-06, 291.15)
- thermo.electrochem.conductivity_methods(CASRN)[source]¶
Return all methods available to obtain electrical conductivity for the specified chemical.
- Parameters
- CASRNstr
CASRN, [-]
- Returns
- methodslist[str]
Methods which can be used to obtain electrical conductivity with the given inputs.
See also
- thermo.electrochem.conductivity_all_methods = ['LANGE_COND']¶
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
Water Dissociation Equilibrium¶
- thermo.electrochem.Kweq_Arcis_Tremaine_Bandura_Lvov(T, rho_w)[source]¶
Calculates equilibrium constant for OH- and H+ in water, according to [1].
\[Q = \rho \exp(\alpha_0 + \alpha_1 T^{-1} + \alpha_2 T^{-2} \rho^{2/3}) \]\[- \log_{10} K_w = -2n \left[ \log_{10}(1+Q) - \frac{Q}{Q+1} \rho (\beta_0 + \beta_1 T^{-1} + \beta_2 \rho) \right] -\log_{10} K_w^G + 2 \log_{10} \frac{18.015268}{1000} \]- Parameters
- Tfloat
Temperature of water [K]
- rho_wfloat
Density of water at temperature and pressure [kg/m^3]
- Returns
- Kweqfloat
Ionization constant of water, [-]
Notes
Formulation is in terms of density in g/cm^3; density is converted internally.
n = 6; alpha0 = -0.864671; alpha1 = 8659.19; alpha2 = -22786.2; beta0 = 0.642044; beta1 = -56.8534; beta2 = -0.375754
References
- 1(1,2)
Arcis, Hugues, Jane P. Ferguson, Jenny S. Cox, and Peter R. Tremaine. “The Ionization Constant of Water at Elevated Temperatures and Pressures: New Data from Direct Conductivity Measurements and Revised Formulations from T = 273 K to 674 K and p = 0.1 MPa to 31 MPa.” Journal of Physical and Chemical Reference Data 49, no. 3 (July 23, 2020): 033103. https://doi.org/10.1063/1.5127662.
Examples
>>> -1*log10(Kweq_Arcis_Tremaine_Bandura_Lvov(600, 700)) 11.138236348
- thermo.electrochem.Kweq_IAPWS(T, rho_w)[source]¶
Calculates equilibrium constant for OH- and H+ in water, according to [1]. This is the most recent formulation available.
\[Q = \rho \exp(\alpha_0 + \alpha_1 T^{-1} + \alpha_2 T^{-2} \rho^{2/3}) \]\[- \log_{10} K_w = -2n \left[ \log_{10}(1+Q) - \frac{Q}{Q+1} \rho (\beta_0 + \beta_1 T^{-1} + \beta_2 \rho) \right] -\log_{10} K_w^G + 2 \log_{10} \frac{18.015268}{1000} \]- Parameters
- Tfloat
Temperature of water [K]
- rho_wfloat
Density of water at temperature and pressure [kg/m^3]
- Returns
- Kweqfloat
Ionization constant of water, [-]
Notes
Formulation is in terms of density in g/cm^3; density is converted internally.
n = 6; alpha0 = -0.864671; alpha1 = 8659.19; alpha2 = -22786.2; beta0 = 0.642044; beta1 = -56.8534; beta2 = -0.375754
References
- 1(1,2)
Bandura, Andrei V., and Serguei N. Lvov. “The Ionization Constant of Water over Wide Ranges of Temperature and Density.” Journal of Physical and Chemical Reference Data 35, no. 1 (March 1, 2006): 15-30. doi:10.1063/1.1928231
Examples
Example from IAPWS check:
>>> -1*log10(Kweq_IAPWS(600, 700)) 11.203153057603775
- thermo.electrochem.Kweq_IAPWS_gas(T)[source]¶
Calculates equilibrium constant for OH- and H+ in water vapor, according to [1]. This is the most recent formulation available.
\[-log_{10} K_w^G = \gamma_0 + \gamma_1 T^{-1} + \gamma_2 T^{-2} + \gamma_3 T^{-3} \]- Parameters
- Tfloat
Temperature of H2O [K]
- Returns
- K_w_Gfloat
Notes
gamma0 = 6.141500E-1; gamma1 = 4.825133E4; gamma2 = -6.770793E4; gamma3 = 1.010210E7
References
- 1(1,2)
Bandura, Andrei V., and Serguei N. Lvov. “The Ionization Constant of Water over Wide Ranges of Temperature and Density.” Journal of Physical and Chemical Reference Data 35, no. 1 (March 1, 2006): 15-30. doi:10.1063/1.1928231
Examples
>>> Kweq_IAPWS_gas(800) 1.4379721554798815e-61
- thermo.electrochem.Kweq_1981(T, rho_w)[source]¶
Calculates equilibrium constant for OH- and H+ in water, according to [1]. Second most recent formulation.
\[\log_{10} K_w= A + B/T + C/T^2 + D/T^3 + (E+F/T+G/T^2)\log_{10} \rho_w \]- Parameters
- Tfloat
Temperature of fluid [K]
- rho_wfloat
Density of water, [kg/m^3]
- Returns
- Kweqfloat
Ionization constant of water, [-]
Notes
Density is internally converted to units of g/cm^3.
A = -4.098; B = -3245.2; C = 2.2362E5; D = -3.984E7; E = 13.957; F = -1262.3; G = 8.5641E5
References
- 1(1,2)
Marshall, William L., and E. U. Franck. “Ion Product of Water Substance, 0-1000 degree C, 1010,000 Bars New International Formulation and Its Background.” Journal of Physical and Chemical Reference Data 10, no. 2 (April 1, 1981): 295-304. doi:10.1063/1.555643.
Examples
>>> -1*log10(Kweq_1981(600, 700)) 11.274522047
Balancing Ions¶
- thermo.electrochem.balance_ions(anions, cations, anion_zs=None, cation_zs=None, anion_concs=None, cation_concs=None, rho_w=997.1, method='increase dominant', selected_ion=None)[source]¶
Performs an ion balance to adjust measured experimental ion compositions to electroneutrality. Can accept either the actual mole fractions of the ions, or their concentrations in units of [mg/L] as well for convinience.
The default method will locate the most prevalent ion in the type of ion not in excess - and increase it until the two ion types balance.
- Parameters
- anionslist(ChemicalMetadata)
List of all negatively charged ions measured as being in the solution; ChemicalMetadata instances or simply objects with the attributes MW and charge, [-]
- cationslist(ChemicalMetadata)
List of all positively charged ions measured as being in the solution; ChemicalMetadata instances or simply objects with the attributes MW and charge, [-]
- anion_zslist, optional
Mole fractions of each anion as measured in the aqueous solution, [-]
- cation_zslist, optional
Mole fractions of each cation as measured in the aqueous solution, [-]
- anion_concslist, optional
Concentrations of each anion in the aqueous solution in the units often reported (for convinience only) [mg/L]
- cation_concslist, optional
Concentrations of each cation in the aqueous solution in the units often reported (for convinience only) [mg/L]
- rho_wfloat, optional
Density of the aqueous solutionr at the temperature and pressure the anion and cation concentrations were measured (if specified), [kg/m^3]
- methodstr, optional
The method to use to balance the ionimbalance; one of ‘dominant’, ‘decrease dominant’, ‘increase dominant’, ‘proportional insufficient ions increase’, ‘proportional excess ions decrease’, ‘proportional cation adjustment’, ‘proportional anion adjustment’, ‘Na or Cl increase’, ‘Na or Cl decrease’, ‘adjust’, ‘increase’, ‘decrease’, ‘makeup’].
- selected_ionChemicalMetadata, optional
Some methods adjust only one user-specified ion; this is that input. For the case of the ‘makeup’ method, this is a tuple of (anion, cation) ChemicalMetadata instances and only the ion type not in excess will be used.
- Returns
- anionslist[ChemicalMetadata]
List of all negatively charged ions measured as being in the solution; ChemicalMetadata instances after potentially adding in an ion which was not present but specified by the user, [-]
- cationslist[ChemicalMetadata]
List of all positively charged ions measured as being in the solution; ChemicalMetadata instances after potentially adding in an ion which was not present but specified by the user, [-]
- anion_zslist[float],
Mole fractions of each anion in the aqueous solution after the charge balance, [-]
- cation_zslist[float]
Mole fractions of each cation in the aqueous solution after the charge balance, [-]
- z_waterfloat[float]
Mole fraction of the water in the solution, [-]
Notes
The methods perform the charge balance as follows:
‘dominant’ : The ion with the largest mole fraction in solution has its concentration adjusted up or down as necessary to balance the solution.
‘decrease dominant’ : The ion with the largest mole fraction in the type of ion with excess charge has its own mole fraction decreased to balance the solution.
‘increase dominant’ : The ion with the largest mole fraction in the type of ion with insufficient charge has its own mole fraction decreased to balance the solution.
‘proportional insufficient ions increase’ : The ion charge type which is present insufficiently has each of the ions mole fractions increased proportionally until the solution is balanced.
‘proportional excess ions decrease’ : The ion charge type which is present in excess has each of the ions mole fractions decreased proportionally until the solution is balanced.
‘proportional cation adjustment’ : All cations have their mole fractions increased or decreased proportionally as necessary to balance the solution.
‘proportional anion adjustment’ : All anions have their mole fractions increased or decreased proportionally as necessary to balance the solution.
‘Na or Cl increase’ : Either Na+ or Cl- is added to the solution until the solution is balanced; the species will be added if they were not present initially as well.
‘Na or Cl decrease’ : Either Na+ or Cl- is removed from the solution until the solution is balanced; the species will be added if they were not present initially as well.
‘adjust’ : An ion specified with the parameter selected_ion has its mole fraction increased or decreased as necessary to balance the solution. An exception is raised if the specified ion alone cannot balance the solution.
‘increase’ : An ion specified with the parameter selected_ion has its mole fraction increased as necessary to balance the solution. An exception is raised if the specified ion alone cannot balance the solution.
‘decrease’ : An ion specified with the parameter selected_ion has its mole fraction decreased as necessary to balance the solution. An exception is raised if the specified ion alone cannot balance the solution.
‘makeup’ : Two ions ase specified as a tuple with the parameter selected_ion. Whichever ion type is present in the solution insufficiently is added; i.e. if the ions were Mg+2 and Cl-, and there was too much negative charge in the solution, Mg+2 would be added until the solution was balanced.
Examples
>>> anions_n = ['Cl-', 'HCO3-', 'SO4-2'] >>> cations_n = ['Na+', 'K+', 'Ca+2', 'Mg+2'] >>> cations = [identifiers.pubchem_db.search_name(i) for i in cations_n] >>> anions = [identifiers.pubchem_db.search_name(i) for i in anions_n] >>> an_res, cat_res, an_zs, cat_zs, z_water = balance_ions(anions, cations, ... anion_zs=[0.02557, 0.00039, 0.00026], cation_zs=[0.0233, 0.00075, ... 0.00262, 0.00119], method='proportional excess ions decrease') >>> an_zs [0.02557, 0.00039, 0.00026] >>> cat_zs [0.01948165456267761, 0.0006270918850647299, 0.0021906409851594564, 0.0009949857909693717] >>> z_water 0.9504856267761288
Fit Coefficients and Data¶
All of these coefficients are lazy-loaded, so they must be accessed as an attribute of this module.
In [1]: from thermo.electrochem import Magomedovk_thermal_cond, cond_data_McCleskey, CRC_aqueous_thermodynamics, electrolyte_dissociation_reactions, Laliberte_data
In [2]: Magomedovk_thermal_cond
Out[2]:
Formula Chemical Ai
CASRN
497-19-8 Na2CO3 Sodium carbonate -0.00050
584-08-7 K2CO3 Potassium carbonate 0.00160
7447-39-4 CuCl2 Cuprous chloride 0.00360
7488-54-2 Rb2SO4 Rubidium sulfate 0.00134
7601-89-0 NaClO4 Sodium perchlorate 0.00250
7646-79-9 CoCl2 Cobaltous chloride 0.00320
7664-93-9 H2SO4 Acid sulfate 0.00305
7699-45-8 ZnBr2 Zinc bromide 0.00410
7718-54-9 NiCl2 Nickelous chloride 0.00330
7758-94-3 FeCl2 Ferrous chloride 0.00294
7761-88-8 AgNO3 Silver nitrate 0.00190
7775-09-9 NaClO3 Sodium chlorate 0.00240
7778-50-9 K2Cr2O7 Potassium dichromate 0.00188
7786-81-4 NiSO4 Nickelous sulfate 0.00140
7789-00-6 K2CrO4 Potassium chromate 0.00130
7789-23-3 KF Potassium fluoride 0.00180
7789-38-0 NaBrO3 Sodium bromate 0.00170
7789-39-1 RbBr Rubidium bromide 0.00305
7789-42-6 CdBr2 Cadmium bromide 0.00274
7789-46-0 FeBr2 Ferrous bromide 0.00375
7790-29-6 RbI Rubidium iodide 0.00322
7790-80-9 CdI2 Cadmium iodide 0.00302
7791-11-9 RbCl Rubidium chloride 0.00238
10042-76-9 Sr(NO3)2 Strontium nitrate 0.00153
10043-01-3 Al2(SO4)3 Aluminum sulfate 0.00335
10099-74-8 Pb(NO3)2 Lead nitrate 0.00138
10102-68-8 CaI2 Calcium iodide 0.00340
10139-47-6 ZnI2 Zinc iodide 0.00410
10325-94-7 Cd(NO3)2 Cadmium nitrate 0.00155
10377-51-2 LiI Lithium iodide 0.00435
10377-58-9 MgI2 Magnesium iodide 0.00417
10476-81-0 SrBr2 Strontium bromide 0.00290
10476-85-4 SrCl2 Strontium chloride 0.00170
10476-86-5 SrI2 Strontium iodide 0.00311
12027-06-4 NH4I Ammonium iodide 0.00480
13126-12-0 RbNO3 Rubidium nitrate 0.00214
13462-88-9 NiBr2 Nickelous bromide 0.00396
13462-90-3 NiI2 Nickelous iodide 0.00393
15238-00-3 CoI2 Cobaltous iodide 0.00384
In [3]: cond_data_McCleskey
Out[3]:
formula c1 c2 ... d3 B multiplier
CASRN ...
7447-40-7 KCl 0.009385 2.533 ... 44.11 1.70 1
7647-14-5 NaCl 0.008967 2.196 ... 44.55 1.30 1
7647-01-0 HCl -0.006766 6.614 ... 48.53 0.01 1
7447-41-8 LiCl 0.008784 1.996 ... 42.79 1.00 1
7647-17-8 CsCl 0.010080 2.479 ... 41.29 1.40 1
12125-02-9 NH4Cl 0.006575 2.684 ... 30.00 0.70 1
10043-52-4 CaCl2 0.011240 2.224 ... 137.70 3.80 2
7786-30-3 MgCl2 0.009534 2.247 ... 129.80 3.10 2
10361-37-2 BaCl2 0.010380 2.346 ... 111.80 2.40 2
10476-85-4 SrCl2 0.009597 2.279 ... 60.18 0.80 2
7664-93-9 H2SO4 -0.019850 7.421 ... 1869.00 11.50 2
7757-82-6 Na2SO4 0.009501 2.317 ... 135.50 2.20 2
7778-80-5 K2SO4 0.008819 2.872 ... 247.10 5.30 2
10294-54-9 Cs2SO4 0.012730 2.457 ... 187.40 3.30 2
7778-18-9 CaSO4 0.011920 2.564 ... 644.40 9.60 2
7646-93-7 KHSO4 -0.003092 9.759 ... 1776.00 8.20 1
298-14-6 KHCO3 0.007807 2.040 ... 38.58 0.90 1
584-08-7 K2CO3 0.011450 2.726 ... 81.12 2.10 2
144-55-8 NaHCO3 0.012600 1.543 ... 52.94 1.10 1
497-19-8 Na2CO3 0.022960 5.211 ... 455.80 4.80 2
1310-73-2 NaOH 0.006936 3.872 ... 56.76 0.20 1
7681-49-4 NaF 0.007346 2.032 ... 69.99 2.30 1
7789-23-3 KF 0.007451 2.294 ... 39.40 0.90 1
7758-02-3 KBr 0.007076 2.612 ... 29.49 0.60 1
7757-79-1 KNO3 0.009117 2.309 ... 49.12 0.70 1
7779-88-6 Zn(NO3)2 0.015260 4.519 ... 302.90 4.00 2
[26 rows x 9 columns]
In [4]: CRC_aqueous_thermodynamics
Out[4]:
Formula Name ... S(aq) Cp(aq)
CAS ...
57-12-5 CN- Cyanide ion ... 94.1 NaN
71-47-6 CHOO- Formate ion ... 92.0 -87.9
71-50-1 CH3COO- Acetate ion ... 86.6 -6.3
71-52-3 HCO3- Bicarbonate ion ... 91.2 NaN
302-04-5 SCN- Thiocyanate ion ... 144.3 -40.2
... ... ... ... ... ...
117412-24-5 BeO2-2 Beryllium dioxide ion ... -159.0 NaN
127622-32-6 Y(OH)+2 Yttrium hydroxide ion ... NaN NaN
129466-35-9 Te(OH)3+ Tellurium(IV) trihydroxide ion ... 111.7 NaN
186449-38-7 InOH+2 Indium hydroxide ion ... -88.0 NaN
2099995000-00-0 Y2(OH)2+4 Yttrium dihydroxide ion ... NaN NaN
[173 rows x 7 columns]
In [5]: electrolyte_dissociation_reactions
Out[5]:
Electrolyte name Electrolyte CAS ... Cation charge Cation count
0 Diammonium Hydrogen phosphate 7783-28-0 ... 1 2
1 Ammonium Sulfate 7783-20-2 ... 1 2
2 ammonium sulfite 10196-04-0 ... 1 2
3 Ammonium phosphate 10361-65-6 ... 1 3
4 Ammonium siliconhexafluoride 16919-19-0 ... 1 2
.. ... ... ... ... ...
259 Zinc selenite 13597-46-1 ... 2 1
260 Zinc selenate 13597-54-1 ... 2 1
261 Zinc Nitrate 7779-88-6 ... 2 1
262 Zinc Chloride 7646-85-7 ... 2 1
263 Zinc Sulfate 7733-02-0 ... 2 1
[264 rows x 11 columns]
In [6]: Laliberte_data
Out[6]:
Name Formula ... Max w.2 No of points in corr.2
CASRN ...
7783-20-2 Ammonium Sulfate (NH4)2SO4 ... NaN NaN
10043-01-3 Aluminum Sulfate Al2(SO4)3 ... NaN NaN
7446-70-0 Aluminum Chloride AlCl3 ... NaN NaN
10022-31-8 Barium Nitrate Ba(NO3)2 ... 0.047274 96.0
10361-37-2 Barium Chloride BaCl2 ... 0.248237 16.0
... ... ... ... ... ...
57-50-1 Sucrose Sucrose ... NaN NaN
13825-74-6 Titanyl Sulfate TiOSO4 ... NaN NaN
7779-88-6 Zinc Nitrate Zn(NO3)2 ... 0.077132 144.0
7646-85-7 Zinc Chloride ZnCl2 ... NaN NaN
7733-02-0 Zinc Sulfate ZnSO4 ... NaN NaN
[109 rows x 32 columns]
Cubic Equations of State (thermo.eos)¶
This module contains implementations of most cubic equations of state for pure components. This includes Peng-Robinson, SRK, Van der Waals, PRSV, TWU and many other variants.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Base Class¶
- class thermo.eos.GCEOS[source]¶
Bases:
object
Class for solving a generic Pressure-explicit three-parameter cubic equation of state. Does not implement any parameters itself; must be subclassed by an equation of state class which uses it. Works for mixtures or pure species for all properties except fugacity. All properties are derived with the CAS SymPy, not relying on any derivations previously published.
\[P=\frac{RT}{V-b}-\frac{a\alpha(T)}{V^2 + \delta V + \epsilon} \]The main methods (in order they are called) are
GCEOS.solve
,