phasepy.mixture

phasepy.mixture object stores both pure component and mixture related information and interaction parameters needed for equilibria and interfacial properties computation. Two pure components are required to create a base mixture:

>>> import numpy as np
>>> from phasepy import component, mixture
>>> water = component(name='water', Tc=647.13, Pc=220.55, Zc=0.229, Vc=55.948, w=0.344861,
                      Ant=[11.64785144, 3797.41566067, -46.77830444],
                      GC={'H2O':1})
>>> ethanol = component(name='ethanol', Tc=514.0, Pc=61.37, Zc=0.241, Vc=168.0, w=0.643558,
                        Ant=[11.61809279, 3423.0259436, -56.48094263],
                        GC={'CH3':1, 'CH2':1, 'OH(P)':1})
>>> mix = mixture(ethanol, water)

Additional components can be added to the mixture with phasepy.mixture.add_component().

>>> mtbe = component(name='mtbe', Tc=497.1, Pc=34.3, Zc=0.273, Vc=329.0, w=0.266059,
                     Ant=[9.16238246, 2541.97883529, -50.40534341],
                     GC={'CH3':3, 'CH3O':1, 'C':1})
>>> mix.add_component(mtbe)

Once all components have been added to the mixture, the interaction parameters must be supplied using a function depending on which model will be used:

For quadratic mixing rule (QMR) used in cubic EoS:

>>> kij = np.array([[0, k12, k13],
                    [k21, 0, k23],
                    [k31, k32, 0]])
>>> mix.kij_cubic(kij)

For NRTL model:

>>> alpha = np.array([[0, alpha12, alpha13],
                      [alpha21, 0, alpha23],
                      [alpha31, alpha32, 0]])
>>> g = np.array([[0, g12, g13],
                  [g21, 0, g23],
                  [g31, g32, 0]])
>>> g1 = np.array([[0, gT12, gT13],
                   [gT21, 0, gT23],
                   [gT31, gT32, 0]])
>>> mix.NRTL(alpha, g, g1)

For Wilson model:

>>> A = np.array([[0, A12, A13],
                  [A21, 0, A23],
                  [A31, A32, 0]])
>>> mix.wilson(A)

For Redlich Kister parameters are set by polynomial by pairs, the order of the pairs must be the following: 1-2, 1-3, …, 1-n, 2-3, …, 2-n, etc.

>>> C0 = np.array([poly12], [poly13], [poly23]]
>>> C1 = np.array([polyT12], [polyT13], [polyT23]]
>>> mix.rk(C0, C1)

For Modified-UNIFAC model, Dortmund public database must be read in:

>>> mix.unifac()

Warning

User is required to supply the necessary parameters for methods

class mixture(component1, component2)[source]

Object class for info about a mixture.

Parameters:
  • component1 (component) – First mixture component object
  • component2 (component) – Second mixture component object
name

Names of the components

Type:List[str]
Tc

Critical temperatures [K]

Type:List[float]
Pc

Critical pressures [bar]

Type:List[float]
Zc

critical compressibility factors

Type:List[float]
Vc

Critical molar volumes [\(\mathrm{cm^3/mol}\)]

Type:List[float]
w

Acentric factors

Type:List[float]
c

Volume translation parameter used in cubic EoS [\(\mathrm{cm^3/mol}\)]

Type:List[float]
cii

Polynomial coefficients for influence parameter used in SGT model

Type:List[list]
ksv

Parameters for alpha for PRSV EoS, if fitted

Type:List[list]
Ant

Antoine correlation parameters

Type:List[list]
GC

Group contribution information used in Modified-UNIFAC activity coefficient model. Group definitions can be found here.

Type:List[dict]
Mw

molar weights of the fluids in the mixture [g/mol]

Type:list[dict]
qi

Component molecular surface used in UNIQUAC model

Type:list[dict]
ri

Component molecular volume used in UNIQUAC model

Type:list[dict]
alpha_params

parameters for custom cubic alpha functions

Type:list[Any]
dHf

Enthalpy of fusion [J/mol]

Type:list[float]
Tf

Temperature of fusion [K]

Type:list[float]
NRTL(alpha, g, g1=None)[source]

Adds NRTL parameters to the mixture.

Parameters:
  • alpha (array) – Aleatory factor
  • g (array) – Matrix of energy interactions [K]
  • g1 (array, optional) – Matrix of energy interactions [1/K]

Note

Parameters are evaluated as a function of temperature: \(\tau = g/T + g_1\)

add_component(component)[source]

Adds a component to the mixture

ci(T)[source]

Returns the matrix of cij interaction parameters for SGT model at a given temperature.

Parameters:T (float) – Absolute temperature [K]
copy()[source]

Returns a copy of the mixture object

kij_cubic(kij, balanced=True)[source]

Adds kij matrix coefficients for QMR mixing rule to the mixture. Matrix must be symmetrical and the main diagonal must be zero.

Parameters:
  • kij (array_like) – Matrix of interaction parameters
  • balanced (bool, optional) – If True, the kij matrix must be symmetrical
kij_saft(kij)[source]

Adds kij binary interaction matrix for SAFT-VR-Mie to the mixture. Matrix must be symmetrical and the main diagonal must be zero.

\[\epsilon_{ij} = (1-k_{ij})\]

rac{sqrt{sigma_i^3 sigma_j^3}}{sigma_{ij}^3} sqrt{epsilon_i epsilon_j}

kij: array_like
Matrix of interaction parameters
kij_ws(kij)[source]

Adds kij matrix coefficients for WS mixing rule to the mixture. Matrix must be symmetrical and the main diagonal must be zero.

Parameters:kij (array_like) – Matrix of interaction parameters
original_unifac()[source]

Reads database for Original-UNIFAC model to the mixture for calculation of activity coefficients.

Group definitions can be found here.

psat(T)[source]

Returns array of vapour saturation pressures [bar] at a given temperature using Antoine equation. Exponential base is \(e\).

The following Antoine’s equation is used:

:math:`ln (P /bar) = A -

rac{B}{T/K + C}`

T : float
Absolute temperature [K]
Psat : array_like
saturation pressure of each component [bar]
rk(c, c1=None)[source]

Adds Redlich Kister polynomial coefficients for excess Gibbs energy to the mixture.

Parameters:
  • c (array) – Polynomial values [Adim]
  • c1 (array, optional) – Polynomial values [K]

Note

Parameters are evaluated as a function of temperature: \(G = c + c_1/T\)

rkb(c, c1=None)[source]

Adds binary Redlich Kister polynomial coefficients for excess Gibbs energy to the mixture.

Parameters:
  • c (array) – Polynomial values [Adim]
  • c1 (array, optional) – Polynomial values [K]

Note

Parameters are evaluated as a function of temperature: \(G = c + c_1/T\)

rkt(D)[source]

Adds a ternary polynomial modification for NRTL model to the mixture.

Parameters:D (array) – Ternary interaction parameter values
tsat(P)[source]

Returns array of vapour saturation temperatures [K] at a given pressure using Antoine equation. Exponential base is \(e\).

The following Antoine’s equation is used:

:math:`ln (P /bar) = A -

rac{B}{T/K + C}`

Psat : float
Saturation pressure [bar]
Tsat : array_like
saturation temperature of each component [K]
unifac()[source]

Reads the Dortmund database for Modified-UNIFAC model to the mixture for calculation of activity coefficients.

Group definitions can be found `here

<http://www.ddbst.com/PublishedParametersUNIFACDO.html#ListOfMainGroups>`_.

uniquac(a0, a1=None)[source]

Adds UNIQUAC interaction energies to the mixture.

Parameters:
  • a0 (array) – Matrix of energy interactions [K]
  • a1 (array, optional) – Matrix of energy interactions [Adim.]

Note

Parameters are evaluated as a function of temperature: \(a_{ij} = a_0 + a_1 T\)

vlrackett(T)[source]

Returns array of liquid molar volumes [\(\mathrm{cm^3/mol}\)] at a given temperature using the Rackett equation.

\(v = v_c Z_c^{(1 - T_r)^{2/7}}\)

Parameters:T (float) – Absolute temperature [K]
Returns:vl – liquid volume of each component [cm3 mol-1]
Return type:array_like
wilson(A)[source]

Adds Wilson model coefficients to the mixture. Argument matrix main diagonal must be zero.

Parameters:A (array) – Interaction parameter values [K]