Cubic Equations of State for Mixtures (thermo.eos_mix)

This module contains implementations of most cubic equations of state for mixtures. 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_mix.GCEOSMIX[source]

Bases: thermo.eos.GCEOS

Class for solving a generic pressure-explicit three-parameter cubic equation of state for a mixture. Does not implement any parameters itself; must be subclassed by a mixture equation of state class which subclasses it.

\[P=\frac{RT}{V-b}-\frac{a\alpha(T)}{V^2 + \delta V + \epsilon} \]
Attributes
A_dep_g

Departure molar Helmholtz energy from ideal gas behavior for the gas phase, [J/mol].

A_dep_l

Departure molar Helmholtz energy from ideal gas behavior for the liquid phase, [J/mol].

Cp_minus_Cv_g

Cp - Cv for the gas phase, [J/mol/K].

Cp_minus_Cv_l

Cp - Cv for the liquid phase, [J/mol/K].

U_dep_g

Departure molar internal energy from ideal gas behavior for the gas phase, [J/mol].

U_dep_l

Departure molar internal energy from ideal gas behavior for the liquid phase, [J/mol].

V_dep_g

Departure molar volume from ideal gas behavior for the gas phase, [m^3/mol].

V_dep_l

Departure molar volume from ideal gas behavior for the liquid phase, [m^3/mol].

V_g_mpmath

The molar volume of the gas phase calculated with mpmath to a higher precision, [m^3/mol].

V_l_mpmath

The molar volume of the liquid phase calculated with mpmath to a higher precision, [m^3/mol].

Vc

Critical volume, [m^3/mol].

a_alpha_ijs

Calculate and return the matrix \((a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}}\).

beta_g

Isobaric (constant-pressure) expansion coefficient for the gas phase, [1/K].

beta_l

Isobaric (constant-pressure) expansion coefficient for the liquid phase, [1/K].

c1
c2
d2H_dep_dT2_g

Second temperature derivative of departure enthalpy with respect to temperature for the gas phase, [(J/mol)/K^2].

d2H_dep_dT2_g_P

Second temperature derivative of departure enthalpy with respect to temperature for the gas phase, [(J/mol)/K^2].

d2H_dep_dT2_g_V

Second temperature derivative of departure enthalpy with respect to temperature at constant volume for the gas phase, [(J/mol)/K^2].

d2H_dep_dT2_l

Second temperature derivative of departure enthalpy with respect to temperature for the liquid phase, [(J/mol)/K^2].

d2H_dep_dT2_l_P

Second temperature derivative of departure enthalpy with respect to temperature for the liquid phase, [(J/mol)/K^2].

d2H_dep_dT2_l_V

Second temperature derivative of departure enthalpy with respect to temperature at constant volume for the liquid phase, [(J/mol)/K^2].

d2H_dep_dTdP_g

Temperature and pressure derivative of departure enthalpy at constant pressure then temperature for the gas phase, [(J/mol)/K/Pa].

d2H_dep_dTdP_l

Temperature and pressure derivative of departure enthalpy at constant pressure then temperature for the liquid phase, [(J/mol)/K/Pa].

d2P_dT2_PV_g

Second derivative of pressure with respect to temperature twice, but with pressure held constant the first time and volume held constant the second time for the gas phase, [Pa/K^2].

d2P_dT2_PV_l

Second derivative of pressure with respect to temperature twice, but with pressure held constant the first time and volume held constant the second time for the liquid phase, [Pa/K^2].

d2P_dTdP_g

Second derivative of pressure with respect to temperature and, then pressure; and with volume held constant at first, then temperature, for the gas phase, [1/K].

d2P_dTdP_l

Second derivative of pressure with respect to temperature and, then pressure; and with volume held constant at first, then temperature, for the liquid phase, [1/K].

d2P_dTdrho_g

Derivative of pressure with respect to molar density, and temperature for the gas phase, [Pa/(K*mol/m^3)].

d2P_dTdrho_l

Derivative of pressure with respect to molar density, and temperature for the liquid phase, [Pa/(K*mol/m^3)].

d2P_dVdP_g

Second derivative of pressure with respect to molar volume and then pressure for the gas phase, [mol/m^3].

d2P_dVdP_l

Second derivative of pressure with respect to molar volume and then pressure for the liquid phase, [mol/m^3].

d2P_dVdT_TP_g

Second derivative of pressure with respect to molar volume and then temperature at constant temperature then pressure for the gas phase, [Pa*mol/m^3/K].

d2P_dVdT_TP_l

Second derivative of pressure with respect to molar volume and then temperature at constant temperature then pressure for the liquid phase, [Pa*mol/m^3/K].

d2P_dVdT_g

Alias of GCEOS.d2P_dTdV_g

d2P_dVdT_l

Alias of GCEOS.d2P_dTdV_l

d2P_drho2_g

Second derivative of pressure with respect to molar density for the gas phase, [Pa/(mol/m^3)^2].

d2P_drho2_l

Second derivative of pressure with respect to molar density for the liquid phase, [Pa/(mol/m^3)^2].

d2S_dep_dT2_g

Second temperature derivative of departure entropy with respect to temperature for the gas phase, [(J/mol)/K^3].

d2S_dep_dT2_g_V

Second temperature derivative of departure entropy with respect to temperature at constant volume for the gas phase, [(J/mol)/K^3].

d2S_dep_dT2_l

Second temperature derivative of departure entropy with respect to temperature for the liquid phase, [(J/mol)/K^3].

d2S_dep_dT2_l_V

Second temperature derivative of departure entropy with respect to temperature at constant volume for the liquid phase, [(J/mol)/K^3].

d2S_dep_dTdP_g

Temperature and pressure derivative of departure entropy at constant pressure then temperature for the gas phase, [(J/mol)/K^2/Pa].

d2S_dep_dTdP_l

Temperature and pressure derivative of departure entropy at constant pressure then temperature for the liquid phase, [(J/mol)/K^2/Pa].

d2T_dP2_g

Second partial derivative of temperature with respect to pressure (constant volume) for the gas phase, [K/Pa^2].

d2T_dP2_l

Second partial derivative of temperature with respect to pressure (constant temperature) for the liquid phase, [K/Pa^2].

d2T_dPdV_g

Second partial derivative of temperature with respect to pressure (constant volume) and then volume (constant pressure) for the gas phase, [K*mol/(Pa*m^3)].

d2T_dPdV_l

Second partial derivative of temperature with respect to pressure (constant volume) and then volume (constant pressure) for the liquid phase, [K*mol/(Pa*m^3)].

d2T_dPdrho_g

Derivative of temperature with respect to molar density, and pressure for the gas phase, [K/(Pa*mol/m^3)].

d2T_dPdrho_l

Derivative of temperature with respect to molar density, and pressure for the liquid phase, [K/(Pa*mol/m^3)].

d2T_dV2_g

Second partial derivative of temperature with respect to volume (constant pressure) for the gas phase, [K*mol^2/m^6].

d2T_dV2_l

Second partial derivative of temperature with respect to volume (constant pressure) for the liquid phase, [K*mol^2/m^6].

d2T_dVdP_g

Second partial derivative of temperature with respect to pressure (constant volume) and then volume (constant pressure) for the gas phase, [K*mol/(Pa*m^3)].

d2T_dVdP_l

Second partial derivative of temperature with respect to pressure (constant volume) and then volume (constant pressure) for the liquid phase, [K*mol/(Pa*m^3)].

d2T_drho2_g

Second derivative of temperature with respect to molar density for the gas phase, [K/(mol/m^3)^2].

d2T_drho2_l

Second derivative of temperature with respect to molar density for the liquid phase, [K/(mol/m^3)^2].

d2V_dP2_g

Second partial derivative of volume with respect to pressure (constant temperature) for the gas phase, [m^3/(Pa^2*mol)].

d2V_dP2_l

Second partial derivative of volume with respect to pressure (constant temperature) for the liquid phase, [m^3/(Pa^2*mol)].

d2V_dPdT_g

Second partial derivative of volume with respect to pressure (constant temperature) and then presssure (constant temperature) for the gas phase, [m^3/(K*Pa*mol)].

d2V_dPdT_l

Second partial derivative of volume with respect to pressure (constant temperature) and then presssure (constant temperature) for the liquid phase, [m^3/(K*Pa*mol)].

d2V_dT2_g

Second partial derivative of volume with respect to temperature (constant pressure) for the gas phase, [m^3/(mol*K^2)].

d2V_dT2_l

Second partial derivative of volume with respect to temperature (constant pressure) for the liquid phase, [m^3/(mol*K^2)].

d2V_dTdP_g

Second partial derivative of volume with respect to pressure (constant temperature) and then presssure (constant temperature) for the gas phase, [m^3/(K*Pa*mol)].

d2V_dTdP_l

Second partial derivative of volume with respect to pressure (constant temperature) and then presssure (constant temperature) for the liquid phase, [m^3/(K*Pa*mol)].

d2a_alpha_dT2_dns

Helper method for calculating the mole number derivatives of d2a_alpha_dT2.

d2a_alpha_dT2_dzs

Helper method for calculating the mole number derivatives of d2a_alpha_dT2.

d2a_alpha_dT2_ijs

Calculate and return the matrix of the second temperature derivatives of the alpha terms.

d2a_alpha_dTdP_g_V

Derivative of the temperature derivative of a_alpha with respect to pressure at constant volume (varying T) for the gas phase, [J^2/mol^2/Pa^2/K].

d2a_alpha_dTdP_l_V

Derivative of the temperature derivative of a_alpha with respect to pressure at constant volume (varying T) for the liquid phase, [J^2/mol^2/Pa^2/K].

d2a_alpha_dninjs

Helper method for calculating the second partial molar derivatives of a_alpha (hessian).

d2a_alpha_dzizjs

Helper method for calculating the second composition derivatives of a_alpha (hessian).

d2b_dninjs

Helper method for calculating the second partial mole number derivatives of b.

d2b_dzizjs

Helper method for calculating the second partial mole fraction derivatives of b.

d2rho_dP2_g

Second derivative of molar density with respect to pressure for the gas phase, [(mol/m^3)/Pa^2].

d2rho_dP2_l

Second derivative of molar density with respect to pressure for the liquid phase, [(mol/m^3)/Pa^2].

d2rho_dPdT_g

Second derivative of molar density with respect to pressure and temperature for the gas phase, [(mol/m^3)/(K*Pa)].

d2rho_dPdT_l

Second derivative of molar density with respect to pressure and temperature for the liquid phase, [(mol/m^3)/(K*Pa)].

d2rho_dT2_g

Second derivative of molar density with respect to temperature for the gas phase, [(mol/m^3)/K^2].

d2rho_dT2_l

Second derivative of molar density with respect to temperature for the liquid phase, [(mol/m^3)/K^2].

d3a_alpha_dT3

Method to calculate the third temperature derivative of \(a \alpha\), [J^2/mol^2/Pa/K^3].

d3a_alpha_dninjnks

Helper method for calculating the third mole number derivatives of a_alpha.

d3a_alpha_dzizjzks

Helper method for calculating the third composition derivatives of a_alpha.

d3b_dninjnks

Helper method for calculating the third partial mole number derivatives of b.

d3b_dzizjzks

Helper method for calculating the third partial mole fraction derivatives of b.

d3delta_dzizjzks

Helper method for calculating the third composition derivatives of delta.

d3epsilon_dzizjzks

Helper method for calculating the third composition derivatives of epsilon.

dH_dep_dP_g

Derivative of departure enthalpy with respect to pressure for the gas phase, [(J/mol)/Pa].

dH_dep_dP_g_V

Derivative of departure enthalpy with respect to pressure at constant volume for the liquid phase, [(J/mol)/Pa].

dH_dep_dP_l

Derivative of departure enthalpy with respect to pressure for the liquid phase, [(J/mol)/Pa].

dH_dep_dP_l_V

Derivative of departure enthalpy with respect to pressure at constant volume for the gas phase, [(J/mol)/Pa].

dH_dep_dT_g

Derivative of departure enthalpy with respect to temperature for the gas phase, [(J/mol)/K].

dH_dep_dT_g_V

Derivative of departure enthalpy with respect to temperature at constant volume for the gas phase, [(J/mol)/K].

dH_dep_dT_l

Derivative of departure enthalpy with respect to temperature for the liquid phase, [(J/mol)/K].

dH_dep_dT_l_V

Derivative of departure enthalpy with respect to temperature at constant volume for the liquid phase, [(J/mol)/K].

dH_dep_dV_g_P

Derivative of departure enthalpy with respect to volume at constant pressure for the gas phase, [J/m^3].

dH_dep_dV_g_T

Derivative of departure enthalpy with respect to volume at constant temperature for the gas phase, [J/m^3].

dH_dep_dV_l_P

Derivative of departure enthalpy with respect to volume at constant pressure for the liquid phase, [J/m^3].

dH_dep_dV_l_T

Derivative of departure enthalpy with respect to volume at constant temperature for the gas phase, [J/m^3].

dP_drho_g

Derivative of pressure with respect to molar density for the gas phase, [Pa/(mol/m^3)].

dP_drho_l

Derivative of pressure with respect to molar density for the liquid phase, [Pa/(mol/m^3)].

dS_dep_dP_g

Derivative of departure entropy with respect to pressure for the gas phase, [(J/mol)/K/Pa].

dS_dep_dP_g_V

Derivative of departure entropy with respect to pressure at constant volume for the gas phase, [(J/mol)/K/Pa].

dS_dep_dP_l

Derivative of departure entropy with respect to pressure for the liquid phase, [(J/mol)/K/Pa].

dS_dep_dP_l_V

Derivative of departure entropy with respect to pressure at constant volume for the liquid phase, [(J/mol)/K/Pa].

dS_dep_dT_g

Derivative of departure entropy with respect to temperature for the gas phase, [(J/mol)/K^2].

dS_dep_dT_g_V

Derivative of departure entropy with respect to temperature at constant volume for the gas phase, [(J/mol)/K^2].

dS_dep_dT_l

Derivative of departure entropy with respect to temperature for the liquid phase, [(J/mol)/K^2].

dS_dep_dT_l_V

Derivative of departure entropy with respect to temperature at constant volume for the liquid phase, [(J/mol)/K^2].

dS_dep_dV_g_P

Derivative of departure entropy with respect to volume at constant pressure for the gas phase, [J/K/m^3].

dS_dep_dV_g_T

Derivative of departure entropy with respect to volume at constant temperature for the gas phase, [J/K/m^3].

dS_dep_dV_l_P

Derivative of departure entropy with respect to volume at constant pressure for the liquid phase, [J/K/m^3].

dS_dep_dV_l_T

Derivative of departure entropy with respect to volume at constant temperature for the gas phase, [J/K/m^3].

dT_drho_g

Derivative of temperature with respect to molar density for the gas phase, [K/(mol/m^3)].

dT_drho_l

Derivative of temperature with respect to molar density for the liquid phase, [K/(mol/m^3)].

dZ_dP_g

Derivative of compressibility factor with respect to pressure for the gas phase, [1/Pa].

dZ_dP_l

Derivative of compressibility factor with respect to pressure for the liquid phase, [1/Pa].

dZ_dT_g

Derivative of compressibility factor with respect to temperature for the gas phase, [1/K].

dZ_dT_l

Derivative of compressibility factor with respect to temperature for the liquid phase, [1/K].

da_alpha_dP_g_V

Derivative of the a_alpha with respect to pressure at constant volume (varying T) for the gas phase, [J^2/mol^2/Pa^2].

da_alpha_dP_l_V

Derivative of the a_alpha with respect to pressure at constant volume (varying T) for the liquid phase, [J^2/mol^2/Pa^2].

da_alpha_dT_dns

Helper method for calculating the mole number derivatives of da_alpha_dT.

da_alpha_dT_dzs

Helper method for calculating the composition derivatives of da_alpha_dT.

da_alpha_dT_ijs

Calculate and return the matrix for the temperature derivatives of the alpha terms.

da_alpha_dns

Helper method for calculating the mole number derivatives of a_alpha.

da_alpha_dzs

Helper method for calculating the composition derivatives of a_alpha.

db_dns

Helper method for calculating the mole number derivatives of b.

db_dzs

Helper method for calculating the composition derivatives of b.

dbeta_dP_g

Derivative of isobaric expansion coefficient with respect to pressure for the gas phase, [1/(Pa*K)].

dbeta_dP_l

Derivative of isobaric expansion coefficient with respect to pressure for the liquid phase, [1/(Pa*K)].

dbeta_dT_g

Derivative of isobaric expansion coefficient with respect to temperature for the gas phase, [1/K^2].

dbeta_dT_l

Derivative of isobaric expansion coefficient with respect to temperature for the liquid phase, [1/K^2].

dfugacity_dP_g

Derivative of fugacity with respect to pressure for the gas phase, [-].

dfugacity_dP_l

Derivative of fugacity with respect to pressure for the liquid phase, [-].

dfugacity_dT_g

Derivative of fugacity with respect to temperature for the gas phase, [Pa/K].

dfugacity_dT_l

Derivative of fugacity with respect to temperature for the liquid phase, [Pa/K].

dna_alpha_dT_dns

Helper method for calculating the mole number derivatives of da_alpha_dT.

dna_alpha_dns

Helper method for calculating the partial molar derivatives of a_alpha.

dnb_dns

Helper method for calculating the partial molar derivative of b.

dphi_dP_g

Derivative of fugacity coefficient with respect to pressure for the gas phase, [1/Pa].

dphi_dP_l

Derivative of fugacity coefficient with respect to pressure for the liquid phase, [1/Pa].

dphi_dT_g

Derivative of fugacity coefficient with respect to temperature for the gas phase, [1/K].

dphi_dT_l

Derivative of fugacity coefficient with respect to temperature for the liquid phase, [1/K].

drho_dP_g

Derivative of molar density with respect to pressure for the gas phase, [(mol/m^3)/Pa].

drho_dP_l

Derivative of molar density with respect to pressure for the liquid phase, [(mol/m^3)/Pa].

drho_dT_g

Derivative of molar density with respect to temperature for the gas phase, [(mol/m^3)/K].

drho_dT_l

Derivative of molar density with respect to temperature for the liquid phase, [(mol/m^3)/K].

fugacity_g

Fugacity for the gas phase, [Pa].

fugacity_l

Fugacity for the liquid phase, [Pa].

kappa_g

Isothermal (constant-temperature) expansion coefficient for the gas phase, [1/Pa].

kappa_l

Isothermal (constant-temperature) expansion coefficient for the liquid phase, [1/Pa].

lnphi_g

The natural logarithm of the fugacity coefficient for the gas phase, [-].

lnphi_l

The natural logarithm of the fugacity coefficient for the liquid phase, [-].

more_stable_phase

Checks the Gibbs energy of each possible phase, and returns ‘l’ if the liquid-like phase is more stable, and ‘g’ if the vapor-like phase is more stable.

mpmath_volume_ratios

Method to compare, as ratios, the volumes of the implemented cubic solver versus those calculated using mpmath.

mpmath_volumes

Method to calculate to a high precision the exact roots to the cubic equation, using mpmath.

mpmath_volumes_float

Method to calculate real roots of a cubic equation, using mpmath, but returned as floats.

phi_g

Fugacity coefficient for the gas phase, [Pa].

phi_l

Fugacity coefficient for the liquid phase, [Pa].

pseudo_Pc

Apply a linear mole-fraction mixing rule to compute the average critical pressure, [Pa].

pseudo_Tc

Apply a linear mole-fraction mixing rule to compute the average critical temperature, [K].

pseudo_a

Apply a linear mole-fraction mixing rule to compute the average a coefficient, [-].

pseudo_omega

Apply a linear mole-fraction mixing rule to compute the average omega, [-].

rho_g

Gas molar density, [mol/m^3].

rho_l

Liquid molar density, [mol/m^3].

sorted_volumes

List of lexicographically-sorted molar volumes available from the root finding algorithm used to solve the PT point.

state_specs

Convenience method to return the two specified state specs (T, P, or V) as a dictionary.

Methods

Hvap(T)

Method to calculate enthalpy of vaporization for a pure fluid from an equation of state, without iteration.

PT_surface_special([Tmin, Tmax, Pmin, Pmax, ...])

Method to create a plot of the special curves of a fluid - vapor pressure, determinant zeros, pseudo critical point, and mechanical critical point.

P_PIP_transition(T[, low_P_limit])

Method to calculate the pressure which makes the phase identification parameter exactly 1.

P_discriminant_zero_g()

Method to calculate the pressure which zero the discriminant function of the general cubic eos, and is likely to sit on a boundary between not having a vapor-like volume; and having a vapor-like volume.

P_discriminant_zero_l()

Method to calculate the pressure which zero the discriminant function of the general cubic eos, and is likely to sit on a boundary between not having a liquid-like volume; and having a liquid-like volume.

P_discriminant_zeros()

Method to calculate the pressures which zero the discriminant function of the general cubic eos, at the current temperature.

P_discriminant_zeros_analytical(T, b, delta, ...)

Method to calculate the pressures which zero the discriminant function of the general cubic eos.

P_max_at_V(V)

Dummy method.

Psat(T[, polish])

Generic method to calculate vapor pressure of a pure-component equation of state for a specified T.

Psat_errors([Tmin, Tmax, pts, plot, show, ...])

Method to create a plot of vapor pressure and the relative error of its calculation vs.

T_discriminant_zero_g([T_guess])

Method to calculate the temperature which zeros the discriminant function of the general cubic eos, and is likely to sit on a boundary between not having a vapor-like volume; and having a vapor-like volume.

T_discriminant_zero_l([T_guess])

Method to calculate the temperature which zeros the discriminant function of the general cubic eos, and is likely to sit on a boundary between not having a liquid-like volume; and having a liquid-like volume.

T_max_at_V(V[, Pmax])

Method to calculate the maximum temperature the EOS can create at a constant volume, if one exists; returns None otherwise.

T_min_at_V(V[, Pmin])

Returns the minimum temperature for the EOS to have the volume as specified.

Tsat(P[, polish])

Generic method to calculate the temperature for a specified vapor pressure of the pure fluid.

V_g_sat(T)

Method to calculate molar volume of the vapor phase along the saturation line.

V_l_sat(T)

Method to calculate molar volume of the liquid phase along the saturation line.

Vs_mpmath()

Method to calculate real roots of a cubic equation, using mpmath.

a_alpha_and_derivatives(T[, full, quick, ...])

Method to calculate a_alpha and its first and second derivatives for an EOS with the Van der Waals mixing rules.

a_alpha_and_derivatives_pure(T)

Dummy method to calculate \(a \alpha\) and its first and second derivatives.

a_alpha_for_Psat(T, Psat[, a_alpha_guess])

Method to calculate which value of \(a \alpha\) is required for a given T, Psat pair.

a_alpha_for_V(T, P, V)

Method to calculate which value of \(a \alpha\) is required for a given T, P pair to match a specified V.

a_alpha_plot([Tmin, Tmax, pts, plot, show])

Method to create a plot of the \(a \alpha\) parameter and its first two derivatives.

as_json()

Method to create a JSON-friendly serialization of the eos which can be stored, and reloaded later.

check_sufficient_inputs()

Method to an exception if none of the pairs (T, P), (T, V), or (P, V) are given.

d2G_dep_dninjs(Z)

Calculates the molar departure Gibbs energy mole number derivatives (where the mole fractions sum to 1).

d2G_dep_dzizjs(Z)

Calculates the molar departure Gibbs energy second composition derivative (where the mole fractions do not sum to 1).

d2V_dninjs(Z)

Calculates the molar volume second mole number derivatives (where the mole fractions sum to 1).

d2V_dzizjs(Z)

Calculates the molar volume second composition derivative (where the mole fractions do not sum to 1).

d2lnphi_dninjs(Z)

Calculates the mixture log fugacity coefficient second mole number derivatives (where the mole fraction sum to 1).

d2lnphi_dzizjs(Z)

Calculates the mixture log fugacity coefficient second mole fraction derivatives (where the mole fractions do not sum to 1).

d2phi_sat_dT2(T[, polish])

Method to calculate the second temperature derivative of saturation fugacity coefficient of the compound.

dG_dep_dns(Z)

Calculates the molar departure Gibbs energy mole number derivatives (where the mole fractions sum to 1).

dG_dep_dzs(Z)

Calculates the molar departure Gibbs energy composition derivative (where the mole fractions do not sum to 1).

dH_dep_dT_sat_g(T[, polish])

Method to calculate and return the temperature derivative of saturation vapor excess enthalpy.

dH_dep_dT_sat_l(T[, polish])

Method to calculate and return the temperature derivative of saturation liquid excess enthalpy.

dH_dep_dns(Z)

Calculates the molar departure enthalpy mole number derivatives (where the mole fractions sum to 1).

dH_dep_dzs(Z)

Calculates the molar departure enthalpy composition derivative (where the mole fractions do not sum to 1).

dPsat_dT(T[, polish, also_Psat])

Generic method to calculate the temperature derivative of vapor pressure for a specified T.

dS_dep_dT_sat_g(T[, polish])

Method to calculate and return the temperature derivative of saturation vapor excess entropy.

dS_dep_dT_sat_l(T[, polish])

Method to calculate and return the temperature derivative of saturation liquid excess entropy.

dS_dep_dns(Z)

Calculates the molar departure entropy mole number derivatives (where the mole fractions sum to 1).

dS_dep_dzs(Z)

Calculates the molar departure entropy composition derivative (where the mole fractions do not sum to 1).

dV_dns(Z)

Calculates the molar volume mole number derivatives (where the mole fractions sum to 1).

dV_dzs(Z)

Calculates the molar volume composition derivative (where the mole fractions do not sum to 1).

dZ_dns(Z)

Calculates the compressibility mole number derivatives (where the mole fractions sum to 1).

dZ_dzs(Z)

Calculates the compressibility composition derivatives (where the mole fractions do not sum to 1).

dfugacities_dns(phase)

Generic formula for calculating the mole number derivaitves of fugacities for each species in a mixture.

discriminant([T, P])

Method to compute the discriminant of the cubic volume solution with the current EOS parameters, optionally at the same (assumed) T, and P or at different ones, if values are specified.

dlnfugacities_dns(phase)

Generic formula for calculating the mole number derivaitves of log fugacities for each species in a mixture.

dlnphi_dns(Z)

Calculates the mixture log fugacity coefficient mole number derivatives (where the mole fractions sum to 1).

dlnphi_dzs(Z)

Calculates the mixture log fugacity coefficient mole fraction derivatives (where the mole fractions do not sum to 1).

dlnphis_dP(phase)

Generic formula for calculating the pressure derivaitve of log fugacity coefficients for each species in a mixture.

dlnphis_dT(phase)

Generic formula for calculating the temperature derivaitve of log fugacity coefficients for each species in a mixture.

dlnphis_dns(Z)

Generic formula for calculating the mole number derivaitves of log fugacity coefficients for each species in a mixture.

dlnphis_dzs(Z)

Generic formula for calculating the mole fraction derivaitves of log fugacity coefficients for each species in a mixture.

dnG_dep_dns(Z)

Calculates the partial molar departure Gibbs energy.

dnH_dep_dns(Z)

Calculates the partial molar departure enthalpy.

dnV_dns(Z)

Calculates the partial molar volume of the specified phase No specific formula is implemented for this property - it is calculated from the molar volume mole fraction derivative.

dnZ_dns(Z)

Calculates the partial compressibility of the specified phase No specific formula is implemented for this property - it is calculated from the compressibility mole fraction derivative.

dphi_sat_dT(T[, polish])

Method to calculate the temperature derivative of saturation fugacity coefficient of the compound.

from_json(json_repr)

Method to create a mixture cubic equation of state from a JSON friendly serialization of another mixture cubic equation of state.

fugacities([only_l, only_g])

Helper method for calculating fugacity coefficients for any phases present, using either the overall mole fractions for both phases or using specified mole fractions for each phase.

fugacity_coefficients(Z)

Generic formula for calculating log fugacity coefficients for each species in a mixture.

mechanical_critical_point()

Method to calculate the mechanical critical point of a mixture of defined composition.

model_hash()

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.

phi_sat(T[, polish])

Method to calculate the saturation fugacity coefficient of the compound.

pures()

Helper method which returns a list of pure EOSs at the same T and P and base EOS as the mixture.

resolve_full_alphas()

Generic method to resolve the eos with fully calculated alpha derviatives.

saturation_prop_plot(prop[, Tmin, Tmax, ...])

Method to create a plot of a specified property of the EOS along the (pure component) saturation line.

set_dnzs_derivatives_and_departures([n, x, ...])

Sets a number of mole number and/or composition partial derivatives of thermodynamic partial derivatives.

set_from_PT(Vs[, only_l, only_g])

Counts the number of real volumes in Vs, and determines what to do.

set_properties_from_solution(T, P, V, b, ...)

Sets all interesting properties which can be calculated from an EOS alone.

solve([pure_a_alphas, only_l, only_g, ...])

First EOS-generic method; should be called by all specific EOSs.

solve_T(P, V[, quick, solution])

Generic method to calculate T from a specified P and V.

solve_missing_volumes()

Generic method to ensure both volumes, if solutions are physical, have calculated properties.

state_hash()

Basic method to calculate a hash of the state of the model and its model parameters.

subset(idxs, **state_specs)

Method to construct a new GCEOSMIX that removes all components not specified in the idxs argument.

to([zs, T, P, V, fugacities])

Method to construct a new GCEOSMIX object at two of T, P or V with the specified composition.

to_PV(P, V)

Method to construct a new GCEOSMIX object at the spcified P and V with the current composition.

to_PV_zs(P, V, zs[, fugacities, only_l, only_g])

Method to construct a new GCEOSMIX instance at P, V, and zs with the same parameters as the existing object.

to_TP(T, P)

Method to construct a new GCEOSMIX object at the spcified T and P with the current composition.

to_TPV_pure(i[, T, P, V])

Helper method which returns a pure EOSs at the specs (two of T, P and V) and base EOS as the mixture for a particular index.

to_TP_zs(T, P, zs[, fugacities, only_l, only_g])

Method to construct a new GCEOSMIX instance at T, P, and zs with the same parameters as the existing object.

to_TP_zs_fast(T, P, zs[, only_l, only_g, ...])

Method to construct a new GCEOSMIX instance with the same parameters as the existing object.

to_TV(T, V)

Method to construct a new GCEOSMIX object at the spcified T and V with the current composition.

to_mechanical_critical_point()

Method to construct a new GCEOSMIX object at the current object's properties and composition, but which is at the mechanical critical point.

volume_error()

Method to calculate the relative absolute error in the calculated molar volumes.

volume_errors([Tmin, Tmax, Pmin, Pmax, pts, ...])

Method to create a plot of the relative absolute error in the cubic volume solution as compared to a higher-precision calculation.

volume_solutions(T, P, b, delta, epsilon, ...)

Halley's method based solver for cubic EOS volumes based on the idea of initializing from a single liquid-like guess which is solved precisely, deflating the cubic analytically, solving the quadratic equation for the next two volumes, and then performing two halley steps on each of them to obtain the final solutions.

volume_solutions_full(T, P, b, delta, ...[, ...])

Newton-Raphson based solver for cubic EOS volumes based on the idea of initializing from an analytical solver.

volume_solutions_mp(T, P, b, delta, epsilon, ...)

Solution of this form of the cubic EOS in terms of volumes, using the mpmath arbitrary precision library.

stabiliy_iteration_Michelsen

Psat(T, polish=False)[source]

Generic method to calculate vapor pressure of a pure-component equation of state for a specified T. An explicit solution is used unless polish is True.

The result of this function has no physical meaning for multicomponent mixtures, and does not represent either a dew point or a bubble point!

Parameters
Tfloat

Temperature, [K]

polishbool, optional

Whether to attempt to use a numerical solver to make the solution more precise or not

Returns
Psatfloat

Vapor pressure using the pure-component approach, [Pa]

Notes

For multicomponent mixtures this may serve as a useful guess for the dew and the bubble pressure.

a_alpha_and_derivatives(T, full=True, quick=True, pure_a_alphas=True)[source]

Method to calculate a_alpha and its first and second derivatives for an EOS with the Van der Waals mixing rules. Uses the parent class’s interface to compute pure component values. Returns a_alpha, da_alpha_dT, and d2a_alpha_dT2.

For use in solve_T this returns only a_alpha if full is False.

\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
Parameters
Tfloat

Temperature, [K]

fullbool, optional

If False, calculates and returns only a_alpha

quickbool, optional

Only the quick variant is implemented; it is little faster anyhow

pure_a_alphasbool, optional

Whether or not to recalculate the a_alpha terms of pure components (for the case of mixtures only) which stay the same as the composition changes (i.e in a PT flash), [-]

Returns
a_alphafloat

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

da_alpha_dTfloat

Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2float

Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]

Notes

The exact expressions can be obtained with the following SymPy expression below, commented out for brevity.

>>> from sympy import *  
>>> kij, T = symbols('kij, T ')  
>>> a_alpha_i, a_alpha_j = symbols('a_alpha_i, a_alpha_j', cls=Function)  
>>> a_alpha_ij = (1-kij)*sqrt(a_alpha_i(T)*a_alpha_j(T))  
>>> diff(a_alpha_ij, T)  
>>> diff(a_alpha_ij, T, T)  
property a_alpha_ijs

Calculate and return the matrix \((a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}}\).

Returns
a_alpha_ijslist[list[float]]

a_alpha terms for each component with every other component, [J^2/mol^2/Pa]

Notes

In an earlier implementation this matrix was stored each EOS solve; however, allocating that much memory becomes quite expensive for large number of component cases and this is now calculated on-demand only.

d2G_dep_dninjs(Z)[source]

Calculates the molar departure Gibbs energy mole number derivatives (where the mole fractions sum to 1). No specific formula is implemented for this property - it is calculated from the mole fraction derivative.

\[\left(\frac{\partial^2 G_{dep}}{\partial n_j \partial n_i}\right)_{T, P, n_{i,j\ne k}} = f\left( \left(\frac{\partial^2 G_{dep}}{\partial x_j \partial x_i}\right)_{T, P, x_{i,j\ne k}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
d2G_dep_dninjsfloat

Departure Gibbs energy second mole number derivatives, [J/mol^3]

d2G_dep_dzizjs(Z)[source]

Calculates the molar departure Gibbs energy second composition derivative (where the mole fractions do not sum to 1). Verified numerically. Useful in solving for gibbs minimization calculations or for solving for the true critical point. Also forms the basis for the molar departure Gibbs energy mole second number derivative.

\[\left(\frac{\partial^2 G_{dep}}{\partial x_j \partial x_i}\right)_{T, P, x_{i,j\ne k}} = \text{run SymPy code to obtain - very long!} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
d2G_dep_dzizjsfloat

Departure Gibbs free energy second composition derivatives, [J/mol]

Notes

The derivation for the derivative is performed as follows using SymPy. The function source code is an optimized variant created with the cse SymPy function, and hand optimized further.

>>> from sympy import * 
>>> P, T, R, x1, x2 = symbols('P, T, R, x1, x2') 
>>> a_alpha, delta, epsilon, V, b = symbols('a\ \\alpha, delta, epsilon, V, b', cls=Function) 
>>> da_alpha_dT, d2a_alpha_dT2 = symbols('da_alpha_dT, d2a_alpha_dT2', cls=Function) 
>>> S_dep = R*log(P*V(x1, x2)/(R*T)) + R*log(V(x1, x2)-b(x1, x2))+2*da_alpha_dT(x1, x2)*atanh((2*V(x1, x2)+delta(x1, x2))/sqrt(delta(x1, x2)**2-4*epsilon(x1, x2)))/sqrt(delta(x1, x2)**2-4*epsilon(x1, x2))-R*log(V(x1, x2)) 
>>> H_dep = P*V(x1, x2) - R*T + 2*atanh((2*V(x1, x2)+delta(x1, x2))/sqrt(delta(x1, x2)**2-4*epsilon(x1, x2)))*(da_alpha_dT(x1, x2)*T-a_alpha(x1, x2))/sqrt(delta(x1, x2)**2-4*epsilon(x1, x2)) 
>>> G_dep = simplify(H_dep - T*S_dep) 
>>> diff(G_dep, x1, x2) 
d2V_dninjs(Z)[source]

Calculates the molar volume second mole number derivatives (where the mole fractions sum to 1). No specific formula is implemented for this property - it is calculated from the second mole fraction derivatives.

\[\left(\frac{\partial^2 V}{\partial n_i \partial n_j}\right)_{T, P, n_{k\ne i,j}} = f\left( \left(\frac{\partial^2 V}{\partial x_i\partial x_j}\right)_{T, P, x_{k\ne i,j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
d2V_dninjsfloat

Molar volume second mole number derivatives, [m^3/mol^3]

d2V_dzizjs(Z)[source]

Calculates the molar volume second composition derivative (where the mole fractions do not sum to 1). Verified numerically. Used in many other derivatives, and for the molar volume second mole number derivative.

\[\left(\frac{\partial^2 V}{\partial x_i \partial x_j}\right)_{T, P, x_{k \ne i,j}} = \text{run SymPy code to obtain - very long!} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
d2V_dzizjsfloat

Molar volume second composition derivatives, [m^3/mol]

Notes

The derivation for the derivative is performed as follows using SymPy. The function source code is an optimized variant created with the cse SymPy function, and hand optimized further.

>>> from sympy import * 
>>> P, T, R, x1, x2 = symbols('P, T, R, x1, x2') 
>>> V, delta, epsilon, a_alpha, b = symbols('V, delta, epsilon, a\ \\alpha, b', cls=Function) 
>>> CUBIC = R*T/(V(x1, x2) - b(x1, x2)) - a_alpha(x1, x2)/(V(x1, x2)*V(x1, x2) + delta(x1, x2)*V(x1, x2) + epsilon(x1, x2)) - P 
>>> solve(diff(CUBIC, x1, x2), Derivative(V(x1, x2), x1, x2)) 
property d2a_alpha_dT2_dns

Helper method for calculating the mole number derivatives of d2a_alpha_dT2. Note this is independent of the phase.

\[\left(\frac{\partial^3 a \alpha}{\partial n_i \partial T^2} \right)_{P, n_{i\ne j}} = f\left(\left(\frac{\partial^3 a\alpha}{\partial z_i \partial T^2} \right)_{P, z_{i\ne j}} \right) \]
Returns
d2a_alpha_dT2_dnslist[float]

Mole number derivative of d2a_alpha_dT2 of each component, [kg*m^5/(mol^3*s^2*K^2)]

Notes

This derivative is checked numerically.

property d2a_alpha_dT2_dzs

Helper method for calculating the mole number derivatives of d2a_alpha_dT2. Note this is independent of the phase.

\[\left(\frac{\partial^3 a \alpha}{\partial z_i \partial T^2} \right)_{P, z_{i\ne j}} = \text{large expression} \]
Returns
d2a_alpha_dT2_dzslist[float]

Composition derivative of d2a_alpha_dT2 of each component, [kg*m^5/(mol^2*s^2*K^2)]

Notes

This derivative is checked numerically.

property d2a_alpha_dT2_ijs

Calculate and return the matrix of the second temperature derivatives of the alpha terms.

\[\frac{\partial^2 (a\alpha)_{ij}}{\partial T^2} = - \frac{\sqrt{\operatorname{a\alpha_{i}}{\left(T \right)} \operatorname{a\alpha_{j}} {\left(T \right)}} \left(k_{ij} - 1\right) \left(\frac{\left(\operatorname{ a\alpha_{i}}{\left(T \right)} \frac{d}{d T} \operatorname{a\alpha_{j}}{\left(T \right)} + \operatorname{a\alpha_{j}}{\left(T \right)} \frac{d}{d T} \operatorname{a\alpha_{i}} {\left(T \right)}\right)^{2}}{4 \operatorname{a\alpha_{i}}{\left(T \right)} \operatorname{a\alpha_{j}}{\left(T \right)}} - \frac{\left(\operatorname{a\alpha_{i}} {\left(T \right)} \frac{d}{d T} \operatorname{a\alpha_{j}}{\left(T \right)} + \operatorname{a\alpha_{j}}{\left(T \right)} \frac{d}{d T} \operatorname{a\alpha_{i}}{\left(T \right)}\right) \frac{d}{d T} \operatorname{a\alpha_{j}}{\left(T \right)}}{2 \operatorname{a\alpha_{j}} {\left(T \right)}} - \frac{\left(\operatorname{a\alpha_{i}}{\left(T \right)} \frac{d}{d T} \operatorname{a\alpha_{j}}{\left(T \right)} + \operatorname{a\alpha_{j}}{\left(T \right)} \frac{d}{d T} \operatorname{a\alpha_{i}}{\left(T \right)}\right) \frac{d}{d T} \operatorname{a\alpha_{i}}{\left(T \right)}}{2 \operatorname{a\alpha_{i}} {\left(T \right)}} + \frac{\operatorname{a\alpha_{i}}{\left(T \right)} \frac{d^{2}}{d T^{2}} \operatorname{a\alpha_{j}}{\left(T \right)}}{2} + \frac{\operatorname{a\alpha_{j}}{\left(T \right)} \frac{d^{2}}{d T^{2}} \operatorname{a\alpha_{i}}{\left(T \right)}}{2} + \frac{d}{d T} \operatorname{a\alpha_{i}}{\left(T \right)} \frac{d}{d T} \operatorname{a\alpha_{j}}{\left(T \right)}\right)} {\operatorname{a\alpha_{i}}{\left(T \right)} \operatorname{a\alpha_{j}} {\left(T \right)}} \]
Returns
d2a_alpha_dT2_ijslist[list[float]]

Second temperature derivative of a_alpha terms for each component with every other component, [J^2/mol^2/Pa/K^2]

Notes

In an earlier implementation this matrix was stored each EOS solve; however, allocating that much memory becomes quite expensive for large number of component cases and this is now calculated on-demand only.

property d2a_alpha_dninjs

Helper method for calculating the second partial molar derivatives of a_alpha (hessian). Note this is independent of the phase.

\[\left(\frac{\partial^2 a \alpha}{\partial n_i \partial n_j }\right)_{T, P, n_{k\ne i,j}} = 2\left[3(a \alpha) + (a\alpha)_{ij} -2 (\text{term}_{i,j}) \right] \]
\[\text{term}_{i,j} = \sum_k z_k\left((a\alpha)_{ik} + (a\alpha)_{jk} \right) \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
Returns
d2a_alpha_dninjslist[float]

Second partial molar derivative of alpha of each component, [kg*m^5/(mol^4*s^2)]

Notes

This derivative is checked numerically.

property d2a_alpha_dzizjs

Helper method for calculating the second composition derivatives of a_alpha (hessian). Note this is independent of the phase.

\[\left(\frac{\partial^2 a \alpha}{\partial x_i \partial x_j}\right)_{T, P, x_{k\ne i,j}} = 2 (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
Returns
d2a_alpha_dzizjslist[float]

Second composition derivative of alpha of each component, [kg*m^5/(mol^2*s^2)]

Notes

This derivative is checked numerically.

property d2b_dninjs

Helper method for calculating the second partial mole number derivatives of b. Note this is independent of the phase.

\[\left(\frac{\partial^2 b}{\partial n_i \partial n_j}\right)_{T, P, n_{k\ne i,k}} = 2b - b_i - b_j \]
Returns
d2b_dninjslist[list[float]]

Second Composition derivative of b of each component, [m^3/mol^3]

Notes

This derivative is checked numerically.

property d2b_dzizjs

Helper method for calculating the second partial mole fraction derivatives of b. Note this is independent of the phase.

\[\left(\frac{\partial^2 b}{\partial x_i \partial x_j} \right)_{T, P, n_{k \ne i,j}} = 0 \]
Returns
d2b_dzizjslist[list[float]]

Second mole fraction derivatives of b of each component, [m^3/mol]

Notes

This derivative is checked numerically.

d2lnphi_dninjs(Z)[source]

Calculates the mixture log fugacity coefficient second mole number derivatives (where the mole fraction sum to 1). No specific formula is implemented for this property - it is calculated from the second mole fraction derivative of Gibbs free energy.

\[\left(\frac{\partial^2 \ln \phi }{\partial n_i\partial n_j}\right)_{T, P, n_{i,j\ne k}} f\left( \left(\frac{\partial^2 G_{dep}} {\partial x_j \partial x_i}\right)_{T, P, x_{i,j\ne k}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
d2lnphi_dninjsfloat

Mixture log fugacity coefficient second mole number derivatives, [-]

d2lnphi_dzizjs(Z)[source]

Calculates the mixture log fugacity coefficient second mole fraction derivatives (where the mole fractions do not sum to 1). No specific formula is implemented for this property - it is calculated from the second mole fraction derivative of Gibbs free energy.

\[\left(\frac{\partial^2 \ln \phi }{\partial x_i\partial x_j}\right)_{T, P, x_{i,j\ne k}} = \frac{1}{RT}\left( \left(\frac{\partial^2 G_{dep}} {\partial x_j \partial x_i}\right)_{T, P, x_{i,j\ne k}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
d2lnphi_dzizjsfloat

Mixture log fugacity coefficient second mole fraction derivatives, [-]

property d3a_alpha_dninjnks

Helper method for calculating the third mole number derivatives of a_alpha. Note this is independent of the phase.

\[\left(\frac{\partial^3 a \alpha}{\partial n_i \partial n_j \partial n_k}\right)_{T, P, n_{m\ne i,j,k}} = 4\left(-6 (a \alpha) - [(a \alpha)_{i,j} + (a \alpha)_{i,k} + (a \alpha)_{j,k}] + 3\sum_m z_m[(a \alpha)_{i,m} + (a \alpha)_{j,m} + (a \alpha)_{k,m}]\right) \]
Returns
d3a_alpha_dninjnkslist[float]

Third mole number derivative of alpha of each component, [kg*m^5/(mol^5*s^2)]

Notes

This derivative is checked numerically.

property d3a_alpha_dzizjzks

Helper method for calculating the third composition derivatives of a_alpha. Note this is independent of the phase.

\[\left(\frac{\partial^3 a \alpha}{\partial x_i \partial x_j \partial x_k}\right)_{T, P, x_{m\ne i,j,k}} = 0 \]
Returns
d3a_alpha_dzizjzkslist[float]

Third composition derivative of alpha of each component, [kg*m^5/(mol^2*s^2)]

Notes

This derivative is checked numerically.

property d3b_dninjnks

Helper method for calculating the third partial mole number derivatives of b. Note this is independent of the phase.

\[\left(\frac{\partial^3 b}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = 2(-3b + b_i + b_j + b_k) \]
Returns
d3b_dninjnkslist[list[list[float]]]

Third mole number derivative of b of each component, [m^3/mol^4]

Notes

This derivative is checked numerically.

property d3b_dzizjzks

Helper method for calculating the third partial mole fraction derivatives of b. Note this is independent of the phase.

\[\left(\frac{\partial^3 b}{\partial x_i \partial x_j \partial x_k} \right)_{T, P, n_{k \ne i,j,k}} = 0 \]
Returns
d3b_dzizjzkslist[list[list[float]]]

Third mole fraction derivatives of b of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property d3delta_dzizjzks

Helper method for calculating the third composition derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial^3 \delta}{\partial x_i \partial x_j \partial x_k }\right)_{T, P, x_{m\ne i,j,k}} = 0 \]
Returns
d3delta_dzizjzkslist[list[list[float]]]

Third composition derivative of epsilon of each component, [m^6/mol^5]

Notes

This derivative is checked numerically.

property d3epsilon_dzizjzks

Helper method for calculating the third composition derivatives of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^3 \epsilon}{\partial x_i \partial x_j \partial x_k }\right)_{T, P, x_{m\ne i,j,k}} = 0 \]
Returns
d2epsilon_dzizjzkslist[list[list[float]]]

Composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

dG_dep_dns(Z)[source]

Calculates the molar departure Gibbs energy mole number derivatives (where the mole fractions sum to 1). No specific formula is implemented for this property - it is calculated from the mole fraction derivative.

\[\left(\frac{\partial G_{dep}}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial G_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]

Apart from the ideal term, this is the formulation for chemical potential.

Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dG_dep_dnsfloat

Departure Gibbs energy mole number derivatives, [J/mol^2]

dG_dep_dzs(Z)[source]

Calculates the molar departure Gibbs energy composition derivative (where the mole fractions do not sum to 1). Verified numerically. Useful in solving for gibbs minimization calculations or for solving for the true critical point. Also forms the basis for the molar departure Gibbs energy mole number derivative and molar partial departure Gibbs energy.

\[\left(\frac{\partial G_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} = P \frac{d}{d x} V{\left(x \right)} - \frac{R T \left(\frac{d}{d x} V{\left(x \right)} - \frac{d}{d x} b{\left(x \right)}\right)}{ V{\left(x \right)} - b{\left(x \right)}} - \frac{2 \left(- \delta{ \left(x \right)} \frac{d}{d x} \delta{\left(x \right)} + 2 \frac{d} {d x} \epsilon{\left(x \right)}\right) \operatorname{a \alpha}{ \left(x \right)} \operatorname{atanh}{\left(\frac{2 V{\left(x \right)}}{\sqrt{\delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}} + \frac{\delta{\left(x \right)}}{\sqrt{\delta^{2}{\left( x \right)} - 4 \epsilon{\left(x \right)}}} \right)}}{\left( \delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}\right)^{ \frac{3}{2}}} - \frac{2 \operatorname{atanh}{\left(\frac{2 V{\left( x \right)}}{\sqrt{\delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}} + \frac{\delta{\left(x \right)}}{\sqrt{\delta^{2}{\left( x \right)} - 4 \epsilon{\left(x \right)}}} \right)} \frac{d}{d x} \operatorname{a \alpha}{\left(x \right)}}{\sqrt{\delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}} - \frac{2 \left(\frac{2 \left(- \delta{\left(x \right)} \frac{d}{d x} \delta{\left(x \right)} + 2 \frac{d}{d x} \epsilon{\left(x \right)}\right) V{\left(x \right)}}{\left(\delta^{2}{\left(x \right)} - 4 \epsilon{ \left(x \right)}\right)^{\frac{3}{2}}} + \frac{\left(- \delta{\left (x \right)} \frac{d}{d x} \delta{\left(x \right)} + 2 \frac{d}{d x} \epsilon{\left(x \right)}\right) \delta{\left(x \right)}}{\left( \delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}\right)^{ \frac{3}{2}}} + \frac{2 \frac{d}{d x} V{\left(x \right)}}{\sqrt{ \delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}} + \frac{\frac{d}{d x} \delta{\left(x \right)}}{\sqrt{\delta^{2}{ \left(x \right)} - 4 \epsilon{\left(x \right)}}}\right) \operatorname{a \alpha}{\left(x \right)}}{\left(1 - \left(\frac{2 V{\left(x \right)}}{\sqrt{\delta^{2}{\left(x \right)} - 4 \epsilon{ \left(x \right)}}} + \frac{\delta{\left(x \right)}}{\sqrt{ \delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}}\right )^{2}\right) \sqrt{\delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dG_dep_dzsfloat

Departure Gibbs free energy composition derivatives, [J/mol]

Notes

The derivation for the derivative is performed as follows using SymPy. The function source code is an optimized variant created with the cse SymPy function, and hand optimized further.

>>> from sympy import * 
>>> P, T, R, x = symbols('P, T, R, x') 
>>> a_alpha, a, delta, epsilon, V, b, da_alpha_dT = symbols('a\ \\alpha, a, delta, epsilon, V, b, da_alpha_dT', cls=Function) 
>>> S_dep = R*log(P*V(x)/(R*T)) + R*log(V(x)-b(x))+2*da_alpha_dT(x)*atanh((2*V(x)+delta(x))/sqrt(delta(x)**2-4*epsilon(x)))/sqrt(delta(x)**2-4*epsilon(x))-R*log(V(x)) 
>>> H_dep = P*V(x) - R*T + 2*atanh((2*V(x)+delta(x))/sqrt(delta(x)**2-4*epsilon(x)))*(da_alpha_dT(x)*T-a_alpha(x))/sqrt(delta(x)**2-4*epsilon(x)) 
>>> G_dep = simplify(H_dep - T*S_dep) 
>>> diff(G_dep, x) 
P*Derivative(V(x), x) - R*T*(Derivative(V(x), x) - Derivative(b(x), x))/(V(x) - b(x)) - 2*(-delta(x)*Derivative(delta(x), x) + 2*Derivative(epsilon(x), x))*a \alpha(x)*atanh(2*V(x)/sqrt(delta(x)**2 - 4*epsilon(x)) + delta(x)/sqrt(delta(x)**2 - 4*epsilon(x)))/(delta(x)**2 - 4*epsilon(x))**(3/2) - 2*atanh(2*V(x)/sqrt(delta(x)**2 - 4*epsilon(x)) + delta(x)/sqrt(delta(x)**2 - 4*epsilon(x)))*Derivative(a \alpha(x), x)/sqrt(delta(x)**2 - 4*epsilon(x)) - 2*(2*(-delta(x)*Derivative(delta(x), x) + 2*Derivative(epsilon(x), x))*V(x)/(delta(x)**2 - 4*epsilon(x))**(3/2) + (-delta(x)*Derivative(delta(x), x) + 2*Derivative(epsilon(x), x))*delta(x)/(delta(x)**2 - 4*epsilon(x))**(3/2) + 2*Derivative(V(x), x)/sqrt(delta(x)**2 - 4*epsilon(x)) + Derivative(delta(x), x)/sqrt(delta(x)**2 - 4*epsilon(x)))*a \alpha(x)/((1 - (2*V(x)/sqrt(delta(x)**2 - 4*epsilon(x)) + delta(x)/sqrt(delta(x)**2 - 4*epsilon(x)))**2)*sqrt(delta(x)**2 - 4*epsilon(x)))
dH_dep_dns(Z)[source]

Calculates the molar departure enthalpy mole number derivatives (where the mole fractions sum to 1). No specific formula is implemented for this property - it is calculated from the mole fraction derivative.

\[\left(\frac{\partial H_{dep}}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial H_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dH_dep_dnsfloat

Departure enthalpy mole number derivatives, [J/mol^2]

dH_dep_dzs(Z)[source]

Calculates the molar departure enthalpy composition derivative (where the mole fractions do not sum to 1). Verified numerically. Useful in solving for enthalpy specifications in newton-type methods, and forms the basis for the molar departure enthalpy mole number derivative and molar partial departure enthalpy.

\[\left(\frac{\partial H_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} = P \frac{d}{d x} V{\left(x \right)} + \frac{2 \left(T \frac{\partial}{\partial T} \operatorname{a \alpha}{\left(T,x \right)} - \operatorname{a \alpha}{\left(x \right)}\right) \left(- \delta{\left(x \right)} \frac{d}{d x} \delta{\left(x \right)} + 2 \frac{d}{d x} \epsilon{\left(x \right)}\right) \operatorname{atanh} {\left(\frac{2 V{\left(x \right)} + \delta{\left(x \right)}}{\sqrt{\delta^{2} {\left(x \right)} - 4 \epsilon{\left(x \right)}}} \right)}}{\left(\delta^{2} {\left(x \right)} - 4 \epsilon{\left(x \right)}\right)^{\frac{3}{2}}} + \frac{2 \left(T \frac{\partial}{\partial T} \operatorname{a \alpha} {\left(T,x \right)} - \operatorname{a \alpha}{\left(x \right)}\right) \left(\frac{\left(- \delta{\left(x \right)} \frac{d}{d x} \delta{\left(x \right)} + 2 \frac{d}{d x} \epsilon{\left(x \right)}\right) \left(2 V{\left(x \right)} + \delta{\left(x \right)}\right)}{\left(\delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}\right)^{\frac{3}{2}}} + \frac{2 \frac{d}{d x} V{\left(x \right)} + \frac{d}{d x} \delta{\left(x \right)}} {\sqrt{\delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}}\right)}{\left( - \frac{\left(2 V{\left(x \right)} + \delta{\left(x \right)}\right)^{2}}{ \delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}} + 1\right) \sqrt{ \delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}} + \frac{2 \left(T \frac{\partial^{2}}{\partial x\partial T} \operatorname{a \alpha} {\left(T,x \right)} - \frac{d}{d x} \operatorname{a \alpha}{\left(x \right)} \right) \operatorname{atanh}{\left(\frac{2 V{\left(x \right)} + \delta{\left(x \right)}}{\sqrt{\delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}} \right)}}{\sqrt{\delta^{2}{\left(x \right)} - 4 \epsilon{\left(x \right)}}} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dH_dep_dzsfloat

Departure enthalpy composition derivatives, [J/mol]

Notes

The derivation for the derivative is performed as follows using SymPy. The function source code is an optimized variant created with the cse SymPy function, and hand optimized further.

>>> from sympy import * 
>>> P, T, V, R, b, a, delta, epsilon, x = symbols('P, T, V, R, b, a, delta, epsilon, x') 
>>> V, delta, epsilon, a_alpha, b = symbols('V, delta, epsilon, a_alpha, b', cls=Function) 
>>> H_dep = (P*V(x) - R*T + 2/sqrt(delta(x)**2 - 4*epsilon(x))*(T*Derivative(a_alpha(T, x), T) 
... - a_alpha(x))*atanh((2*V(x)+delta(x))/sqrt(delta(x)**2-4*epsilon(x))))
>>> diff(H_dep, x) 
P*Derivative(V(x), x) + 2*(T*Derivative(a \alpha(T, x), T) - a \alpha(x))*(-delta(x)*Derivative(delta(x), x) + 2*Derivative(epsilon(x), x))*atanh((2*V(x) + delta(x))/sqrt(delta(x)**2 - 4*epsilon(x)))/(delta(x)**2 - 4*epsilon(x))**(3/2) + 2*(T*Derivative(a \alpha(T, x), T) - a \alpha(x))*((-delta(x)*Derivative(delta(x), x) + 2*Derivative(epsilon(x), x))*(2*V(x) + delta(x))/(delta(x)**2 - 4*epsilon(x))**(3/2) + (2*Derivative(V(x), x) + Derivative(delta(x), x))/sqrt(delta(x)**2 - 4*epsilon(x)))/((-(2*V(x) + delta(x))**2/(delta(x)**2 - 4*epsilon(x)) + 1)*sqrt(delta(x)**2 - 4*epsilon(x))) + 2*(T*Derivative(a \alpha(T, x), T, x) - Derivative(a \alpha(x), x))*atanh((2*V(x) + delta(x))/sqrt(delta(x)**2 - 4*epsilon(x)))/sqrt(delta(x)**2 - 4*epsilon(x))
dS_dep_dns(Z)[source]

Calculates the molar departure entropy mole number derivatives (where the mole fractions sum to 1). No specific formula is implemented for this property - it is calculated from the mole fraction derivative.

\[\left(\frac{\partial S_{dep}}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial S_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dS_dep_dnsfloat

Departure entropy mole number derivatives, [J/mol^2/K]

dS_dep_dzs(Z)[source]

Calculates the molar departure entropy composition derivative (where the mole fractions do not sum to 1). Verified numerically. Useful in solving for entropy specifications in newton-type methods, and forms the basis for the molar departure entropy mole number derivative and molar partial departure entropy.

\[\left(\frac{\partial S_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} = \frac{1}{T}\left( \left(\frac{\partial H_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} - \left(\frac{\partial G_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dS_dep_dzsfloat

Departure entropy composition derivatives, [J/mol/K]

dV_dns(Z)[source]

Calculates the molar volume mole number derivatives (where the mole fractions sum to 1). No specific formula is implemented for this property - it is calculated from the mole fraction derivative.

\[\left(\frac{\partial V}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial V}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dV_dnsfloat

Molar volume mole number derivatives, [m^3/mol^2]

dV_dzs(Z)[source]

Calculates the molar volume composition derivative (where the mole fractions do not sum to 1). Verified numerically. Used in many other derivatives, and for the molar volume mole number derivative and partial molar volume calculation.

\[\left(\frac{\partial V}{\partial x_i}\right)_{T, P, x_{i\ne j}} = \frac{- R T \left(V^{2}{\left(x \right)} + V{\left(x \right)} \delta{\left(x \right)} + \epsilon{\left(x \right)}\right)^{3} \frac{d}{d x} b{\left(x \right)} + \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} \left(V^{2}{\left(x \right)} + V{\left(x \right)} \delta{\left(x \right)} + \epsilon{\left(x \right)}\right)^{2} \frac{d}{d x} \operatorname{a \alpha}{\left(x \right)} - \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} V^{3}{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} \frac{d}{d x} \delta{\left(x \right)} - \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} V^{2}{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} \delta{\left(x \right)} \frac{d}{d x} \delta{\left(x \right)} - \left(V{\left(x \right)} - b{\left(x \right)} \right)^{2} V^{2}{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} \frac{d}{d x} \epsilon{ \left(x \right)} - \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} V{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} \delta{\left(x \right)} \frac{d}{d x} \epsilon{\left(x \right)} - \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} V{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} \epsilon{\left(x \right)} \frac{d}{d x} \delta{\left(x \right)} - \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} \operatorname{a \alpha}{\left(x \right)} \epsilon{\left(x \right)} \frac{d}{d x} \epsilon{\left(x \right)}}{- R T \left(V^{2}{\left(x \right)} + V{\left(x \right)} \delta{\left(x \right)} + \epsilon{\left(x \right)}\right)^{3} + 2 \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} V^{3}{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} + 3 \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} V^{2}{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} \delta{\left(x \right)} + \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} V{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} \delta^{2}{\left(x \right)} + 2 \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} V{\left(x \right)} \operatorname{a \alpha}{\left(x \right)} \epsilon{\left(x \right)} + \left(V{\left(x \right)} - b{\left(x \right)}\right)^{2} \operatorname{a \alpha}{\left(x \right)} \delta{\left(x \right)} \epsilon{\left(x \right)}} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dV_dzsfloat

Molar volume composition derivatives, [m^3/mol]

Notes

The derivation for the derivative is performed as follows using SymPy. The function source code is an optimized variant created with the cse SymPy function, and hand optimized further.

>>> from sympy import * 
>>> P, T, R, x = symbols('P, T, R, x') 
>>> V, delta, epsilon, a_alpha, b = symbols('V, delta, epsilon, a\ \\alpha, b', cls=Function) 
>>> CUBIC = R*T/(V(x) - b(x)) - a_alpha(x)/(V(x)*V(x) + delta(x)*V(x) + epsilon(x)) - P 
>>> solve(diff(CUBIC, x), Derivative(V(x), x)) 
[(-R*T*(V(x)**2 + V(x)*delta(x) + epsilon(x))**3*Derivative(b(x), x) + (V(x) - b(x))**2*(V(x)**2 + V(x)*delta(x) + epsilon(x))**2*Derivative(a \alpha(x), x) - (V(x) - b(x))**2*V(x)**3*a \alpha(x)*Derivative(delta(x), x) - (V(x) - b(x))**2*V(x)**2*a \alpha(x)*delta(x)*Derivative(delta(x), x) - (V(x) - b(x))**2*V(x)**2*a \alpha(x)*Derivative(epsilon(x), x) - (V(x) - b(x))**2*V(x)*a \alpha(x)*delta(x)*Derivative(epsilon(x), x) - (V(x) - b(x))**2*V(x)*a \alpha(x)*epsilon(x)*Derivative(delta(x), x) - (V(x) - b(x))**2*a \alpha(x)*epsilon(x)*Derivative(epsilon(x), x))/(-R*T*(V(x)**2 + V(x)*delta(x) + epsilon(x))**3 + 2*(V(x) - b(x))**2*V(x)**3*a \alpha(x) + 3*(V(x) - b(x))**2*V(x)**2*a \alpha(x)*delta(x) + (V(x) - b(x))**2*V(x)*a \alpha(x)*delta(x)**2 + 2*(V(x) - b(x))**2*V(x)*a \alpha(x)*epsilon(x) + (V(x) - b(x))**2*a \alpha(x)*delta(x)*epsilon(x))]
dZ_dns(Z)[source]

Calculates the compressibility mole number derivatives (where the mole fractions sum to 1). No specific formula is implemented for this property - it is calculated from the mole fraction derivative.

\[\left(\frac{\partial Z}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial Z}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dZ_dnsfloat

Compressibility number derivatives, [1/mol]

dZ_dzs(Z)[source]

Calculates the compressibility composition derivatives (where the mole fractions do not sum to 1). No specific formula is implemented for this property - it is calculated from the composition derivative of molar volume, which does have its formula implemented.

\[\left(\frac{\partial Z}{\partial x_i}\right)_{T, P, x_{i\ne j}} = \frac{P }{RT} \left(\frac{\partial V}{\partial x_i}\right)_{T, P, x_{i\ne j}} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dZ_dzsfloat

Compressibility composition derivative, [-]

property da_alpha_dT_dns

Helper method for calculating the mole number derivatives of da_alpha_dT. Note this is independent of the phase.

\[\left(\frac{\partial^2 a \alpha}{\partial n_i \partial T} \right)_{P, n_{i\ne j}} = 2 \left[\sum_j -z_{j} (k_{ij} - 1) (a \alpha)_i (a \alpha)_j \frac{\partial (a \alpha)_i}{\partial T} \frac{\partial (a \alpha)_j}{\partial T} \left({ (a \alpha)_i (a \alpha)_j}\right)^{-0.5} - \frac{\partial a \alpha}{\partial T} \right] \]
Returns
da_alpha_dT_dnslist[float]

Composition derivative of da_alpha_dT of each component, [kg*m^5/(mol^3*s^2*K)]

Notes

This derivative is checked numerically.

property da_alpha_dT_dzs

Helper method for calculating the composition derivatives of da_alpha_dT. Note this is independent of the phase.

\[\left(\frac{\partial^2 a \alpha}{\partial x_i \partial T} \right)_{P, x_{i\ne j}} = 2 \sum_j -z_{j} (k_{ij} - 1) (a \alpha)_i (a \alpha)_j \frac{\partial (a \alpha)_i}{\partial T} \frac{\partial (a \alpha)_j}{\partial T} \left({ (a \alpha)_i (a \alpha)_j}\right)^{-0.5} \]
Returns
da_alpha_dT_dzslist[float]

Composition derivative of da_alpha_dT of each component, [kg*m^5/(mol^2*s^2*K)]

Notes

This derivative is checked numerically.

property da_alpha_dT_ijs

Calculate and return the matrix for the temperature derivatives of the alpha terms.

\[\frac{\partial (a\alpha)_{ij}}{\partial T} = \frac{\sqrt{\operatorname{a\alpha_{i}}{\left(T \right)} \operatorname{a\alpha_{j}} {\left(T \right)}} \left(1 - k_{ij}\right) \left(\frac{\operatorname{a\alpha_{i}} {\left(T \right)} \frac{d}{d T} \operatorname{a\alpha_{j}}{\left(T \right)}}{2} + \frac{\operatorname{a\alpha_{j}}{\left(T \right)} \frac{d}{d T} \operatorname{ a\alpha_{i}}{\left(T \right)}}{2}\right)}{\operatorname{a\alpha_{i}}{\left(T \right)} \operatorname{a\alpha_{j}}{\left(T \right)}} \]
Returns
da_alpha_dT_ijslist[list[float]]

First temperature derivative of a_alpha terms for each component with every other component, [J^2/mol^2/Pa/K]

Notes

In an earlier implementation this matrix was stored each EOS solve; however, allocating that much memory becomes quite expensive for large number of component cases and this is now calculated on-demand only.

property da_alpha_dns

Helper method for calculating the mole number derivatives of a_alpha. Note this is independent of the phase.

\[\left(\frac{\partial a \alpha}{\partial n_i}\right)_{T, P, n_{i\ne j}} = 2 (-a\alpha + \sum_j z_{j} (1 - k_{ij}) \sqrt{ (a \alpha)_i (a \alpha)_j}) \]
Returns
da_alpha_dnslist[float]

Mole number derivative of alpha of each component, [kg*m^5/(mol^3*s^2)]

Notes

This derivative is checked numerically.

property da_alpha_dzs

Helper method for calculating the composition derivatives of a_alpha. Note this is independent of the phase.

\[\left(\frac{\partial a \alpha}{\partial x_i}\right)_{T, P, x_{i\ne j}} = 2 \cdot \sum_j z_{j} (1 - k_{ij}) \sqrt{ (a \alpha)_i (a \alpha)_j} \]
Returns
da_alpha_dzslist[float]

Composition derivative of alpha of each component, [kg*m^5/(mol^2*s^2)]

Notes

This derivative is checked numerically.

property db_dns

Helper method for calculating the mole number derivatives of b. Note this is independent of the phase.

\[\left(\frac{\partial b}{\partial n_i}\right)_{T, P, n_{i\ne j}} = b_i - b \]
Returns
db_dnslist[float]

Composition derivative of b of each component, [m^3/mol^2]

Notes

This derivative is checked numerically.

property db_dzs

Helper method for calculating the composition derivatives of b. Note this is independent of the phase.

\[\left(\frac{\partial b}{\partial x_i}\right)_{T, P, x_{i\ne j}} = b_i \]
Returns
db_dzslist[float]

Composition derivative of b of each component, [m^3/mol]

Notes

This derivative is checked numerically.

dfugacities_dns(phase)[source]

Generic formula for calculating the mole number derivaitves of fugacities for each species in a mixture. Verified numerically. Applicable to all cubic equations of state which can be cast in the form used here.

\[\left(\frac{\partial f_i}{\partial n_i}\right)_{P, n_{j \ne i}} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dfugacities_dnslist[list[float]]

Mole number derivatives of fugacities for each species, [-]

dlnfugacities_dns(phase)[source]

Generic formula for calculating the mole number derivaitves of log fugacities for each species in a mixture. Verified numerically. Applicable to all cubic equations of state which can be cast in the form used here.

\[\left(\frac{\partial \ln f_i}{\partial n_i}\right)_{P, n_{j \ne i}} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnfugacities_dnslist[list[float]]

Mole number derivatives of log fugacities for each species, [-]

dlnphi_dns(Z)[source]

Calculates the mixture log fugacity coefficient mole number derivatives (where the mole fractions sum to 1). No specific formula is implemented for this property - it is calculated from the mole fraction derivative of Gibbs free energy.

\[\left(\frac{\partial \ln \phi }{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial G_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]

This property can be converted into a partial molar property to obtain the individual fugacity coefficients.

Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dlnphi_dnsfloat

Mixture log fugacity coefficient mole number derivatives, [1/mol]

dlnphi_dzs(Z)[source]

Calculates the mixture log fugacity coefficient mole fraction derivatives (where the mole fractions do not sum to 1). No specific formula is implemented for this property - it is calculated from the mole fraction derivative of Gibbs free energy.

\[\left(\frac{\partial \ln \phi }{\partial x_i}\right)_{T, P, x_{i\ne j}} = \frac{1}{RT}\left( \left(\frac{\partial G_{dep}} {\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dlnphi_dzsfloat

Mixture log fugacity coefficient mole fraction derivatives, [-]

dlnphis_dP(phase)[source]

Generic formula for calculating the pressure derivaitve of log fugacity coefficients for each species in a mixture. Verified numerically. Applicable to all cubic equations of state which can be cast in the form used here.

Normally this routine is slower than EOS-specific ones, as it does not make assumptions that certain parameters are zero or equal to other parameters.

\[\left(\frac{\partial \ln \phi_i}{\partial P}\right)_{T, nj \ne i} = \frac{G_{dep}}{\partial P}_{T, n} + \left(\frac{\partial^2 \ln \phi}{\partial P \partial n_i} \right)_{T, P, n_{j \ne i}} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnphis_dPfloat

Pressure derivatives of log fugacity coefficient for each species, [1/Pa]

Notes

This expression for the partial derivative of the mixture lnphi with respect to pressure and mole number can be derived as follows; to convert to the partial molar lnphi pressure and temperature derivative, add ::math::frac{G_{dep}/(RT)}{partial P}_{T, n}.

>>> from sympy import * 
>>> P, T, R, n = symbols('P, T, R, n') 
>>> a_alpha, a, delta, epsilon, V, b, da_alpha_dT, d2a_alpha_dT2 = symbols('a_alpha, a, delta, epsilon, V, b, da_alpha_dT, d2a_alpha_dT2', cls=Function) 
>>> S_dep = R*log(P*V(n, P)/(R*T)) + R*log(V(n, P)-b(n))+2*da_alpha_dT(n, T)*atanh((2*V(n, P)+delta(n))/sqrt(delta(n)**2-4*epsilon(n)))/sqrt(delta(n)**2-4*epsilon(n))-R*log(V(n, P)) 
>>> H_dep = P*V(n, P) - R*T + 2*atanh((2*V(n, P)+delta(n))/sqrt(delta(n)**2-4*epsilon(n)))*(da_alpha_dT(n, T)*T-a_alpha(n, T))/sqrt(delta(n)**2-4*epsilon(n)) 
>>> G_dep = H_dep - T*S_dep 
>>> lnphi = simplify(G_dep/(R*T)) 
>>> diff(diff(lnphi, P), n) 
P*Derivative(V(n, P), P, n)/(R*T) + Derivative(V(n, P), P, n)/V(n, P) - Derivative(V(n, P), P)*Derivative(V(n, P), n)/V(n, P)**2 - Derivative(V(n, P), P, n)/(V(n, P) - b(n)) - (-Derivative(V(n, P), n) + Derivative(b(n), n))*Derivative(V(n, P), P)/(V(n, P) - b(n))**2 + Derivative(V(n, P), n)/(R*T) - 4*(-2*delta(n)*Derivative(delta(n), n) + 4*Derivative(epsilon(n), n))*a_alpha(n, T)*Derivative(V(n, P), P)/(R*T*(1 - (2*V(n, P)/sqrt(delta(n)**2 - 4*epsilon(n)) + delta(n)/sqrt(delta(n)**2 - 4*epsilon(n)))**2)*(delta(n)**2 - 4*epsilon(n))**2) - 4*a_alpha(n, T)*Derivative(V(n, P), P, n)/(R*T*(1 - (2*V(n, P)/sqrt(delta(n)**2 - 4*epsilon(n)) + delta(n)/sqrt(delta(n)**2 - 4*epsilon(n)))**2)*(delta(n)**2 - 4*epsilon(n))) - 4*Derivative(V(n, P), P)*Derivative(a_alpha(n, T), n)/(R*T*(1 - (2*V(n, P)/sqrt(delta(n)**2 - 4*epsilon(n)) + delta(n)/sqrt(delta(n)**2 - 4*epsilon(n)))**2)*(delta(n)**2 - 4*epsilon(n))) - 4*(2*V(n, P)/sqrt(delta(n)**2 - 4*epsilon(n)) + delta(n)/sqrt(delta(n)**2 - 4*epsilon(n)))*(4*(-delta(n)*Derivative(delta(n), n) + 2*Derivative(epsilon(n), n))*V(n, P)/(delta(n)**2 - 4*epsilon(n))**(3/2) + 2*(-delta(n)*Derivative(delta(n), n) + 2*Derivative(epsilon(n), n))*delta(n)/(delta(n)**2 - 4*epsilon(n))**(3/2) + 4*Derivative(V(n, P), n)/sqrt(delta(n)**2 - 4*epsilon(n)) + 2*Derivative(delta(n), n)/sqrt(delta(n)**2 - 4*epsilon(n)))*a_alpha(n, T)*Derivative(V(n, P), P)/(R*T*(1 - (2*V(n, P)/sqrt(delta(n)**2 - 4*epsilon(n)) + delta(n)/sqrt(delta(n)**2 - 4*epsilon(n)))**2)**2*(delta(n)**2 - 4*epsilon(n))) + R*T*(P*Derivative(V(n, P), P)/(R*T) + V(n, P)/(R*T))*Derivative(V(n, P), n)/(P*V(n, P)**2) - R*T*(P*Derivative(V(n, P), P, n)/(R*T) + Derivative(V(n, P), n)/(R*T))/(P*V(n, P))
dlnphis_dT(phase)[source]

Generic formula for calculating the temperature derivaitve of log fugacity coefficients for each species in a mixture. Verified numerically. Applicable to all cubic equations of state which can be cast in the form used here.

Normally this routine is slower than EOS-specific ones, as it does not make assumptions that certain parameters are zero or equal to other parameters.

\[\left(\frac{\partial \ln \phi_i}{\partial T}\right)_{P, nj \ne i} = \frac{\frac{G_{dep}}{RT}}{\partial T}_{P, n} + \left(\frac{\partial^2 \ln \phi}{\partial T \partial n_i} \right)_{P, n_{j \ne i}} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnphis_dTfloat

Temperature derivatives of log fugacity coefficient for each species, [1/K]

Notes

This expression for the partial derivative of the mixture lnphi with respect to pressure and mole number can be derived as follows; to convert to the partial molar lnphi pressure and temperature derivative, add ::math::frac{G_{dep}/(RT)}{partial T}_{P, n}.

>>> from sympy import * 
>>> P, T, R, n = symbols('P, T, R, n') 
>>> a_alpha, a, delta, epsilon, V, b, da_alpha_dT, d2a_alpha_dT2 = symbols('a_alpha, a, delta, epsilon, V, b, da_alpha_dT, d2a_alpha_dT2', cls=Function) 
>>> S_dep = R*log(P*V(n, T)/(R*T)) + R*log(V(n, T)-b(n))+2*da_alpha_dT(n, T)*atanh((2*V(n, T)+delta(n))/sqrt(delta(n)**2-4*epsilon(n)))/sqrt(delta(n)**2-4*epsilon(n))-R*log(V(n, T)) 
>>> H_dep = P*V(n, T) - R*T + 2*atanh((2*V(n, T)+delta(n))/sqrt(delta(n)**2-4*epsilon(n)))*(da_alpha_dT(n, T)*T-a_alpha(n, T))/sqrt(delta(n)**2-4*epsilon(n)) 
>>> G_dep = H_dep - T*S_dep 
>>> lnphi = simplify(G_dep/(R*T)) 
>>> diff(diff(lnphi, T), n) 
dlnphis_dns(Z)[source]

Generic formula for calculating the mole number derivaitves of log fugacity coefficients for each species in a mixture. Verified numerically. Applicable to all cubic equations of state which can be cast in the form used here.

\[\left(\frac{\partial \ln \phi_i}{\partial n_i}\right)_{P, n_{j \ne i}} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dlnphis_dnslist[list[float]]

Mole number derivatives of log fugacity coefficient for each species, [-]

dlnphis_dzs(Z)[source]

Generic formula for calculating the mole fraction derivaitves of log fugacity coefficients for each species in a mixture. Verified numerically. Applicable to all cubic equations of state which can be cast in the form used here.

\[\left(\frac{\partial \ln \phi_i}{\partial z_i}\right)_{P, z_{j \ne i}} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dlnphis_dzslist[list[float]]

Mole fraction derivatives of log fugacity coefficient for each species (such that the mole fractions do not sum to 1), [-]

dnG_dep_dns(Z)[source]

Calculates the partial molar departure Gibbs energy. No specific formula is implemented for this property - it is calculated from the mole fraction derivative.

\[\left(\frac{\partial n G_{dep}}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial G_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dnG_dep_dnsfloat

Partial molar departure Gibbs energy of the phase, [J/mol]

dnH_dep_dns(Z)[source]

Calculates the partial molar departure enthalpy. No specific formula is implemented for this property - it is calculated from the mole fraction derivative.

\[\left(\frac{\partial n H_{dep}}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial H_{dep}}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dnH_dep_dnsfloat

Partial molar departure enthalpies of the phase, [J/mol]

dnV_dns(Z)[source]

Calculates the partial molar volume of the specified phase No specific formula is implemented for this property - it is calculated from the molar volume mole fraction derivative.

\[\left(\frac{\partial n V}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial V}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dnV_dnsfloat

Partial molar volume of the mixture of the specified phase, [m^3/mol]

dnZ_dns(Z)[source]

Calculates the partial compressibility of the specified phase No specific formula is implemented for this property - it is calculated from the compressibility mole fraction derivative.

\[\left(\frac{\partial n Z}{\partial n_i}\right)_{T, P, n_{i\ne j}} = f\left( \left(\frac{\partial Z}{\partial x_i}\right)_{T, P, x_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dnZ_dnsfloat

Partial compressibility of the mixture of the specified phase, [-]

property dna_alpha_dT_dns

Helper method for calculating the mole number derivatives of da_alpha_dT. Note this is independent of the phase.

\[\left(\frac{\partial^2 n a \alpha}{\partial n_i \partial T} \right)_{P, n_{i\ne j}} = 2 \left[\sum_j -z_{j} (k_{ij} - 1) (a \alpha)_i (a \alpha)_j \frac{\partial (a \alpha)_i}{\partial T} \frac{\partial (a \alpha)_j}{\partial T} \left({ (a \alpha)_i (a \alpha)_j}\right)^{-0.5} - 0.5 \frac{\partial a \alpha}{\partial T} \right] \]
Returns
dna_alpha_dT_dnslist[float]

Composition derivative of da_alpha_dT of each component, [kg*m^5/(mol^2*s^2*K)]

Notes

This derivative is checked numerically.

property dna_alpha_dns

Helper method for calculating the partial molar derivatives of a_alpha. Note this is independent of the phase.

\[\left(\frac{\partial a \alpha}{\partial n_i}\right)_{T, P, n_{i\ne j}} = 2 (-0.5 a\alpha + \sum_j z_{j} (1 - k_{ij}) \sqrt{ (a \alpha)_i (a \alpha)_j}) \]
Returns
dna_alpha_dnslist[float]

Partial molar derivative of alpha of each component, [kg*m^5/(mol^2*s^2)]

Notes

This derivative is checked numerically.

property dnb_dns

Helper method for calculating the partial molar derivative of b. Note this is independent of the phase.

\[\left(\frac{\partial n \cdot b}{\partial n_i}\right)_{T, P, n_{i\ne j}} = b_i \]
Returns
dnb_dnslist[float]

Partial molar derivative of b of each component, [m^3/mol]

Notes

This derivative is checked numerically.

classmethod from_json(json_repr)[source]

Method to create a mixture cubic equation of state from a JSON friendly serialization of another mixture cubic equation of state.

Parameters
json_reprdict

Json representation, [-]

Returns
eos_mixGCEOSMIX

Newly created object from the json serialization, [-]

Notes

It is important that the input string be in the same format as that created by GCEOS.as_json.

Examples

>>> import pickle
>>> 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 = pickle.dumps(eos.as_json())
>>> new_eos = GCEOSMIX.from_json(pickle.loads(json_stuff))
>>> assert new_eos == eos
fugacities(only_l=False, only_g=False)[source]

Helper method for calculating fugacity coefficients for any phases present, using either the overall mole fractions for both phases or using specified mole fractions for each phase.

Requires fugacity_coefficients to be implemented by each subclassing EOS.

In addition to setting fugacities_l and/or fugacities_g, this also sets the fugacity coefficients phis_l and/or phis_g.

\[\hat \phi_i^g = \frac{\hat f_i^g}{y_i P} \]
\[\hat \phi_i^l = \frac{\hat f_i^l}{x_i P} \]

Note that in a flash calculation, each phase requires their own EOS object.

Parameters
only_lbool

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set.

only_gbool

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set.

Notes

It is helpful to check that fugacity_coefficients has been implemented correctly using the following expression, from [1].

\[\ln \hat \phi_i = \left[\frac{\partial (n\ln \phi)}{\partial n_i}\right]_{T,P,n_j,V_t} \]

For reference, several expressions for fugacity of a component are as follows, shown in [1] and [2].

\[\ln \hat \phi_i = \int_{0}^P\left(\frac{\hat V_i} {RT} - \frac{1}{P}\right)dP \]
\[\ln \hat \phi_i = \int_V^\infty \left[ \frac{1}{RT}\frac{\partial P}{ \partial n_i} - \frac{1}{V}\right] d V - \ln Z \]

References

1(1,2)

Hu, Jiawen, Rong Wang, and Shide Mao. “Some Useful Expressions for Deriving Component Fugacity Coefficients from Mixture Fugacity Coefficient.” Fluid Phase Equilibria 268, no. 1-2 (June 25, 2008): 7-13. doi:10.1016/j.fluid.2008.03.007.

2

Walas, Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.

fugacity_coefficients(Z)[source]

Generic formula for calculating log fugacity coefficients for each species in a mixture. Verified numerically. Applicable to all cubic equations of state which can be cast in the form used here. Normally this routine is slower than EOS-specific ones, as it does not make assumptions that certain parameters are zero or equal to other parameters.

\[\left(\frac{\partial n \ln \phi}{\partial n_i} \right)_{n_{k \ne i}} = \ln \phi _i = \ln \phi + n \left(\frac{\partial \ln \phi}{\partial n_i} \right)_{n_{k\ne i}} \]
\[\left(\frac{\partial \ln \phi }{\partial n_i}\right)_{T, P, n_{i\ne j}} = \frac{1}{RT}\left( \left(\frac{\partial G_{dep}} {\partial n_i}\right)_{T, P, n_{i\ne j}} \right) \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
log_phisfloat

Log fugacity coefficient for each species, [-]

kwargs_linear = ()

Tuple of 1D arguments used by the specific EOS in addition to the conventional ones.

kwargs_square = ('kijs',)

Tuple of 2D arguments used by the specific EOS.

mechanical_critical_point()[source]

Method to calculate the mechanical critical point of a mixture of defined composition.

The mechanical critical point is where:

\[\frac{\partial P}{\partial \rho}|_T = \frac{\partial^2 P}{\partial \rho^2}|_T = 0 \]
Returns
Tfloat

Mechanical critical temperature, [K]

Pfloat

Mechanical critical temperature, [Pa]

Notes

One useful application of the mechanical critical temperature is that the phase identification approach of Venkatarathnam is valid only up to it.

Note that the equation of state, when solved at these conditions, will have fairly large (1e-3 - 1e-6) results for the derivatives; but they are the minimum. This is just from floating point precision.

It can also be checked looking at the calculated molar volumes - all three (available with sorted_volumes) will be very close (1e-5 difference in practice), again differing because of floating point error.

The algorithm here is a custom implementation, using Newton-Raphson’s method with the initial guesses described in [1] (mole-weighted critical pressure average, critical temperature average using a quadratic mixing rule). Normally ~4 iterations are needed to solve the system. It is relatively fast, as only one evaluation of a_alpha and da_alpha_dT are needed per call to function and its jacobian.

References

1

Watson, Harry A. J., and Paul I. Barton. “Reliable Flash Calculations: Part 3. A Nonsmooth Approach to Density Extrapolation and Pseudoproperty Evaluation.” Industrial & Engineering Chemistry Research, November 11, 2017. https://doi.org/10.1021/acs.iecr.7b03233.

2

Mathias P. M., Boston J. F., and Watanasiri S. “Effective Utilization of Equations of State for Thermodynamic Properties in Process Simulation.” AIChE Journal 30, no. 2 (June 17, 2004): 182-86. https://doi.org/10.1002/aic.690300203.

mix_kwargs_to_pure = {}
multicomponent = True

All inherited classes of GCEOSMIX are multicomponent.

nonstate_constants = ('N', 'cmps', 'Tcs', 'Pcs', 'omegas', 'kijs', 'kwargs', 'ais', 'bs')
property pseudo_Pc

Apply a linear mole-fraction mixing rule to compute the average critical pressure, [Pa].

Examples

>>> base = RKMIX(T=150.0, P=4e6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.pseudo_Pc
3878000.0
property pseudo_Tc

Apply a linear mole-fraction mixing rule to compute the average critical temperature, [K].

Examples

>>> base = RKMIX(T=150.0, P=4e6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.pseudo_Tc
151.9
property pseudo_a

Apply a linear mole-fraction mixing rule to compute the average a coefficient, [-].

Examples

>>> base = RKMIX(T=150.0, P=4e6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.pseudo_a
0.17634464184
property pseudo_omega

Apply a linear mole-fraction mixing rule to compute the average omega, [-].

Examples

>>> base = RKMIX(T=150.0, P=4e6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.pseudo_omega
0.0284
pures()[source]

Helper method which returns a list of pure EOSs at the same T and P and base EOS as the mixture.

Returns
eos_pureslist[eos]

A list of pure-species EOSs at the same T and P as the system, [-]

Notes

This is useful for i.e. comparing mixture fugacities with the Lewis-Randall rule or when using an activity coefficient model which require pure component fugacities.

scalar = True

Whether the model is implemented using pure-Python lists of floats, or numpy arrays of float64.

set_dnzs_derivatives_and_departures(n=True, x=True, only_l=False, only_g=False)[source]

Sets a number of mole number and/or composition partial derivatives of thermodynamic partial derivatives.

The list of properties set is as follows, with all properties suffixed with ‘_l’ or ‘_g’

if n is True: d2P_dTdns, d2P_dVdns, d2V_dTdns, d2V_dPdns, d2T_dVdns, d2T_dPdns, d3P_dT2dns, d3P_dV2dns, d3V_dT2dns, d3V_dP2dns, d3T_dV2dns, d3T_dP2dns, d3V_dPdTdns, d3P_dTdVdns, d3T_dPdVdns, dV_dep_dns, dG_dep_dns, dH_dep_dns, dU_dep_dns, dS_dep_dns, dA_dep_dns

if x is True: d2P_dTdzs, d2P_dVdzs, d2V_dTdzs, d2V_dPdzs, d2T_dVdzs, d2T_dPdzs, d3P_dT2dzs, d3P_dV2dzs, d3V_dT2dzs, d3V_dP2dzs, d3T_dV2dzs, d3T_dP2dzs, d3V_dPdTdzs, d3P_dTdVdzs, d3T_dPdVdzs, dV_dep_dzs, dG_dep_dzs, dH_dep_dzs, dU_dep_dzs, dS_dep_dzs, dA_dep_dzs

Parameters
nbool, optional

Whether or not to set the mole number derivatives (sums up to one), [-]

xbool, optional

Whether or not to set the composition derivatives (does not sum up to one), [-]

only_lbool, optional

Whether or not to set only the liquid-like phase properties (if there are two phases), [-]

only_gbool, optional

Whether or not to set only the gas-like phase properties (if there are two phases), [-]

solve_T(P, V, quick=True, solution=None)[source]

Generic method to calculate T from a specified P and V. Provides SciPy’s newton solver, and iterates to solve the general equation for P, recalculating a_alpha as a function of temperature using a_alpha_and_derivatives each iteration.

Parameters
Pfloat

Pressure, [Pa]

Vfloat

Molar volume, [m^3/mol]

quickbool, optional

Unimplemented, although it may be possible to derive explicit expressions as done for many pure-component EOS

solutionstr or None, optional

‘l’ or ‘g’ to specify a liquid of vapor solution (if one exists); if None, will select a solution more likely to be real (closer to STP, attempting to avoid temperatures like 60000 K or 0.0001 K).

Returns
Tfloat

Temperature, [K]

stabiliy_iteration_Michelsen(T, P, zs, Ks_initial=None, maxiter=20, xtol=1e-12, liq=True)[source]
subset(idxs, **state_specs)[source]

Method to construct a new GCEOSMIX that removes all components not specified in the idxs argument.

Parameters
idxslist[int] or Slice

Indexes of components that should be included, [-]

Returns
subset_eosGCEOSMIX

Multicomponent GCEOSMIX at the same specified specs but with a composition normalized to 1 and with fewer components, [-]

state_specsfloat

Keyword arguments which can be any of T, P, V, zs; zs is optional, as are (T, P, V), but if any of (T, P, V) are specified, a second one is required as well, [various]

Notes

Subclassing equations of state require their kwargs_linear and kwargs_square attributes to be correct for this to work. Tcs, Pcs, and omegas are always assumed to be used.

Examples

>>> 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.8193231441048036, 0.1806768558951965], 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)
to(zs=None, T=None, P=None, V=None, fugacities=True)[source]

Method to construct a new GCEOSMIX object at two of T, P or V with the specified composition. In the event the specs match those of the current object, it will be returned unchanged.

Parameters
zslist[float], optional

Mole fractions of EOS, [-]

Tfloat or None, optional

Temperature, [K]

Pfloat or None, optional

Pressure, [Pa]

Vfloat or None, optional

Molar volume, [m^3/mol]

fugacitiesbool

Whether or not to calculate fugacities, [-]

Returns
objGCEOSMIX

Pure component GCEOSMIX at the two specified specs, [-]

Notes

Constructs the object with parameters Tcs, Pcs, omegas, and kwargs.

Examples

>>> base = PRMIX(T=500.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.to(T=300.0, P=1e9).state_specs
{'T': 300.0, 'P': 1000000000.0}
>>> base.to(T=300.0, V=1.0).state_specs
{'T': 300.0, 'V': 1.0}
>>> base.to(P=1e5, V=1.0).state_specs
{'P': 100000.0, 'V': 1.0}
to_PV(P, V)[source]

Method to construct a new GCEOSMIX object at the spcified P and V with the current composition. In the event the P and V match the current object’s P and V, it will be returned unchanged.

Parameters
Pfloat

Pressure, [Pa]

Vfloat

Molar volume, [m^3/mol]

Returns
objGCEOSMIX

Pure component GCEOSMIX at specified P and V, [-]

Notes

Constructs the object with parameters Tcs, Pcs, omegas, and kwargs.

Examples

>>> base = RKMIX(T=500.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> new = base.to_PV(P=1000000.0, V=1.0)
>>> base.state_specs, new.state_specs
({'T': 500.0, 'P': 1000000.0}, {'P': 1000000.0, 'V': 1.0})
to_PV_zs(P, V, zs, fugacities=True, only_l=False, only_g=False)[source]

Method to construct a new GCEOSMIX instance at P, V, and zs with the same parameters as the existing object. Optionally, only one set of phase properties can be solved for, increasing speed. The fugacities calculation can be be skipped by by setting fugacities to False.

Parameters
Pfloat

Pressure, [Pa]

Vfloat

Molar volume, [m^3/mol]

zslist[float]

Mole fractions of each component, [-]

fugacitiesbool

Whether or not to calculate and set the fugacities of each component, [-]

only_lbool

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set.

only_gbool

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set.

Returns
eosGCEOSMIX

Multicomponent GCEOSMIX at the specified conditions [-]

Notes

A check for whether or not P, V, and zs are the same as the existing instance is performed; if it is, the existing object is returned.

Examples

>>> base = RKMIX(T=500.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.to_PV_zs(V=0.004162, P=1e5, zs=[.1, 0.9])
RKMIX(Tcs=[126.1, 190.6], Pcs=[3394000.0, 4604000.0], omegas=[0.04, 0.011], kijs=[[0.0, 0.0], [0.0, 0.0]], zs=[0.1, 0.9], P=100000.0, V=0.004162)
to_TP(T, P)[source]

Method to construct a new GCEOSMIX object at the spcified T and P with the current composition. In the event the T and P match the current object’s T and P, it will be returned unchanged.

Parameters
Tfloat

Temperature, [K]

Pfloat

Pressure, [Pa]

Returns
objGCEOSMIX

Pure component GCEOSMIX at specified T and P, [-]

Notes

Constructs the object with parameters Tcs, Pcs, omegas, and kwargs.

Examples

>>> base = RKMIX(T=500.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> new = base.to_TP(T=10.0, P=2000.0)
>>> base.state_specs, new.state_specs
({'T': 500.0, 'P': 1000000.0}, {'T': 10.0, 'P': 2000.0})
to_TPV_pure(i, T=None, P=None, V=None)[source]

Helper method which returns a pure EOSs at the specs (two of T, P and V) and base EOS as the mixture for a particular index.

Parameters
iint

Index of specified compound, [-]

Tfloat or None, optional

Specified temperature, [K]

Pfloat or None, optional

Specified pressure, [Pa]

Vfloat or None, optional

Specified volume, [m^3/mol]

Returns
eos_pureeos

A pure-species EOSs at the two specified T, P, and V for component i, [-]

to_TP_zs(T, P, zs, fugacities=True, only_l=False, only_g=False)[source]

Method to construct a new GCEOSMIX instance at T, P, and zs with the same parameters as the existing object. Optionally, only one set of phase properties can be solved for, increasing speed. The fugacities calculation can be be skipped by by setting fugacities to False.

Parameters
Tfloat

Temperature, [K]

Pfloat

Pressure, [Pa]

zslist[float]

Mole fractions of each component, [-]

fugacitiesbool

Whether or not to calculate and set the fugacities of each component, [-]

only_lbool

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set.

only_gbool

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set.

Returns
eosGCEOSMIX

Multicomponent GCEOSMIX at the specified conditions [-]

Notes

A check for whether or not T, P, and zs are the same as the existing instance is performed; if it is, the existing object is returned.

Examples

>>> base = RKMIX(T=500.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.to_TP_zs(T=300, P=1e5, zs=[.1, 0.9])
RKMIX(Tcs=[126.1, 190.6], Pcs=[3394000.0, 4604000.0], omegas=[0.04, 0.011], kijs=[[0.0, 0.0], [0.0, 0.0]], zs=[0.1, 0.9], T=300, P=100000.0)
to_TP_zs_fast(T, P, zs, only_l=False, only_g=False, full_alphas=True)[source]

Method to construct a new GCEOSMIX instance with the same parameters as the existing object. If both instances are at the same temperature, a_alphas and da_alpha_dTs and d2a_alpha_dT2s are shared between the instances. It is always assumed the new object has a differet composition. Optionally, only one set of phase properties can be solved for, increasing speed. Additionally, if full_alphas is set to False no temperature derivatives of a_alpha will be computed. Those derivatives are not needed in the context of a PT or PVF flash.

Parameters
Tfloat

Temperature, [K]

Pfloat

Pressure, [Pa]

zslist[float]

Mole fractions of each component, [-]

only_lbool

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set.

only_gbool

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set.

Returns
eosGCEOSMIX

Multicomponent GCEOSMIX at the specified conditions [-]

Examples

>>> base = RKMIX(T=500.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.to_TP_zs_fast(T=300, P=1e5, zs=base.zs)
RKMIX(Tcs=[126.1, 190.6], Pcs=[3394000.0, 4604000.0], omegas=[0.04, 0.011], kijs=[[0.0, 0.0], [0.0, 0.0]], zs=[0.6, 0.4], T=300, P=100000.0)
to_TV(T, V)[source]

Method to construct a new GCEOSMIX object at the spcified T and V with the current composition. In the event the T and V match the current object’s T and V, it will be returned unchanged.

Parameters
Tfloat

Temperature, [K]

Vfloat

Molar volume, [m^3/mol]

Returns
objGCEOSMIX

Pure component GCEOSMIX at specified T and V, [-]

Notes

Constructs the object with parameters Tcs, Pcs, omegas, and kwargs.

Examples

>>> base = RKMIX(T=500.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> new = base.to_TV(T=1000000.0, V=1.0)
>>> base.state_specs, new.state_specs
({'T': 500.0, 'P': 1000000.0}, {'T': 1000000.0, 'V': 1.0})
to_mechanical_critical_point()[source]

Method to construct a new GCEOSMIX object at the current object’s properties and composition, but which is at the mechanical critical point.

Returns
objGCEOSMIX

Pure component GCEOSMIX at mechanical critical point [-]

Examples

>>> base = RKMIX(T=500.0, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.6, 0.4])
>>> base.to_mechanical_critical_point()
RKMIX(Tcs=[126.1, 190.6], Pcs=[3394000.0, 4604000.0], omegas=[0.04, 0.011], kijs=[[0.0, 0.0], [0.0, 0.0]], zs=[0.6, 0.4], T=151.861, P=3908737.9)
translated = False

Whether or not the model implements volume translation.

Peng-Robinson Family EOSs

Standard Peng Robinson

class thermo.eos_mix.PRMIX(Tcs, Pcs, omegas, zs, kijs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.GCEOSMIX, thermo.eos.PR

Class for solving the Peng-Robinson [1] [2] cubic equation of state for a mixture of any number of compounds. Subclasses PR. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{v-b}-\frac{a\alpha(T)}{v(v+b)+b(v-b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i=0.45724\frac{R^2T_{c,i}^2}{P_{c,i}} \]
\[b_i=0.07780\frac{RT_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i=[1+\kappa_i(1-\sqrt{T_{r,i}})]^2 \]
\[\kappa_i=0.37464+1.54226\omega_i-0.26992\omega^2_i \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1

Peng, Ding-Yu, and Donald B. Robinson. “A New Two-Constant Equation of State.” Industrial & Engineering Chemistry Fundamentals 15, no. 1 (February 1, 1976): 59-64. doi:10.1021/i160057a011.

2

Robinson, Donald B., Ding-Yu Peng, and Samuel Y-K Chung. “The Development of the Peng - Robinson Equation and Its Application to Phase Equilibrium in a System Containing Methanol.” Fluid Phase Equilibria 24, no. 1 (January 1, 1985): 25-41. doi:10.1016/0378-3812(85)87035-7.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = 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],[0,0]])
>>> eos.V_l, eos.V_g
(3.6257362939e-05, 0.00070066592313)
>>> eos.fugacities_l, eos.fugacities_g
([793860.83821, 73468.552253], [436530.92470, 358114.63827])
Attributes
d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta.

d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta.

d2epsilon_dninjs

Helper method for calculating the second mole number derivatives (hessian) of epsilon.

d2epsilon_dzizjs

Helper method for calculating the second composition derivatives (hessian) of epsilon.

d3a_alpha_dT3

Method to calculate approximately the third temperature derivative of a_alpha for the PR EOS.

d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta.

d3epsilon_dninjnks

Helper method for calculating the third partial mole number derivatives of epsilon.

ddelta_dns

Helper method for calculating the mole number derivatives of delta.

ddelta_dzs

Helper method for calculating the composition derivatives of delta.

depsilon_dns

Helper method for calculating the mole number derivatives of epsilon.

depsilon_dzs

Helper method for calculating the composition derivatives of epsilon.

Methods

a_alpha_and_derivatives_vectorized(T)

Method to calculate the pure-component a_alphas and their first and second derivatives for the PR EOS.

a_alphas_vectorized(T)

Method to calculate the pure-component a_alphas for the PR EOS.

d3a_alpha_dT3_vectorized(T)

Method to calculate the third temperature derivative of pure-component a_alphas for the PR EOS.

dlnphis_dP(phase)

Generic formula for calculating the pressure derivaitve of log fugacity coefficients for each species in a mixture for the Peng-Robinson EOS.

dlnphis_dT(phase)

Formula for calculating the temperature derivaitve of log fugacity coefficients for each species in a mixture for the Peng-Robinson equation of state.

dlnphis_dzs(Z)

Calculate and return the mole fraction derivaitves of log fugacity coefficients for each species in a mixture.

eos_pure

alias of thermo.eos.PR

fugacity_coefficients(Z)

Literature formula for calculating fugacity coefficients for each species in a mixture.

a_alpha_and_derivatives_vectorized(T)[source]

Method to calculate the pure-component a_alphas and their first and second derivatives for the PR EOS. This vectorized implementation is added for extra speed.

\[a\alpha = a \left(\kappa \left(- \frac{T^{0.5}}{Tc^{0.5}} + 1\right) + 1\right)^{2} \]
\[\frac{d a\alpha}{dT} = - \frac{1.0 a \kappa}{T^{0.5} Tc^{0.5}} \left(\kappa \left(- \frac{T^{0.5}}{Tc^{0.5}} + 1\right) + 1\right) \]
\[\frac{d^2 a\alpha}{dT^2} = 0.5 a \kappa \left(- \frac{1}{T^{1.5} Tc^{0.5}} \left(\kappa \left(\frac{T^{0.5}}{Tc^{0.5}} - 1\right) - 1\right) + \frac{\kappa}{T^{1.0} Tc^{1.0}}\right) \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

da_alpha_dTslist[float]

Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2slist[float]

Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]

a_alphas_vectorized(T)[source]

Method to calculate the pure-component a_alphas for the PR EOS. This vectorized implementation is added for extra speed.

\[a\alpha = a \left(\kappa \left(- \frac{T^{0.5}}{Tc^{0.5}} + 1\right) + 1\right)^{2} \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

property d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta. Note this is independent of the phase.

\[\left(\frac{\partial^2 \delta}{\partial n_i \partial n_j}\right)_{T, P, n_{k\ne i,j}} = 4b - 2b_i - 2b_j \]
Returns
d2delta_dninjslist[list[float]]

Second mole number derivative of delta of each component, [m^3/mol^3]

Notes

This derivative is checked numerically.

property d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta. Note this is independent of the phase.

\[\left(\frac{\partial^2 \delta}{\partial x_i\partial x_j}\right)_{T, P, x_{k\ne i,j}} = 0 \]
Returns
d2delta_dzizjslist[float]

Second Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property d2epsilon_dninjs

Helper method for calculating the second mole number derivatives (hessian) of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^2 \epsilon}{\partial n_i n_j}\right)_{T, P, n_{k\ne i,j}} = -2b(2b - b_i - b_j) - 2(b - b_i)(b - b_j) \]
Returns
d2epsilon_dninjslist[list[float]]

Second mole number derivative of epsilon of each component, [m^6/mol^4]

Notes

This derivative is checked numerically.

property d2epsilon_dzizjs

Helper method for calculating the second composition derivatives (hessian) of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^2 \epsilon}{\partial x_i \partial x_j}\right)_{T, P, x_{k\ne i,j}} = 2 b_i b_j \]
Returns
d2epsilon_dzizjslist[list[float]]

Second composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

property d3a_alpha_dT3

Method to calculate approximately the third temperature derivative of a_alpha for the PR EOS. A rigorous calculation has not been implemented.

Parameters
Tfloat

Temperature, [K]

Returns
d3a_alpha_dT3float

Third temperature derivative \(a \alpha\), [J^2/mol^2/Pa/K^3]

d3a_alpha_dT3_vectorized(T)[source]

Method to calculate the third temperature derivative of pure-component a_alphas for the PR EOS. This vectorized implementation is added for extra speed.

Parameters
Tfloat

Temperature, [K]

Returns
d3a_alpha_dT3slist[float]

Third temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K^3]

property d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial^3 \delta}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = 4(-3b + b_i + b_j + b_k) \]
Returns
d3delta_dninjnkslist[list[list[float]]]

Third mole number derivative of delta of each component, [m^3/mol^4]

Notes

This derivative is checked numerically.

property d3epsilon_dninjnks

Helper method for calculating the third partial mole number derivatives of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^3 \epsilon}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = 24b^2 - 12b(b_i + b_j + b_k) + 4(b_i b_j + b_i b_k + b_j b_k) \]
Returns
d3epsilon_dninjnkslist[list[list[float]]]

Third mole number derivative of epsilon of each component, [m^6/mol^5]

Notes

This derivative is checked numerically.

property ddelta_dns

Helper method for calculating the mole number derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial \delta}{\partial n_i}\right)_{T, P, n_{i\ne j}} = 2 (b_i - b) \]
Returns
ddelta_dnslist[float]

Mole number derivative of delta of each component, [m^3/mol^2]

Notes

This derivative is checked numerically.

property ddelta_dzs

Helper method for calculating the composition derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial \delta}{\partial x_i}\right)_{T, P, x_{i\ne j}} = 2 b_i \]
Returns
ddelta_dzslist[float]

Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property depsilon_dns

Helper method for calculating the mole number derivatives of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial \epsilon}{\partial n_i}\right)_{T, P, n_{i\ne j}} = 2b(b - b_i) \]
Returns
depsilon_dnslist[float]

Composition derivative of epsilon of each component, [m^6/mol^3]

Notes

This derivative is checked numerically.

property depsilon_dzs

Helper method for calculating the composition derivatives of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial \epsilon}{\partial x_i}\right)_{T, P, x_{i\ne j}} = -2 b_i\cdot b \]
Returns
depsilon_dzslist[float]

Composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

dlnphis_dP(phase)[source]

Generic formula for calculating the pressure derivaitve of log fugacity coefficients for each species in a mixture for the Peng-Robinson EOS. Verified numerically.

\[\left(\frac{\partial \ln \phi_i}{\partial P}\right)_{T, nj \ne i} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnphis_dPfloat

Pressure derivatives of log fugacity coefficient for each species, [1/Pa]

Notes

This expression was derived using SymPy and optimized with the cse technique.

dlnphis_dT(phase)[source]

Formula for calculating the temperature derivaitve of log fugacity coefficients for each species in a mixture for the Peng-Robinson equation of state. Verified numerically.

\[\left(\frac{\partial \ln \phi_i}{\partial T}\right)_{P, nj \ne i} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnphis_dTfloat

Temperature derivatives of log fugacity coefficient for each species, [1/K]

Notes

This expression was derived using SymPy and optimized with the cse technique.

dlnphis_dzs(Z)[source]

Calculate and return the mole fraction derivaitves of log fugacity coefficients for each species in a mixture. This formula is specific to the Peng-Robinson equation of state.

\[\left(\frac{\partial \ln \phi_i}{\partial z_i}\right)_{P, z_{j \ne i}} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
dlnphis_dzslist[list[float]]

Mole fraction derivatives of log fugacity coefficient for each species (such that the mole fractions do not sum to 1), [-]

Notes

This formula is from [1] but is validated to match the generic implementation.

References

1

Chang, Yih-Bor. “Development and Application of an Equation of State Compositional Simulator” 1990. https://repositories.lib.utexas.edu/handle/2152/80585.

Examples

>>> kijs = [[0, 0.00076, 0.00171], [0.00076, 0, 0.00061], [0.00171, 0.00061, 0]]
>>> eos = 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, kijs=kijs)
>>> eos.dlnphis_dzs(eos.Z_l)
[[0.009938069276, 0.0151503498382, 0.018297235797], [-0.038517738793, -0.05958926042, -0.068438990795], [-0.07057106923, -0.10363920720, -0.14116283024]]
eos_pure

alias of thermo.eos.PR

fugacity_coefficients(Z)[source]

Literature formula for calculating fugacity coefficients for each species in a mixture. Verified numerically. Applicable to most derivatives of the Peng-Robinson equation of state as well. Called by fugacities on initialization, or by a solver routine which is performing a flash calculation.

\[\ln \hat \phi_i = \frac{B_i}{B}(Z-1)-\ln(Z-B) + \frac{A}{2\sqrt{2}B} \left[\frac{B_i}{B} - \frac{2}{a\alpha}\sum_i y_i(a\alpha)_{ij}\right] \ln\left[\frac{Z + (1+\sqrt{2})B}{Z-(\sqrt{2}-1)B}\right] \]
\[A = \frac{(a\alpha)P}{R^2 T^2} \]
\[B = \frac{b P}{RT} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
log_phisfloat

Log fugacity coefficient for each species, [-]

Peng Robinson (1978)

class thermo.eos_mix.PR78MIX(Tcs, Pcs, omegas, zs, kijs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.PRMIX

Class for solving the Peng-Robinson cubic equation of state for a mixture of any number of compounds according to the 1978 variant. Subclasses PR. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{v-b}-\frac{a\alpha(T)}{v(v+b)+b(v-b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i=0.45724\frac{R^2T_{c,i}^2}{P_{c,i}} \]
\[b_i=0.07780\frac{RT_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i=[1+\kappa_i(1-\sqrt{T_{r,i}})]^2 \]
\[\kappa_i = 0.37464+1.54226\omega_i-0.26992\omega_i^2 \text{ if } \omega_i \le 0.491 \]
\[\kappa_i = 0.379642 + 1.48503 \omega_i - 0.164423\omega_i^2 + 0.016666 \omega_i^3 \text{ if } \omega_i > 0.491 \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

This variant is recommended over the original.

References

1

Peng, Ding-Yu, and Donald B. Robinson. “A New Two-Constant Equation of State.” Industrial & Engineering Chemistry Fundamentals 15, no. 1 (February 1, 1976): 59-64. doi:10.1021/i160057a011.

2

Robinson, Donald B., Ding-Yu Peng, and Samuel Y-K Chung. “The Development of the Peng - Robinson Equation and Its Application to Phase Equilibrium in a System Containing Methanol.” Fluid Phase Equilibria 24, no. 1 (January 1, 1985): 25-41. doi:10.1016/0378-3812(85)87035-7.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa, with modified acentric factors to show the difference between PRMIX

>>> eos = PR78MIX(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.6, 0.7], zs=[0.5, 0.5], kijs=[[0,0],[0,0]])
>>> eos.V_l, eos.V_g
(3.2396438915e-05, 0.00050433802024)
>>> eos.fugacities_l, eos.fugacities_g
([833048.45119, 6160.9088153], [460717.27767, 279598.90103])

Methods

eos_pure

alias of thermo.eos.PR78

eos_pure

alias of thermo.eos.PR78

Peng Robinson Stryjek-Vera

class thermo.eos_mix.PRSVMIX(Tcs, Pcs, omegas, zs, kijs=None, T=None, P=None, V=None, kappa1s=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.PRMIX, thermo.eos.PRSV

Class for solving the Peng-Robinson-Stryjek-Vera equations of state for a mixture as given in [1]. Subclasses PRMIX and PRSV. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Inherits the method of calculating fugacity coefficients from PRMIX. Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{v-b}-\frac{a\alpha(T)}{v(v+b)+b(v-b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i=0.45724\frac{R^2T_{c,i}^2}{P_{c,i}} \]
\[b_i=0.07780\frac{RT_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i=[1+\kappa_i(1-\sqrt{T_{r,i}})]^2 \]
\[\kappa_i = \kappa_{0,i} + \kappa_{1,i}(1 + T_{r,i}^{0.5})(0.7 - T_{r,i}) \]
\[\kappa_{0,i} = 0.378893 + 1.4897153\omega_i - 0.17131848\omega_i^2 + 0.0196554\omega_i^3 \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

kappa1slist[float], optional

Fit parameter; available in [1] for over 90 compounds, SRKMIXTranslated[-]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

[1] recommends that kappa1 be set to 0 for Tr > 0.7. This is not done by default; the class boolean kappa1_Tr_limit may be set to True and the problem re-solved with that specified if desired. kappa1_Tr_limit is not supported for P-V inputs.

For P-V initializations, a numerical solver is used to find T.

[2] and [3] are two more resources documenting the PRSV EOS. [4] lists kappa values for 69 additional compounds. See also PRSV2MIX. Note that tabulated kappa values should be used with the critical parameters used in their fits. Both [1] and [4] only considered vapor pressure in fitting the parameter.

References

1(1,2,3,4)

Stryjek, R., and J. H. Vera. “PRSV: An Improved Peng-Robinson Equation of State for Pure Compounds and Mixtures.” The Canadian Journal of Chemical Engineering 64, no. 2 (April 1, 1986): 323-33. doi:10.1002/cjce.5450640224.

2

Stryjek, R., and J. H. Vera. “PRSV - An Improved Peng-Robinson Equation of State with New Mixing Rules for Strongly Nonideal Mixtures.” The Canadian Journal of Chemical Engineering 64, no. 2 (April 1, 1986): 334-40. doi:10.1002/cjce.5450640225.

3

Stryjek, R., and J. H. Vera. “Vapor-liquid Equilibrium of Hydrochloric Acid Solutions with the PRSV Equation of State.” Fluid Phase Equilibria 25, no. 3 (January 1, 1986): 279-90. doi:10.1016/0378-3812(86)80004-8.

4(1,2)

Proust, P., and J. H. Vera. “PRSV: The Stryjek-Vera Modification of the Peng-Robinson Equation of State. Parameters for Other Pure Compounds of Industrial Interest.” The Canadian Journal of Chemical Engineering 67, no. 1 (February 1, 1989): 170-73. doi:10.1002/cjce.5450670125.

Examples

P-T initialization, two-phase, nitrogen and methane

>>> eos = PRSVMIX(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],[0,0]])
>>> eos.phase, eos.V_l, eos.H_dep_l, eos.S_dep_l
('l/g', 3.6235536165e-05, -6349.0055583, -49.1240502472)

Methods

a_alpha_and_derivatives_vectorized(T)

Method to calculate the pure-component a_alphas and their first and second derivatives for the PRSV EOS.

a_alphas_vectorized(T)

Method to calculate the pure-component a_alphas for the PRSV EOS.

eos_pure

alias of thermo.eos.PRSV

a_alpha_and_derivatives_vectorized(T)[source]

Method to calculate the pure-component a_alphas and their first and second derivatives for the PRSV EOS. This vectorized implementation is added for extra speed.

\[a\alpha = a \left(\left(\kappa_{0} + \kappa_{1} \left(\sqrt{\frac{ T}{Tc}} + 1\right) \left(- \frac{T}{Tc} + \frac{7}{10}\right) \right) \left(- \sqrt{\frac{T}{Tc}} + 1\right) + 1\right)^{2} \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

da_alpha_dTslist[float]

Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2slist[float]

Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]

a_alphas_vectorized(T)[source]

Method to calculate the pure-component a_alphas for the PRSV EOS. This vectorized implementation is added for extra speed.

\[a\alpha = a \left(\left(\kappa_{0} + \kappa_{1} \left(\sqrt{\frac{ T}{Tc}} + 1\right) \left(- \frac{T}{Tc} + \frac{7}{10}\right) \right) \left(- \sqrt{\frac{T}{Tc}} + 1\right) + 1\right)^{2} \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

eos_pure

alias of thermo.eos.PRSV

Peng Robinson Stryjek-Vera 2

class thermo.eos_mix.PRSV2MIX(Tcs, Pcs, omegas, zs, kijs=None, T=None, P=None, V=None, kappa1s=None, kappa2s=None, kappa3s=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.PRMIX, thermo.eos.PRSV2

Class for solving the Peng-Robinson-Stryjek-Vera 2 equations of state for a Mixture as given in [1]. Subclasses PRMIX and PRSV2 <thermo.eos.PRSV2>. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Inherits the method of calculating fugacity coefficients from PRMIX. Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{v-b}-\frac{a\alpha(T)}{v(v+b)+b(v-b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i=0.45724\frac{R^2T_{c,i}^2}{P_{c,i}} \]
\[b_i=0.07780\frac{RT_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i=[1+\kappa_i(1-\sqrt{T_{r,i}})]^2 \]
\[\kappa_i = \kappa_{0,i} + [\kappa_{1,i} + \kappa_{2,i}(\kappa_{3,i} - T_{r,i})(1-T_{r,i}^{0.5})] (1 + T_{r,i}^{0.5})(0.7 - T_{r,i}) \]
\[\kappa_{0,i} = 0.378893 + 1.4897153\omega_i - 0.17131848\omega_i^2 + 0.0196554\omega_i^3 \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

kappa1slist[float], optional

Fit parameter; available in [1] for over 90 compounds, [-]

kappa2slist[float], optional

Fit parameter; available in [1] for over 90 compounds, [-]

kappa3slist[float], optional

Fit parameter; available in [1] for over 90 compounds, [-]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

Note that tabulated kappa values should be used with the critical parameters used in their fits. [1] considered only vapor pressure in fitting the parameter.

References

1(1,2,3,4,5)

Stryjek, R., and J. H. Vera. “PRSV2: A Cubic Equation of State for Accurate Vapor-liquid Equilibria Calculations.” The Canadian Journal of Chemical Engineering 64, no. 5 (October 1, 1986): 820-26. doi:10.1002/cjce.5450640516.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = PRSV2MIX(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],[0,0]])
>>> eos.V_l, eos.V_g
(3.6235536165e-05, 0.00070024238654)
>>> eos.fugacities_l, eos.fugacities_g
([794057.58318, 72851.22327], [436553.65618, 357878.11066])

Methods

a_alpha_and_derivatives_vectorized(T)

Method to calculate the pure-component a_alphas and their first and second derivatives for the PRSV2 EOS.

a_alphas_vectorized(T)

Method to calculate the pure-component a_alphas for the PRSV2 EOS.

eos_pure

alias of thermo.eos.PRSV2

a_alpha_and_derivatives_vectorized(T)[source]

Method to calculate the pure-component a_alphas and their first and second derivatives for the PRSV2 EOS. This vectorized implementation is added for extra speed.

Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

da_alpha_dTslist[float]

Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2slist[float]

Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]

a_alphas_vectorized(T)[source]

Method to calculate the pure-component a_alphas for the PRSV2 EOS. This vectorized implementation is added for extra speed.

Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

Examples

>>> eos = PRSV2MIX(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],[0,0]])
>>> eos.a_alphas_vectorized(300)
[0.0860568595, 0.20174345803]
eos_pure

alias of thermo.eos.PRSV2

Peng Robinson Twu (1995)

class thermo.eos_mix.TWUPRMIX(Tcs, Pcs, omegas, zs, kijs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_alpha_functions.TwuPR95_a_alpha, thermo.eos_mix.PRMIX

Class for solving the Twu [1] variant of the Peng-Robinson cubic equation of state for a mixture. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{v-b}-\frac{a\alpha(T)}{v(v+b)+b(v-b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i=0.45724\frac{R^2T_{c,i}^2}{P_{c,i}} \]
\[b_i=0.07780\frac{RT_{c,i}}{P_{c,i}} \]
\[\alpha_i = \alpha_i^{(0)} + \omega_i(\alpha_i^{(1)}-\alpha_i^{(0)}) \]
\[\alpha^{(\text{0 or 1})} = T_{r,i}^{N(M-1)}\exp[L(1-T_{r,i}^{NM})] \]

For sub-critical conditions:

L0, M0, N0 = 0.125283, 0.911807, 1.948150;

L1, M1, N1 = 0.511614, 0.784054, 2.812520

For supercritical conditions:

L0, M0, N0 = 0.401219, 4.963070, -0.2;

L1, M1, N1 = 0.024955, 1.248089, -8.

Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T. Claimed to be more accurate than the PR, PR78 and PRSV equations.

References

1

Twu, Chorng H., John E. Coon, and John R. Cunningham. “A New Generalized Alpha Function for a Cubic Equation of State Part 1. Peng-Robinson Equation.” Fluid Phase Equilibria 105, no. 1 (March 15, 1995): 49-59. doi:10.1016/0378-3812(94)02601-V.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = TWUPRMIX(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],[0,0]])
>>> eos.V_l, eos.V_g
(3.624571041e-05, 0.0007004401318)
>>> eos.fugacities_l, eos.fugacities_g
([792155.022163, 73305.88829], [436468.967764, 358049.2495573])

Methods

eos_pure

alias of thermo.eos.TWUPR

eos_pure

alias of thermo.eos.TWUPR

Peng Robinson Translated

class thermo.eos_mix.PRMIXTranslated(Tcs, Pcs, omegas, zs, kijs=None, cs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.PRMIX

Class for solving the Peng-Robinson [1] [2] translated cubic equation of state for a mixture of any number of compounds. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{v + c - b} - \frac{a\alpha(T)}{(v+c)(v + c + b)+b(v + c - b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i=0.45724\frac{R^2T_{c,i}^2}{P_{c,i}} \]
\[b_i=0.07780\frac{RT_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i=[1+\kappa_i(1-\sqrt{T_{r,i}})]^2 \]
\[\kappa_i=0.37464+1.54226\omega_i-0.26992\omega^2_i \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

cslist[float], optional

Volume translation parameters; always zero in the original implementation, [m^3/mol]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1

Peng, Ding-Yu, and Donald B. Robinson. “A New Two-Constant Equation of State.” Industrial & Engineering Chemistry Fundamentals 15, no. 1 (February 1, 1976): 59-64. doi:10.1021/i160057a011.

2

Robinson, Donald B., Ding-Yu Peng, and Samuel Y-K Chung. “The Development of the Peng - Robinson Equation and Its Application to Phase Equilibrium in a System Containing Methanol.” Fluid Phase Equilibria 24, no. 1 (January 1, 1985): 25-41. doi:10.1016/0378-3812(85)87035-7.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = PRMIXTranslated(T=115, P=1E6, cs=[-4.4e-6, -4.35e-6], Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.2, 0.8], kijs=[[0,0.03],[0.03,0]])
>>> eos.V_l, eos.V_g
(3.9079056337e-05, 0.00060231393016)
>>> eos.fugacities_l, eos.fugacities_g
([442838.8615, 108854.48589], [184396.972, 565531.7709])
Attributes
d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta.

d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta.

d2epsilon_dninjs

Helper method for calculating the second mole number derivatives (hessian) of epsilon.

d2epsilon_dzizjs

Helper method for calculating the second composition derivatives (hessian) of epsilon.

d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta.

d3delta_dzizjzks

Helper method for calculating the third composition derivatives of delta.

d3epsilon_dninjnks

Helper method for calculating the third partial mole number derivatives of epsilon.

d3epsilon_dzizjzks

Helper method for calculating the third composition derivatives of epsilon.

ddelta_dns

Helper method for calculating the mole number derivatives of delta.

ddelta_dzs

Helper method for calculating the composition derivatives of delta.

depsilon_dns

Helper method for calculating the mole number derivatives of epsilon.

depsilon_dzs

Helper method for calculating the composition derivatives of epsilon.

Methods

eos_pure

alias of thermo.eos.PRTranslated

property d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial^2 \delta}{\partial n_i \partial n_j}\right)_{T, P, n_{k\ne i,j}} = 2\left(\delta - b^0_i - b^0_j - c_i - c_j \right) \]
Returns
d2delta_dninjslist[list[float]]

Second mole number derivative of delta of each component, [m^3/mol^3]

Notes

This derivative is checked numerically.

property d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta. Note this is independent of the phase.

\[\left(\frac{\partial^2 \delta}{\partial x_i\partial x_j}\right)_{T, P, x_{k\ne i,j}} = 0 \]
Returns
d2delta_dzizjslist[float]

Second Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property d2epsilon_dninjs

Helper method for calculating the second mole number derivatives (hessian) of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^2 \epsilon}{\partial n_i n_j}\right)_{T, P, n_{k\ne i,j}} = -2b^0(2b^0 - b_i^0 - b_j^0) + c(4b^0 - 2b^0_i - 2b^0_j + 2c - c_i - c_j) -2(b^0 - b_i^0)(b^0 - b^0_j) + (c - c_i)(2b^0 - 2b^0_j - c_j + c) + (c - c_j)(2b^0 - 2b^0_i - c_i + c) + (2b^0 + c)(2c-c_i - c_j) \]
Returns
d2epsilon_dninjslist[list[float]]

Second mole number derivative of epsilon of each component, [m^6/mol^4]

Notes

This derivative is checked numerically.

property d2epsilon_dzizjs

Helper method for calculating the second composition derivatives (hessian) of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^2 \epsilon}{\partial x_i \partial x_j}\right)_{T, P, x_{k\ne i,j}} = -2 b^0_i b^0_j + 2b^0_i c_j + 2b^0_j c_i + 2c_i c_j \]
Returns
d2epsilon_dzizjslist[list[float]]

Second composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

property d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial^3 \delta}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = 4\left(b^0_i + b^0_j + b^0_k + c_i + c_j + c_k \right) - 6 \delta \]
Returns
d3delta_dninjnkslist[list[list[float]]]

Third mole number derivative of delta of each component, [m^3/mol^4]

Notes

This derivative is checked numerically.

property d3delta_dzizjzks

Helper method for calculating the third composition derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial^3 \delta}{\partial x_i \partial x_j \partial x_k }\right)_{T, P, x_{m\ne i,j,k}} = 0 \]
Returns
d3delta_dzizjzkslist[list[list[float]]]

Third composition derivative of epsilon of each component, [m^6/mol^5]

Notes

This derivative is checked numerically.

property d3epsilon_dninjnks

Helper method for calculating the third partial mole number derivatives of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^3 \epsilon}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = 4b^0(3b^0 - b_i^0 - b_j^0 - b_k^0) -2c(6b^0 - 2(b_i^0 + b_j^0 + b_k^0) + 3c - (c_i + c_j + c_k)) +2(b^0-b_i^0)(2b^0 - b_j^0 - b_k^0) + 2(b^0 - b^0_j)(2b^0 - b_i^0 - b_k^0) +2(b^0-b^0_k)(2b^0 - b^0_i-b^0_j) -(c-c_i)(4b^0 - 2b^0_j - 2b^0_k + 2c - c_j - c_k) -(c-c_j)(4b^0 - 2b^0_i - 2b^0_k + 2c - c_i - c_k) -(c-c_k)(4b^0 - 2b^0_j - 2b^0_i + 2c - c_j - c_i) -2(c + 2b^0)(3c - c_i - c_j - c_k) -(2c - c_i - c_j)(2b^0 + c - 2b^0_k - c_k) -(2c - c_i - c_k)(2b^0 + c - 2b^0_j - c_j) -(2c - c_j - c_k)(2b^0 + c - 2b^0_i - c_i) \]
Returns
d3epsilon_dninjnkslist[list[list[float]]]

Third mole number derivative of epsilon of each component, [m^6/mol^5]

Notes

This derivative is checked numerically.

property d3epsilon_dzizjzks

Helper method for calculating the third composition derivatives of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^3 \epsilon}{\partial x_i \partial x_j \partial x_k }\right)_{T, P, x_{m\ne i,j,k}} = 0 \]
Returns
d2epsilon_dzizjzkslist[list[list[float]]]

Composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

property ddelta_dns

Helper method for calculating the mole number derivatives of delta. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial \delta}{\partial n_i}\right)_{T, P, n_{i\ne j}} = 2 (c_i + b^0_i) - \delta \]
Returns
ddelta_dnslist[float]

Mole number derivative of delta of each component, [m^3/mol^2]

Notes

This derivative is checked numerically.

property ddelta_dzs

Helper method for calculating the composition derivatives of delta. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial \delta}{\partial x_i}\right)_{T, P, x_{i\ne j}} = 2 (c_i + b^0_i) \]
Returns
ddelta_dzslist[float]

Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property depsilon_dns

Helper method for calculating the mole number derivatives of epsilon. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial \epsilon}{\partial n_i}\right)_{T, P, n_{i\ne j}} = 2b^0(b^0 - b^0_i) - c(2b^0 - 2b_i^0 + c - c_i) - (c - c_i)(2b^0 + c) \]
Returns
depsilon_dnslist[float]

Composition derivative of epsilon of each component, [m^6/mol^3]

Notes

This derivative is checked numerically.

property depsilon_dzs

Helper method for calculating the composition derivatives of epsilon. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial \epsilon}{\partial x_i}\right)_{T, P, x_{i\ne j}} = c_i(2b^0_i + c) + c(2b^0_i + c_i) - 2b^0 b^0_i \]
Returns
depsilon_dzslist[float]

Composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

eos_pure

alias of thermo.eos.PRTranslated

Peng Robinson Translated-Consistent

class thermo.eos_mix.PRMIXTranslatedConsistent(Tcs, Pcs, omegas, zs, kijs=None, cs=None, alpha_coeffs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_alpha_functions.Twu91_a_alpha, thermo.eos_mix.PRMIXTranslated

Class for solving the volume translated Le Guennec, Privat, and Jaubert revision of the Peng-Robinson equation of state according to [1].

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{v + c - b} - \frac{a\alpha(T)}{(v+c)(v + c + b)+b(v + c - b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i=0.45724\frac{R^2T_{c,i}^2}{P_{c,i}} \]
\[b_i=0.07780\frac{RT_{c,i}}{P_{c,i}} \]
\[\alpha_i = \left(\frac{T}{T_{c}}\right)^{c_{3} \left(c_{2} - 1\right)} e^{c_{1} \left(- \left(\frac{T}{T_{c}} \right)^{c_{2} c_{3}} + 1\right)} \]

If c is not provided, they are estimated as:

\[c =\frac{R T_c}{P_c}(0.0198\omega - 0.0065) \]

If alpha_coeffs is not provided, the parameters L and M are estimated from the acentric factor as follows:

\[L = 0.1290\omega^2 + 0.6039\omega + 0.0877 \]
\[M = 0.1760\omega^2 - 0.2600\omega + 0.8884 \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

cslist[float], optional

Volume translation parameters, [m^3/mol]

alpha_coeffslist[tuple(float[3])], optional

Coefficients L, M, N (also called C1, C2, C3) of TWU 1991 form, [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1

Le Guennec, Yohann, Romain Privat, and Jean-Noël Jaubert. “Development of the Translated-Consistent Tc-PR and Tc-RK Cubic Equations of State for a Safe and Accurate Prediction of Volumetric, Energetic and Saturation Properties of Pure Compounds in the Sub- and Super-Critical Domains.” Fluid Phase Equilibria 429 (December 15, 2016): 301-12. https://doi.org/10.1016/j.fluid.2016.09.003.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = PRMIXTranslatedConsistent(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.2, 0.8], kijs=[[0,0.03],[0.03,0]])
>>> eos.V_l, eos.V_g
(3.675235812e-05, 0.00059709319879)
>>> eos.fugacities_l, eos.fugacities_g
([443454.9336, 106184.004057], [184122.74082, 563037.785])

Methods

eos_pure

alias of thermo.eos.PRTranslatedConsistent

eos_pure

alias of thermo.eos.PRTranslatedConsistent

Peng Robinson Translated (Pina-Martinez, Privat, and Jaubert Variant)

class thermo.eos_mix.PRMIXTranslatedPPJP(Tcs, Pcs, omegas, zs, kijs=None, cs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.PRMIXTranslated

Class for solving the Pina-Martinez, Privat, Jaubert, and Peng revision of the Peng-Robinson equation of state.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{v + c - b} - \frac{a\alpha(T)}{(v+c)(v + c + b)+b(v + c - b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i=0.45724\frac{R^2T_{c,i}^2}{P_{c,i}} \]
\[b_i=0.07780\frac{RT_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i=[1+\kappa_i(1-\sqrt{T_{r,i}})]^2 \]
\[\kappa_i=0.3919 + 1.4996 \omega - 0.2721\omega^2 + 0.1063\omega^3 \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

cslist[float], optional

Volume translation parameters, [m^3/mol]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1

Pina-Martinez, Andrés, Romain Privat, Jean-Noël Jaubert, and Ding-Yu Peng. “Updated Versions of the Generalized Soave α-Function Suitable for the Redlich-Kwong and Peng-Robinson Equations of State.” Fluid Phase Equilibria, December 7, 2018. https://doi.org/10.1016/j.fluid.2018.12.007.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = PRMIXTranslatedPPJP(T=115, P=1E6, cs=[-4.4e-6, -4.35e-6], Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.2, 0.8], kijs=[[0,0.03],[0.03,0]])
>>> eos.V_l, eos.V_g
(3.8989032701e-05, 0.00059686183724)
>>> eos.fugacities_l, eos.fugacities_g
([444791.13707, 104520.280997], [184782.600238, 563352.147])

Methods

eos_pure

alias of thermo.eos.PRTranslatedPPJP

eos_pure

alias of thermo.eos.PRTranslatedPPJP

SRK Family EOSs

Standard SRK

class thermo.eos_mix.SRKMIX(Tcs, Pcs, omegas, zs, kijs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.EpsilonZeroMixingRules, thermo.eos_mix.GCEOSMIX, thermo.eos.SRK

Class for solving the Soave-Redlich-Kwong cubic equation of state for a mixture of any number of compounds. Solves the EOS on initialization and calculates fugacities for all components in all phases.

The implemented method here is fugacity_coefficients, which implements the formula for fugacity coefficients in a mixture as given in [1]. Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{V-b} - \frac{a\alpha(T)}{V(V+b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i =\left(\frac{R^2(T_{c,i})^{2}}{9(\sqrt[3]{2}-1)P_{c,i}} \right) =\frac{0.42748\cdot R^2(T_{c,i})^{2}}{P_{c,i}} \]
\[b_i =\left( \frac{(\sqrt[3]{2}-1)}{3}\right)\frac{RT_{c,i}}{P_{c,i}} =\frac{0.08664\cdot R T_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i = \left[1 + m_i\left(1 - \sqrt{\frac{T}{T_{c,i}}}\right)\right]^2 \]
\[m_i = 0.480 + 1.574\omega_i - 0.176\omega_i^2 \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1

Soave, Giorgio. “Equilibrium Constants from a Modified Redlich-Kwong Equation of State.” Chemical Engineering Science 27, no. 6 (June 1972): 1197-1203. doi:10.1016/0009-2509(72)80096-4.

2

Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.

3

Walas, Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> SRK_mix = 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],[0,0]])
>>> SRK_mix.V_l, SRK_mix.V_g
(4.1047569614e-05, 0.0007110158049)

Methods

a_alpha_and_derivatives_vectorized(T)

Method to calculate the pure-component a_alphas and their first and second derivatives for the SRK EOS.

a_alphas_vectorized(T)

Method to calculate the pure-component a_alphas for the SRK EOS.

dlnphis_dP(phase)

Generic formula for calculating the pressure derivaitve of log fugacity coefficients for each species in a mixture for the SRK EOS.

dlnphis_dT(phase)

Formula for calculating the temperature derivaitve of log fugacity coefficients for each species in a mixture for the SRK equation of state.

eos_pure

alias of thermo.eos.SRK

fugacity_coefficients(Z)

Literature formula for calculating fugacity coefficients for each species in a mixture.

a_alpha_and_derivatives_vectorized(T)[source]

Method to calculate the pure-component a_alphas and their first and second derivatives for the SRK EOS. This vectorized implementation is added for extra speed.

\[a\alpha = a \left(m \left(- \sqrt{\frac{T}{Tc}} + 1\right) + 1\right)^{2} \]
\[\frac{d a\alpha}{dT} = \frac{a m}{T} \sqrt{\frac{T}{Tc}} \left(m \left(\sqrt{\frac{T}{Tc}} - 1\right) - 1\right) \]
\[\frac{d^2 a\alpha}{dT^2} = \frac{a m \sqrt{\frac{T}{Tc}}}{2 T^{2}} \left(m + 1\right) \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

da_alpha_dTslist[float]

Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2slist[float]

Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]

a_alphas_vectorized(T)[source]

Method to calculate the pure-component a_alphas for the SRK EOS. This vectorized implementation is added for extra speed.

\[a\alpha = a \left(m \left(- \sqrt{\frac{T}{Tc}} + 1\right) + 1\right)^{2} \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

dlnphis_dP(phase)[source]

Generic formula for calculating the pressure derivaitve of log fugacity coefficients for each species in a mixture for the SRK EOS. Verified numerically.

\[\left(\frac{\partial \ln \phi_i}{\partial P}\right)_{T, nj \ne i} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnphis_dPfloat

Pressure derivatives of log fugacity coefficient for each species, [1/Pa]

Notes

This expression was derived using SymPy and optimized with the cse technique.

dlnphis_dT(phase)[source]

Formula for calculating the temperature derivaitve of log fugacity coefficients for each species in a mixture for the SRK equation of state. Verified numerically.

\[\left(\frac{\partial \ln \phi_i}{\partial T}\right)_{P, nj \ne i} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnphis_dTfloat

Temperature derivatives of log fugacity coefficient for each species, [1/K]

Notes

This expression was derived using SymPy and optimized with the cse technique.

eos_pure

alias of thermo.eos.SRK

fugacity_coefficients(Z)[source]

Literature formula for calculating fugacity coefficients for each species in a mixture. Verified numerically. Applicable to most derivatives of the SRK equation of state as well. Called by fugacities on initialization, or by a solver routine which is performing a flash calculation.

\[\ln \hat \phi_i = \frac{B_i}{B}(Z-1) - \ln(Z-B) + \frac{A}{B} \left[\frac{B_i}{B} - \frac{2}{a \alpha}\sum_i y_i(a\alpha)_{ij} \right]\ln\left(1+\frac{B}{Z}\right) \]
\[A=\frac{a\alpha P}{R^2T^2} \]
\[B = \frac{bP}{RT} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
log_phisfloat

Log fugacity coefficient for each species, [-]

Twu SRK (1995)

class thermo.eos_mix.TWUSRKMIX(Tcs, Pcs, omegas, zs, kijs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_alpha_functions.TwuSRK95_a_alpha, thermo.eos_mix.SRKMIX

Class for solving the Twu variant of the Soave-Redlich-Kwong cubic equation of state for a mixture. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{V-b} - \frac{a\alpha(T)}{V(V+b)} \]
\[a_i =\left(\frac{R^2(T_{c,i})^{2}}{9(\sqrt[3]{2}-1)P_{c,i}} \right) =\frac{0.42748\cdot R^2(T_{c,i})^{2}}{P_{c,i}} \]
\[b_i =\left( \frac{(\sqrt[3]{2}-1)}{3}\right)\frac{RT_{c,i}}{P_{c,i}} =\frac{0.08664\cdot R T_{c,i}}{P_{c,i}} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[\alpha_i = \alpha^{(0,i)} + \omega_i(\alpha^{(1,i)}-\alpha^{(0,i)}) \]
\[\alpha^{(\text{0 or 1, i})} = T_{r,i}^{N(M-1)}\exp[L(1-T_{r,i}^{NM})] \]

For sub-critical conditions:

L0, M0, N0 = 0.141599, 0.919422, 2.496441

L1, M1, N1 = 0.500315, 0.799457, 3.291790

For supercritical conditions:

L0, M0, N0 = 0.441411, 6.500018, -0.20

L1, M1, N1 = 0.032580, 1.289098, -8.0

Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T. Claimed to be more accurate than the SRK equation.

References

1

Twu, Chorng H., John E. Coon, and John R. Cunningham. “A New Generalized Alpha Function for a Cubic Equation of State Part 2. Redlich-Kwong Equation.” Fluid Phase Equilibria 105, no. 1 (March 15, 1995): 61-69. doi:10.1016/0378-3812(94)02602-W.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = TWUSRKMIX(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],[0,0]])
>>> eos.V_l, eos.V_g
(4.1087927542e-05, 0.00071170732525)
>>> eos.fugacities_l, eos.fugacities_g
([809692.830826, 74093.6388157], [441783.431489, 362470.3174107])

Methods

eos_pure

alias of thermo.eos.TWUSRK

eos_pure

alias of thermo.eos.TWUSRK

API SRK

class thermo.eos_mix.APISRKMIX(Tcs, Pcs, zs, omegas=None, kijs=None, T=None, P=None, V=None, S1s=None, S2s=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.SRKMIX, thermo.eos.APISRK

Class for solving the Refinery Soave-Redlich-Kwong cubic equation of state for a mixture of any number of compounds, as shown in the API Databook [1]. Subclasses APISRK. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{V-b} - \frac{a\alpha(T)}{V(V+b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i =\left(\frac{R^2(T_{c,i})^{2}}{9(\sqrt[3]{2}-1)P_{c,i}} \right) =\frac{0.42748\cdot R^2(T_{c,i})^{2}}{P_{c,i}} \]
\[b_i =\left( \frac{(\sqrt[3]{2}-1)}{3}\right)\frac{RT_{c,i}}{P_{c,i}} =\frac{0.08664\cdot R T_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i = \left[1 + S_{1,i}\left(1-\sqrt{T_{r,i}}\right) + S_{2,i} \frac{1- \sqrt{T_{r,i}}}{\sqrt{T_{r,i}}}\right]^2 \]
\[S_{1,i} = 0.48508 + 1.55171\omega_i - 0.15613\omega_i^2 \text{ if S1 is not tabulated } \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

S1sfloat, optional

Fit constant or estimated from acentric factor if not provided [-]

S2sfloat, optional

Fit constant or 0 if not provided [-]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1

API Technical Data Book: General Properties & Characterization. American Petroleum Institute, 7E, 2005.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = APISRKMIX(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],[0,0]])
>>> eos.V_l, eos.V_g
(4.101592310e-05, 0.00071046883030)
>>> eos.fugacities_l, eos.fugacities_g
([817882.3033, 71620.4823812], [442158.29113, 361519.79877])

Methods

eos_pure

alias of thermo.eos.APISRK

eos_pure

alias of thermo.eos.APISRK

SRK Translated

class thermo.eos_mix.SRKMIXTranslated(Tcs, Pcs, omegas, zs, kijs=None, cs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.SRKMIX

Class for solving the volume translated Soave-Redlich-Kwong cubic equation of state for a mixture of any number of compounds. Subclasses SRKMIX. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{V + c - b} - \frac{a\alpha(T)}{(V + c)(V + c + b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[b = \sum_i z_i b_i \]
\[a_i =\left(\frac{R^2(T_{c,i})^{2}}{9(\sqrt[3]{2}-1)P_{c,i}} \right) =\frac{0.42748\cdot R^2(T_{c,i})^{2}}{P_{c,i}} \]
\[b_i =\left( \frac{(\sqrt[3]{2}-1)}{3}\right)\frac{RT_{c,i}}{P_{c,i}} =\frac{0.08664\cdot R T_{c,i}}{P_{c,i}} \]
\[\alpha(T)_i = \left[1 + m_i\left(1 - \sqrt{\frac{T}{T_{c,i}}}\right)\right]^2 \]
\[m_i = 0.480 + 1.574\omega_i - 0.176\omega_i^2 \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

cslist[float], optional

Volume translation parameters; always zero in the original implementation, [m^3/mol]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = SRKMIXTranslated(T=115, P=1E6, cs=[-4.4e-6, -4.35e-6], Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.2, 0.8], kijs=[[0,0.03],[0.03,0]])
>>> eos.V_l, eos.V_g
(4.35928920e-05, 0.00060927202)
Attributes
d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta.

d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta.

d2epsilon_dninjs

Helper method for calculating the second mole number derivatives (hessian) of epsilon.

d2epsilon_dzizjs

Helper method for calculating the second composition derivatives (hessian) of epsilon.

d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta.

d3delta_dzizjzks

Helper method for calculating the third composition derivatives of delta.

d3epsilon_dninjnks

Helper method for calculating the third partial mole number derivatives of epsilon.

d3epsilon_dzizjzks

Helper method for calculating the third composition derivatives of epsilon.

ddelta_dns

Helper method for calculating the mole number derivatives of delta.

ddelta_dzs

Helper method for calculating the composition derivatives of delta.

depsilon_dns

Helper method for calculating the mole number derivatives of epsilon.

depsilon_dzs

Helper method for calculating the composition derivatives of epsilon.

Methods

eos_pure

alias of thermo.eos.SRKTranslated

property d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial^2 \delta}{\partial n_i \partial n_j}\right)_{T, P, n_{k\ne i,j}} = \left(\2(b^0 - c_i - c_j) + 4c - b_i^0 - b_j^0\right) \]
Returns
d2delta_dninjslist[list[float]]

Second mole number derivative of delta of each component, [m^3/mol^3]

Notes

This derivative is checked numerically.

property d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta. Note this is independent of the phase.

\[\left(\frac{\partial^2 \delta}{\partial x_i\partial x_j}\right)_{T, P, x_{k\ne i,j}} = 0 \]
Returns
d2delta_dzizjslist[float]

Second Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property d2epsilon_dninjs

Helper method for calculating the second mole number derivatives (hessian) of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^2 \epsilon}{\partial n_i n_j}\right)_{T, P, n_{k\ne i,j}} = b^0(2c - c_i - c_j) + c(2b^0 - b_i^0 - b_j^0) + 2c(2c - c_i - c_j) +(b^0 - b^0_i)(c - c_j) + (b^0 - b_j^0)(c - c_i) + 2(c - c_i)(c - c_j) \]
Returns
d2epsilon_dninjslist[list[float]]

Second mole number derivative of epsilon of each component, [m^6/mol^4]

Notes

This derivative is checked numerically.

property d2epsilon_dzizjs

Helper method for calculating the second composition derivatives (hessian) of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^2 \epsilon}{\partial x_i \partial x_j}\right)_{T, P, x_{k\ne i,j}} = b^0_i c_j + b^0_j c_i + 2c_i c_j \]
Returns
d2epsilon_dzizjslist[list[float]]

Second composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

property d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial^3 \delta}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = -6b^0 + 2(b^0_i + b^0_j + b^0_k) + -12c +4(c_i + c_j + c_k) \]
Returns
d3delta_dninjnkslist[list[list[float]]]

Third mole number derivative of delta of each component, [m^3/mol^4]

Notes

This derivative is checked numerically.

property d3delta_dzizjzks

Helper method for calculating the third composition derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial^3 \delta}{\partial x_i \partial x_j \partial x_k }\right)_{T, P, x_{m\ne i,j,k}} = 0 \]
Returns
d3delta_dzizjzkslist[list[list[float]]]

Third composition derivative of epsilon of each component, [m^6/mol^5]

Notes

This derivative is checked numerically.

property d3epsilon_dninjnks

Helper method for calculating the third partial mole number derivatives of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^3 \epsilon}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = -2b^0(3c - c_i - c_j - c_k) - 2c(3b^0 - b^0_i - b^0_j - b^0_k) - 4c(3c - c_i - c_j - c_k) -(b^0 - b^0_i)(2c - c_j - c_k) -(b^0 - b^0_j)(2c - c_i - c_k) -(b^0 - b^0_k)(2c - c_i - c_j) - (c - c_i)(2b^0 - b^0_j - b^0_k) - (c - c_j)(2b^0 - b^0_i - b^0_k) - (c - c_k)(2b^0 - b^0_i - b^0_j) -2(c - c_i)(2c - c_j - c_k) -2(c - c_j)(2c - c_i - c_k) -2(c - c_k)(2c - c_i - c_j) \]
Returns
d3epsilon_dninjnkslist[list[list[float]]]

Third mole number derivative of epsilon of each component, [m^6/mol^5]

Notes

This derivative is checked numerically.

property d3epsilon_dzizjzks

Helper method for calculating the third composition derivatives of epsilon. Note this is independent of the phase.

\[\left(\frac{\partial^3 \epsilon}{\partial x_i \partial x_j \partial x_k }\right)_{T, P, x_{m\ne i,j,k}} = 0 \]
Returns
d2epsilon_dzizjzkslist[list[list[float]]]

Composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

property ddelta_dns

Helper method for calculating the mole number derivatives of delta. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial \delta}{\partial n_i}\right)_{T, P, n_{i\ne j}} = (2 c_i + b^0_i) - \delta \]
Returns
ddelta_dnslist[float]

Mole number derivative of delta of each component, [m^3/mol^2]

Notes

This derivative is checked numerically.

property ddelta_dzs

Helper method for calculating the composition derivatives of delta. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial \delta}{\partial x_i}\right)_{T, P, x_{i\ne j}} = 2 (c_i + b^0_i) \]
Returns
ddelta_dzslist[float]

Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property depsilon_dns

Helper method for calculating the mole number derivatives of epsilon. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial \epsilon}{\partial n_i}\right)_{T, P, n_{i\ne j}} = -b^0(c - c_i) - c(b^0 - b_i^0) - 2c(c - c_i) \]
Returns
depsilon_dnslist[float]

Composition derivative of epsilon of each component, [m^6/mol^3]

Notes

This derivative is checked numerically.

property depsilon_dzs

Helper method for calculating the composition derivatives of epsilon. Note this is independent of the phase. \(b^0\) refers to the original b parameter not involving any translation.

\[\left(\frac{\partial \epsilon}{\partial x_i}\right)_{T, P, x_{i\ne j}} = c_i b^0 + 2c c_i + b_i c \]
Returns
depsilon_dzslist[float]

Composition derivative of epsilon of each component, [m^6/mol^2]

Notes

This derivative is checked numerically.

eos_pure

alias of thermo.eos.SRKTranslated

SRK Translated-Consistent

class thermo.eos_mix.SRKMIXTranslatedConsistent(Tcs, Pcs, omegas, zs, kijs=None, cs=None, alpha_coeffs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_alpha_functions.Twu91_a_alpha, thermo.eos_mix.SRKMIXTranslated

Class for solving the volume translated Le Guennec, Privat, and Jaubert revision of the SRK equation of state according to [1].

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{V + c - b} - \frac{a\alpha(T)}{(V + c)(V + c + b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[\alpha_i = \left(\frac{T}{T_{c,i}}\right)^{c_{3} \left(c_{2} - 1\right)} e^{c_{1} \left(- \left(\frac{T}{T_{c,i}} \right)^{c_{2} c_{3}} + 1\right)} \]
\[b = \sum_i z_i b_i \]
\[a_i =\left(\frac{R^2(T_{c,i})^{2}}{9(\sqrt[3]{2}-1)P_{c,i}} \right) =\frac{0.42748\cdot R^2(T_{c,i})^{2}}{P_{c,i}} \]
\[b_i =\left( \frac{(\sqrt[3]{2}-1)}{3}\right)\frac{RT_{c,i}}{P_{c,i}} =\frac{0.08664\cdot R T_{c,i}}{P_{c,i}} \]

If cs is not provided, they are estimated as:

\[c =\frac{R T_c}{P_c}(0.0172\omega - 0.0096) \]

If alpha_coeffs is not provided, the parameters L and M are estimated from each of the acentric factors as follows:

\[L = 0.0947\omega^2 + 0.6871\omega + 0.1508 \]
\[M = 0.1615\omega^2 - 0.2349\omega + 0.8876 \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

cslist[float], optional

Volume translation parameters, [m^3/mol]

alpha_coeffslist[list[float]]

Coefficients for thermo.eos_alpha_functions.Twu91_a_alpha, [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1

Le Guennec, Yohann, Romain Privat, and Jean-Noël Jaubert. “Development of the Translated-Consistent Tc-PR and Tc-RK Cubic Equations of State for a Safe and Accurate Prediction of Volumetric, Energetic and Saturation Properties of Pure Compounds in the Sub- and Super-Critical Domains.” Fluid Phase Equilibria 429 (December 15, 2016): 301-12. https://doi.org/10.1016/j.fluid.2016.09.003.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = SRKMIXTranslatedConsistent(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.2, 0.8], kijs=[[0,0.03],[0.03,0]])
>>> eos.V_l, eos.V_g
(3.591044498e-05, 0.0006020501621)

Methods

eos_pure

alias of thermo.eos.SRKTranslatedConsistent

eos_pure

alias of thermo.eos.SRKTranslatedConsistent

MSRK Translated

class thermo.eos_mix.MSRKMIXTranslated(Tcs, Pcs, omegas, zs, kijs=None, cs=None, alpha_coeffs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_alpha_functions.Soave_1979_a_alpha, thermo.eos_mix.SRKMIXTranslatedConsistent

Class for solving the volume translated Soave (1980) alpha function, revision of the Soave-Redlich-Kwong equation of state for a pure compound according to [1]. Uses two fitting parameters N and M to more accurately fit the vapor pressure of pure species.

Two of T, P, and V are needed to solve the EOS.

\[P = \frac{RT}{V + c - b} - \frac{a\alpha(T)}{(V + c)(V + c + b)} \]
\[a \alpha = \sum_i \sum_j z_i z_j {(a\alpha)}_{ij} \]
\[(a\alpha)_{ij} = (1-k_{ij})\sqrt{(a\alpha)_{i}(a\alpha)_{j}} \]
\[\alpha(T)_i = 1 + (1 - T_{r,i})(M + \frac{N}{T_{r,i}}) \]
\[b = \sum_i z_i b_i \]
\[a_i =\left(\frac{R^2(T_{c,i})^{2}}{9(\sqrt[3]{2}-1)P_{c,i}} \right) =\frac{0.42748\cdot R^2(T_{c,i})^{2}}{P_{c,i}} \]
\[b_i =\left( \frac{(\sqrt[3]{2}-1)}{3}\right)\frac{RT_{c,i}}{P_{c,i}} =\frac{0.08664\cdot R T_{c,i}}{P_{c,i}} \]

This is an older correlation that offers lower accuracy on many properties which were sacrificed to obtain the vapor pressure accuracy. The alpha function of this EOS does not meet any of the consistency requriements for alpha functions.

Coefficients can be found in [2], or estimated with the method in [3]. The estimation method in [3] works as follows, using the acentric factor and true critical compressibility:

\[M = 0.4745 + 2.7349(\omega Z_c) + 6.0984(\omega Z_c)^2 \]
\[N = 0.0674 + 2.1031(\omega Z_c) + 3.9512(\omega Z_c)^2 \]

An alternate estimation scheme is provided in [1], which provides analytical solutions to calculate the parameters M and N from two points on the vapor pressure curve, suggested as 10 mmHg and 1 atm. This is used as an estimation method here if the parameters are not provided, and the two vapor pressure points are obtained from the original SRK equation of state.

Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

cslist[float], optional

Volume translation parameters, [m^3/mol]

alpha_coeffslist[list[float]]

Coefficients for thermo.eos_alpha_functions.Soave_1979_a_alpha, [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1(1,2)

Soave, G. “Rigorous and Simplified Procedures for Determining the Pure-Component Parameters in the Redlich—Kwong—Soave Equation of State.” Chemical Engineering Science 35, no. 8 (January 1, 1980): 1725-30. https://doi.org/10.1016/0009-2509(80)85007-X.

2

Sandarusi, Jamal A., Arthur J. Kidnay, and Victor F. Yesavage. “Compilation of Parameters for a Polar Fluid Soave-Redlich-Kwong Equation of State.” Industrial & Engineering Chemistry Process Design and Development 25, no. 4 (October 1, 1986): 957-63. https://doi.org/10.1021/i200035a020.

3(1,2)

Valderrama, Jose O., Héctor De la Puente, and Ahmed A. Ibrahim. “Generalization of a Polar-Fluid Soave-Redlich-Kwong Equation of State.” Fluid Phase Equilibria 93 (February 11, 1994): 377-83. https://doi.org/10.1016/0378-3812(94)87021-7.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = MSRKMIXTranslated(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, 0.011], zs=[0.2, 0.8], kijs=[[0,0.03],[0.03,0]])
>>> eos.V_l, eos.V_g
(3.9222990198e-05, 0.00060438075638)

Methods

eos_pure

alias of thermo.eos.MSRKTranslated

eos_pure

alias of thermo.eos.MSRKTranslated

Cubic Equation of State with Activity Coefficients

class thermo.eos_mix.PSRK(Tcs, Pcs, omegas, zs, alpha_coeffs, ge_model, kijs=None, cs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_alpha_functions.Mathias_Copeman_poly_a_alpha, thermo.eos_mix.PSRKMixingRules, thermo.eos_mix.SRKMIXTranslated

Class for solving the Predictive Soave-Redlich-Kwong [1] equation of state for a mixture of any number of compounds. Solves the EOS on initialization.

Two of T, P, and V are needed to solve the EOS.

Warning

This class is not complete! Fugacities and their derivatives among others are not yet implemented.

\[P = \frac{RT}{V-b} - \frac{a\alpha(T)}{V(V+b)} \]
\[b = \sum_i z_i b_i \]
\[a_i =\left(\frac{R^2(T_{c,i})^{2}}{9(\sqrt[3]{2}-1)P_{c,i}} \right) =\frac{0.42748\cdot R^2(T_{c,i})^{2}}{P_{c,i}} \]
\[b_i =\left( \frac{(\sqrt[3]{2}-1)}{3}\right)\frac{RT_{c,i}}{P_{c,i}} =\frac{0.08664\cdot R T_{c,i}}{P_{c,i}} \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

omegasfloat

Acentric factors of all compounds, [-]

zsfloat

Overall mole fractions of all species, [-]

alpha_coeffslist[list[float]]

Coefficients for thermo.eos_alpha_functions.Mathias_Copeman_poly_a_alpha, [-]

ge_modelthermo.activity.GibbsExcess object

Excess Gibbs free energy model; to match the PSRK model, this is a thermo.unifac.UNIFAC object, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

cslist[float], optional

Volume translation parameters; always zero in the original implementation, [m^3/mol]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

References

1

Holderbaum, T., and J. Gmehling. “PSRK: A Group Contribution Equation of State Based on UNIFAC.” Fluid Phase Equilibria 70, no. 2-3 (December 30, 1991): 251-65. https://doi.org/10.1016/0378-3812(91)85038-V.

Examples

T-P initialization, equimolar CO2, n-hexane:

>>> from thermo.unifac import UNIFAC, PSRKIP, PSRKSG
>>> Tcs = [304.2, 507.4]
>>> Pcs = [7.37646e6, 3.014419e6]
>>> omegas = [0.2252, 0.2975]
>>> zs = [0.5, 0.5]
>>> Mathias_Copeman_coeffs = [[-1.7039, 0.2515, 0.8252, 1.0], [2.9173, -1.4411, 1.1061, 1.0]]
>>> T = 313.
>>> P = 1E6
>>> ge_model = UNIFAC.from_subgroups(T=T, xs=zs, chemgroups=[{117: 1}, {1:2, 2:4}], subgroups=PSRKSG, interaction_data=PSRKIP, version=0)
>>> eos = PSRK(Tcs=Tcs, Pcs=Pcs, omegas=omegas, zs=zs, ge_model=ge_model, alpha_coeffs=Mathias_Copeman_coeffs, T=T, P=P)
>>> eos
PSRK(Tcs=[304.2, 507.4], Pcs=[7376460.0, 3014419.0], omegas=[0.2252, 0.2975], kijs=[[0.0, 0.0], [0.0, 0.0]], alpha_coeffs=[[-1.7039, 0.2515, 0.8252, 1.0], [2.9173, -1.4411, 1.1061, 1.0]], cs=[0.0, 0.0], ge_model=UNIFAC(T=313.0, xs=[0.5, 0.5], rs=[1.3, 4.4998000000000005], qs=[0.982, 3.856], Qs=[0.848, 0.54, 0.982], vs=[[0, 2], [0, 4], [1, 0]], psi_abc=([[0.0, 0.0, 919.8], [0.0, 0.0, 919.8], [-38.672, -38.672, 0.0]], [[0.0, 0.0, -3.9132], [0.0, 0.0, -3.9132], [0.8615, 0.8615, 0.0]], [[0.0, 0.0, 0.0046309], [0.0, 0.0, 0.0046309], [-0.0017906, -0.0017906, 0.0]]), version=0), zs=[0.5, 0.5], T=313.0, P=1000000.0)
>>> eos.phase, eos.V_l, eos.V_g
('l/g', 0.000110889753959, 0.00197520225546)

Methods

eos_pure

alias of thermo.eos.SRKTranslated

eos_pure

alias of thermo.eos.SRKTranslated

Van der Waals Equation of State

class thermo.eos_mix.VDWMIX(Tcs, Pcs, zs, kijs=None, T=None, P=None, V=None, omegas=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.EpsilonZeroMixingRules, thermo.eos_mix.GCEOSMIX, thermo.eos.VDW

Class for solving the Van der Waals [1] [2] cubic equation of state for a mixture of any number of compounds. Solves the EOS on initialization and calculates fugacities for all components in all phases.

Two of T, P, and V are needed to solve the EOS.

\[P=\frac{RT}{V-b}-\frac{a}{V^2} \]
\[a = \sum_i \sum_j z_i z_j {a}_{ij} \]
\[b = \sum_i z_i b_i \]
\[a_{ij} = (1-k_{ij})\sqrt{a_{i}a_{j}} \]
\[a_i=\frac{27}{64}\frac{(RT_{c,i})^2}{P_{c,i}} \]
\[b_i=\frac{RT_{c,i}}{8P_{c,i}} \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

omegasfloat, optional

Acentric factors of all compounds - Not used in equation of state!, [-]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

For P-V initializations, a numerical solver is used to find T.

References

1

Walas, Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.

2

Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = VDWMIX(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], zs=[0.5, 0.5], kijs=[[0,0],[0,0]])
>>> eos.V_l, eos.V_g
(5.881369844883e-05, 0.00077708723758)
>>> eos.fugacities_l, eos.fugacities_g
([854533.266920, 207126.8497276], [448470.736338, 397826.543999])
Attributes
d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta.

d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta.

d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta.

ddelta_dns

Helper method for calculating the mole number derivatives of delta.

ddelta_dzs

Helper method for calculating the composition derivatives of delta.

Methods

a_alpha_and_derivatives_vectorized(T)

Method to calculate the pure-component a_alphas and their first and second derivatives for the VDW EOS.

a_alphas_vectorized(T)

Method to calculate the pure-component a_alphas for the VDW EOS.

dlnphis_dP(phase)

Generic formula for calculating the pressure derivaitve of log fugacity coefficients for each species in a mixture for the VDW EOS.

dlnphis_dT(phase)

Formula for calculating the temperature derivaitve of log fugacity coefficients for each species in a mixture for the VDW equation of state.

eos_pure

alias of thermo.eos.VDW

fugacity_coefficients(Z)

Literature formula for calculating fugacity coefficients for each species in a mixture.

a_alpha_and_derivatives_vectorized(T)[source]

Method to calculate the pure-component a_alphas and their first and second derivatives for the VDW EOS. This vectorized implementation is added for extra speed.

\[a\alpha = a \]
\[\frac{d a\alpha}{dT} = 0 \]
\[\frac{d^2 a\alpha}{dT^2} = 0 \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

da_alpha_dTslist[float]

Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2slist[float]

Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]

a_alphas_vectorized(T)[source]

Method to calculate the pure-component a_alphas for the VDW EOS. This vectorized implementation is added for extra speed.

\[a\alpha = a \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

property d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta. Note this is independent of the phase.

\[\left(\frac{\partial^2 \delta}{\partial n_i \partial n_j}\right)_{T, P, n_{k\ne i,j}} = 0 \]
Returns
d2delta_dninjslist[list[float]]

Second mole number derivative of delta of each component, [m^3/mol^3]

Notes

This derivative is checked numerically.

property d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta. Note this is independent of the phase.

\[\left(\frac{\partial^2 \delta}{\partial x_i\partial x_j}\right)_{T, P, x_{k\ne i,j}} = 0 \]
Returns
d2delta_dzizjslist[float]

Second Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial^3 \delta}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = 0 \]
Returns
d3delta_dninjnkslist[list[list[float]]]

Third mole number derivative of delta of each component, [m^3/mol^4]

Notes

This derivative is checked numerically.

property ddelta_dns

Helper method for calculating the mole number derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial \delta}{\partial n_i}\right)_{T, P, n_{i\ne j}} = 0 \]
Returns
ddelta_dnslist[float]

Mole number derivative of delta of each component, [m^3/mol^2]

Notes

This derivative is checked numerically.

property ddelta_dzs

Helper method for calculating the composition derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial \delta}{\partial x_i}\right)_{T, P, x_{i\ne j}} = 0 \]
Returns
ddelta_dzslist[float]

Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

dlnphis_dP(phase)[source]

Generic formula for calculating the pressure derivaitve of log fugacity coefficients for each species in a mixture for the VDW EOS. Verified numerically.

\[\left(\frac{\partial \ln \phi_i}{\partial P}\right)_{T, nj \ne i} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnphis_dPfloat

Pressure derivatives of log fugacity coefficient for each species, [1/Pa]

Notes

This expression was derived using SymPy and optimized with the cse technique.

dlnphis_dT(phase)[source]

Formula for calculating the temperature derivaitve of log fugacity coefficients for each species in a mixture for the VDW equation of state. Verified numerically.

\[\left(\frac{\partial \ln \phi_i}{\partial T}\right)_{P, nj \ne i} \]
Parameters
phasestr

One of ‘l’ or ‘g’, [-]

Returns
dlnphis_dTfloat

Temperature derivatives of log fugacity coefficient for each species, [1/K]

Notes

This expression was derived using SymPy and optimized with the cse technique.

eos_pure

alias of thermo.eos.VDW

fugacity_coefficients(Z)[source]

Literature formula for calculating fugacity coefficients for each species in a mixture. Verified numerically. Called by fugacities on initialization, or by a solver routine which is performing a flash calculation.

\[\ln \hat \phi_i = \frac{b_i}{V-b} - \ln\left[Z\left(1 - \frac{b}{V}\right)\right] - \frac{2\sqrt{aa_i}}{RTV} \]
Parameters
Zfloat

Compressibility of the mixture for a desired phase, [-]

Returns
log_phisfloat

Log fugacity coefficient for each species, [-]

References

1

Walas, Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.

Redlich-Kwong Equation of State

class thermo.eos_mix.RKMIX(Tcs, Pcs, zs, omegas=None, kijs=None, T=None, P=None, V=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.EpsilonZeroMixingRules, thermo.eos_mix.GCEOSMIX, thermo.eos.RK

Class for solving the Redlich Kwong [1] [2] cubic equation of state for a mixture of any number of compounds. Subclasses thermo.eos.RK . Solves the EOS on initialization and calculates fugacities for all components in all phases. Two of T, P, and V are needed to solve the EOS.

\[P =\frac{RT}{V-b}-\frac{a}{V\sqrt{T}(V+b)} \]
\[a = \sum_i \sum_j z_i z_j {a}_{ij} \]
\[b = \sum_i z_i b_i \]
\[a_{ij} = (1-k_{ij})\sqrt{a_{i}a_{j}} \]
\[a_i =\left(\frac{R^2(T_{c,i})^{2}}{9(\sqrt[3]{2}-1)P_{c,i}} \right) =\frac{0.42748\cdot R^2(T_{c,i})^{2}}{P_{c,i}} \]
\[b_i=\left( \frac{(\sqrt[3]{2}-1)}{3}\right)\frac{RT_{c,i}}{P_{c,i}} =\frac{0.08664\cdot R T_{c,i}}{P_{c,i}} \]
Parameters
Tcsfloat

Critical temperatures of all compounds, [K]

Pcsfloat

Critical pressures of all compounds, [Pa]

zsfloat

Overall mole fractions of all species, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

omegasfloat, optional

Acentric factors of all compounds - Not used in this equation of state!, [-]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

The PV solution for T is iterative.

References

1

Walas, Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.

2

Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = RKMIX(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], zs=[0.5, 0.5], kijs=[[0,0],[0,0]])
>>> eos.V_l, eos.V_g
(4.048414781e-05, 0.00070060605863)
Attributes
d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta.

d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta.

d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta.

ddelta_dns

Helper method for calculating the mole number derivatives of delta.

ddelta_dzs

Helper method for calculating the composition derivatives of delta.

Methods

a_alpha_and_derivatives_vectorized(T)

Method to calculate the pure-component a_alphas and their first and second derivatives for the RK EOS.

a_alphas_vectorized(T)

Method to calculate the pure-component a_alphas for the RK EOS.

eos_pure

alias of thermo.eos.RK

a_alpha_and_derivatives_vectorized(T)[source]

Method to calculate the pure-component a_alphas and their first and second derivatives for the RK EOS. This vectorized implementation is added for extra speed.

\[a\alpha = \frac{a}{\sqrt{\frac{T}{Tc}}} \]
\[\frac{d a\alpha}{dT} = - \frac{a}{2 T\sqrt{\frac{T}{Tc}}} \]
\[\frac{d^2 a\alpha}{dT^2} = \frac{3 a}{4 T^{2}\sqrt{\frac{T}{Tc}}} \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

da_alpha_dTslist[float]

Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2slist[float]

Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]

Examples

>>> eos = RKMIX(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],[0,0]])
>>> eos.a_alpha_and_derivatives_vectorized(115)
([0.1449810919468, 0.30019773677], [-0.000630352573681, -0.00130520755121], [8.2219900915e-06, 1.7024446320e-05])
a_alphas_vectorized(T)[source]

Method to calculate the pure-component a_alphas for the RK EOS. This vectorized implementation is added for extra speed.

\[a\alpha = \frac{a}{\sqrt{\frac{T}{Tc}}} \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

Examples

>>> eos = RKMIX(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],[0,0]])
>>> eos.a_alphas_vectorized(115)
[0.1449810919468, 0.30019773677]
property d2delta_dninjs

Helper method for calculating the second mole number derivatives (hessian) of delta. Note this is independent of the phase.

\[\left(\frac{\partial^2 \delta}{\partial n_i \partial n_j}\right)_{T, P, n_{k\ne i,j}} = 2b - b_i - b_j \]
Returns
d2delta_dninjslist[list[float]]

Second mole number derivative of delta of each component, [m^3/mol^3]

Notes

This derivative is checked numerically.

property d2delta_dzizjs

Helper method for calculating the second composition derivatives (hessian) of delta. Note this is independent of the phase.

\[\left(\frac{\partial^2 \delta}{\partial x_i\partial x_j}\right)_{T, P, x_{k\ne i,j}} = 0 \]
Returns
d2delta_dzizjslist[float]

Second Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

property d3delta_dninjnks

Helper method for calculating the third partial mole number derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial^3 \delta}{\partial n_i \partial n_j \partial n_k } \right)_{T, P, n_{m \ne i,j,k}} = 2(-3b + b_i + b_j + b_k) \]
Returns
d3delta_dninjnkslist[list[list[float]]]

Third mole number derivative of delta of each component, [m^3/mol^4]

Notes

This derivative is checked numerically.

property ddelta_dns

Helper method for calculating the mole number derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial \delta}{\partial n_i}\right)_{T, P, n_{i\ne j}} = (b_i - b) \]
Returns
ddelta_dnslist[float]

Mole number derivative of delta of each component, [m^3/mol^2]

Notes

This derivative is checked numerically.

property ddelta_dzs

Helper method for calculating the composition derivatives of delta. Note this is independent of the phase.

\[\left(\frac{\partial \delta}{\partial x_i}\right)_{T, P, x_{i\ne j}} = b_i \]
Returns
ddelta_dzslist[float]

Composition derivative of delta of each component, [m^3/mol]

Notes

This derivative is checked numerically.

eos_pure

alias of thermo.eos.RK

Ideal Gas Equation of State

class thermo.eos_mix.IGMIX(zs, T=None, P=None, V=None, Tcs=None, Pcs=None, omegas=None, kijs=None, fugacities=True, only_l=False, only_g=False)[source]

Bases: thermo.eos_mix.EpsilonZeroMixingRules, thermo.eos_mix.GCEOSMIX, thermo.eos.IG

Class for solving the ideal gas [1] [2] equation of state for a mixture of any number of compounds. Subclasses thermo.eos.IG. Solves the EOS on initialization. Two of T, P, and V are needed to solve the EOS.

\[P =\frac{RT}{V} \]
Parameters
zslist[float]

Overall mole fractions of all species, [-]

Tfloat, optional

Temperature, [K]

Pfloat, optional

Pressure, [Pa]

Vfloat, optional

Molar volume, [m^3/mol]

Tcslist[float], optional

Critical temperatures of all compounds, [K]

Pcslist[float], optional

Critical pressures of all compounds, [Pa]

omegaslist[float], optional

Acentric factors of all compounds - Not used in this equation of state!, [-]

kijslist[list[float]], optional

n*n size list of lists with binary interaction parameters for the Van der Waals mixing rules, default all 0 and not used[-]

fugacitiesbool, optional

Whether or not to calculate fugacity related values (phis, log phis, and fugacities); default True, [-]

only_lbool, optional

When true, if there is a liquid and a vapor root, only the liquid root (and properties) will be set; default False, [-]

only_gbool, optional

When true, if there is a liquid and a vapor root, only the vapor root (and properties) will be set; default False, [-]

Notes

Many properties of this object are zero. Many of the arguments are not used and are provided for consistency only.

References

1

Walas, Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.

2

Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.

Examples

T-P initialization, nitrogen-methane at 115 K and 1 MPa:

>>> eos = IGMIX(T=115, P=1E6, Tcs=[126.1, 190.6], Pcs=[33.94E5, 46.04E5], omegas=[0.04, .008], zs=[0.5, 0.5])
>>> eos.phase, eos.V_g
('g', 0.0009561632010876225)

Methods

a_alpha_and_derivatives_vectorized(T)

Method to calculate the pure-component a_alphas and their first and second derivatives for the Ideal Gas EOS.

a_alphas_vectorized(T)

Method to calculate the pure-component a_alphas for the Ideal Gas EOS.

eos_pure

alias of thermo.eos.IG

a_alpha_and_derivatives_vectorized(T)[source]

Method to calculate the pure-component a_alphas and their first and second derivatives for the Ideal Gas EOS. This vectorized implementation is added for extra speed.

\[a\alpha = 0 \]
\[\frac{d a\alpha}{dT} = 0 \]
\[\frac{d^2 a\alpha}{dT^2} = 0 \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

da_alpha_dTslist[float]

Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2slist[float]

Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]

a_alphas_vectorized(T)[source]

Method to calculate the pure-component a_alphas for the Ideal Gas EOS. This vectorized implementation is added for extra speed.

\[a\alpha = 0 \]
Parameters
Tfloat

Temperature, [K]

Returns
a_alphaslist[float]

Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]

eos_pure

alias of thermo.eos.IG

Different Mixing Rules

class thermo.eos_mix.EpsilonZeroMixingRules[source]
Attributes
d2epsilon_dninjs

Helper method for calculating the second mole number derivatives (hessian) of epsilon.

d2epsilon_dzizjs

Helper method for calculating the second composition derivatives (hessian) of epsilon.

d3epsilon_dninjnks

Helper method for calculating the third partial mole number derivatives of epsilon.

depsilon_dns

Helper method for calculating the mole number derivatives of epsilon.

depsilon_dzs

Helper method for calculating the composition derivatives of epsilon.

class thermo.eos_mix.PSRKMixingRules[source]

Bases: object

Methods

a_alpha_and_derivatives(T[, full, quick, ...])

Method to calculate a_alpha and its first and second derivatives for an EOS with the PSRK mixing rules.

A = -0.6466271649250525
a_alpha_and_derivatives(T, full=True, quick=True, pure_a_alphas=True)[source]

Method to calculate a_alpha and its first and second derivatives for an EOS with the PSRK mixing rules. Returns a_alpha, da_alpha_dT, and d2a_alpha_dT2.

For use in some methods, this returns only a_alpha if full is False.

\[\alpha = bRT \left[ \sum_i \frac{z_i \alpha_i}{b_i RT} + \frac{1}{A}\left(\frac{G^E}{RT} + \sum_i z_i \ln \left(\frac{b}{b_i}\right) \right)\right] \]
\[\frac{\partial \alpha}{\partial T} = RTb\left[ \sum_i \left(\frac{z_i \frac{\partial \alpha_i}{\partial T}}{RTb_i} -\frac{z_i\alpha_i}{RT^2b_i} \right) + \frac{1}{A}\left(\frac{\frac{\partial G^E}{\partial T}}{RT} - \frac{G^E}{RT^2} \right) \right] + \frac{\alpha}{T} \]
\[\frac{\partial^2 \alpha}{\partial T^2} = b\left[\sum_i \left(\frac{z_i\frac{\partial^2 \alpha_i}{\partial T^2}}{b_i} - \frac{2z_i \frac{\partial \alpha_i}{\partial T}}{T b_i} + \frac{2z_i\alpha_i}{T^2 b_i} \right) + \frac{2}{T}\left[\sum_i \left(\frac{z_i\frac{\partial \alpha_i} {\partial T}}{b_i} - \frac{z_i \alpha_i}{T b_i} \right) + \frac{1}{A}\left(\frac{\partial G^E}{\partial T} - \frac{G^E}{T} \right) \right] + \frac{1}{A}\left( \frac{\partial^2 G^E}{\partial T^2} - \frac{2}{T} \frac{\partial G^E}{\partial T} + 2\frac{G^E}{T^2} \right) \right] \]
Parameters
Tfloat

Temperature, [K]

fullbool, optional

If False, calculates and returns only a_alpha

quickbool, optional

Only the quick variant is implemented; it is little faster anyhow

pure_a_alphasbool, optional

Whether or not to recalculate the a_alpha terms of pure components (for the case of mixtures only) which stay the same as the composition changes (i.e in a PT flash), [-]

Returns
a_alphafloat

Coefficient calculated by PSRK-specific method, [J^2/mol^2/Pa]

da_alpha_dTfloat

Temperature derivative of coefficient calculated by PSRK-specific method, [J^2/mol^2/Pa/K]

d2a_alpha_dT2float

Second temperature derivative of coefficient calculated by PSRK-specific method, [J^2/mol^2/Pa/K**2]

u = 1.1

Lists of Equations of State

thermo.eos_mix.eos_mix_list = [<class 'thermo.eos_mix.PRMIX'>, <class 'thermo.eos_mix.SRKMIX'>, <class 'thermo.eos_mix.PR78MIX'>, <class 'thermo.eos_mix.VDWMIX'>, <class 'thermo.eos_mix.PRSVMIX'>, <class 'thermo.eos_mix.PRSV2MIX'>, <class 'thermo.eos_mix.TWUPRMIX'>, <class 'thermo.eos_mix.TWUSRKMIX'>, <class 'thermo.eos_mix.APISRKMIX'>, <class 'thermo.eos_mix.IGMIX'>, <class 'thermo.eos_mix.RKMIX'>, <class 'thermo.eos_mix.PRMIXTranslatedConsistent'>, <class 'thermo.eos_mix.PRMIXTranslatedPPJP'>, <class 'thermo.eos_mix.SRKMIXTranslatedConsistent'>, <class 'thermo.eos_mix.PRMIXTranslated'>, <class 'thermo.eos_mix.SRKMIXTranslated'>]

List of all exported EOS classes.

thermo.eos_mix.eos_mix_no_coeffs_list = [<class 'thermo.eos_mix.PRMIX'>, <class 'thermo.eos_mix.SRKMIX'>, <class 'thermo.eos_mix.PR78MIX'>, <class 'thermo.eos_mix.VDWMIX'>, <class 'thermo.eos_mix.TWUPRMIX'>, <class 'thermo.eos_mix.TWUSRKMIX'>, <class 'thermo.eos_mix.IGMIX'>, <class 'thermo.eos_mix.RKMIX'>, <class 'thermo.eos_mix.PRMIXTranslatedConsistent'>, <class 'thermo.eos_mix.PRMIXTranslated'>, <class 'thermo.eos_mix.SRKMIXTranslated'>, <class 'thermo.eos_mix.PRMIXTranslatedPPJP'>, <class 'thermo.eos_mix.SRKMIXTranslatedConsistent'>]

List of all exported EOS classes that do not require special parameters or can fill in their special parameters from other specified parameters.