Skip to the content.

Many methods in ThermoPack can return several values. These are commonly packaged in simple structures to facilitate easy access of the desired properties. This page is an overview of the different structures returned from various ThermoPack methods.

Differentials

Property calculations (i.e. TV-Properties, TP-Properties, and TVP-Properties) typically yield a value, and optionally differentials. If any differentials are computed, these are returned in a Differentials struct, which contains the attributes

Example:

from cubic import PengRobinson
eos = PengRobinson('C1,C3') # PR eos for methane/propane mixture
T = 300 # Kelvin
p = 1e5 # Pascal
n = [1, 5] # mol
h, dh = eos.enthalpy(T, p, n, dhdt=True, dhdn=True) # eos.enthalpy is a TP-property interface
print(h) # Enthalpy (J / mol)
print(dh.constant) # 'tpn'
print(dh.dT) # Derivative wrt. T at constant p, n (i.e. isobaric heat capacity)
print(dh.dV) # None (Not available for TP-properties)
print(dh.dn) # Derivative wrt. mole numbers at constant T, p (i.e. partial molar enthalpies)
print(dh.dp) # None (computation flag not set to True)

V = 1.2 # m^3
h_vap, dh_vap = eos.enthalpy_tv(T, V, n, eos.VAPPH, dhdt=True, dndV=True) # eos.enthalpy_tv is a TV-property interface
print(h_vap) # Vapour phase Enthalpy (J)
print(dh_vap.constant) # 'tvn'
print(dh_vap.dT) # Derivative wrt. T at constant V, n
print(dh_vap.dV) # Derivative wrt. V at constant T, n
print(dh_vap.dn) # None (computation flag not set to True)
print(dh_vap.dp) # None (not available for TV-properties)

FlashResult

There are a variety of flash interfaces in ThermoPack, which all return equivalent FlashResult structures, with the attributes

XYDiagram

The methods get_binary_pxy and get_binary_txy are used to compute the pxy- and Txy- phase diagrams for binary mixtures. The results are returned in an XYDiagram structure, which contains the attributes

The composition and pressure/temperature along each phase boundary is contained in the corresponding XYEquilibrium structure.

The XYDiagram struct is iterable, and in practice it is often unpacked directly upon being returned, as

from cubic import PengRobinson
eos = PengRobinson('C1,NC6') # PR eos for methane/hexane mixture
lle, l1ve, l2ve = eos.get_binary_pxy(300) # Binary pxy-diagram at 300 K

The above is equivalent to

xydiag = eos.get_binary_pxy(300) # Binary pxy-diagram at 300 K
lle = xydiag.lle
l1ve = xydiag.l1ve
l2ve = xydiag.l2ve

XYEquilibrium

The phase boundaries in the binary XY-diagrams are held in PxyEquilibrium and TxyEquilibrium structures, these contain the attributes

Thus, to plot the binary phase diagram we can use

lle, l1ve, l2ve = eos.get_binary_pxy(300) # Binary pxy-diagram at 300 K

plt.plot(lle.x1, lle.p) # Liquid 1 miscibility composition
plt.plot(lle.x2, lle.p) # Liquid 2 miscibility composition

plt.plot(l1ve.x, l1ve.p) # Liquid 1 bubble line
plt.plot(l1ve.y, l1ve.p) # Liquid 1 dew line

plt.plot(l2ve.x, l2ve.p) # Liquid 2 bubble line
plt.plot(l2ve.y, l2ve.p) # Liquid 2 dew line

And the equivalent for get_binary_txy, only replacing p for T.