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 pure 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.
Calculates the molar departure Gibbs energy mole number derivatives (where the mole fractions sum to 1).
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).
Calculates the mixture log fugacity coefficient second mole number derivatives (where the mole fraction sum to 1).
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.
Generic formula for calculating log fugacity coefficients for each species in a mixture.
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.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
- Returns
- Psat
float
Vapor pressure using the pure-component approach, [Pa]
- Psat
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
- T
float
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), [-]
- T
- Returns
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
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)$
- 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
- Z
float
Compressibility of the mixture for a desired phase, [-]
- Z
- Returns
- d2G_dep_dzizjs
float
Departure Gibbs free energy second composition derivatives, [J/mol]
- d2G_dep_dzizjs
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)$
- 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
- Z
float
Compressibility of the mixture for a desired phase, [-]
- Z
- Returns
- d2V_dzizjs
float
Molar volume second composition derivatives, [m^3/mol]
- d2V_dzizjs
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
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
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
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
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
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
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
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)$
- 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)$
- 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
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
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
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
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
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
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.
- 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
- Z
float
Compressibility of the mixture for a desired phase, [-]
- Z
- Returns
- dG_dep_dzs
float
Departure Gibbs free energy composition derivatives, [J/mol]
- dG_dep_dzs
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)$
- 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
- Z
float
Compressibility of the mixture for a desired phase, [-]
- Z
- Returns
- dH_dep_dzs
float
Departure enthalpy composition derivatives, [J/mol]
- dH_dep_dzs
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)$
- 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)$
- 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)$
- 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
- Z
float
Compressibility of the mixture for a desired phase, [-]
- Z
- Returns
- dV_dzs
float
Molar volume composition derivatives, [m^3/mol]
- dV_dzs
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)$
- 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}}$
- 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
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
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
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
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
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$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$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}}$
- 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}}$
- 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.
- 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)$
- 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
- phase
str
One of ‘l’ or ‘g’, [-]
- phase
- Returns
- dlnphis_dP
float
Pressure derivatives of log fugacity coefficient for each species, [1/Pa]
- dlnphis_dP
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
- phase
str
One of ‘l’ or ‘g’, [-]
- phase
- Returns
- dlnphis_dT
float
Temperature derivatives of log fugacity coefficient for each species, [1/K]
- dlnphis_dT
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}}$
- 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}}$
- 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)$
- 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)$
- 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)$
- 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)$
- 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
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
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$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_repr
dict
Json representation, [-]
- json_repr
- Returns
- eos_mix
GCEOSMIX
Newly created object from the json serialization, [-]
- eos_mix
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
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}}$