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.
- 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 .
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 , [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 and its first and second derivatives.
a_alpha_for_Psat
(T, Psat[, a_alpha_guess])Method to calculate which value of is required for a given T, Psat pair.
a_alpha_for_V
(T, P, V)Method to calculate which value of 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 parameter and its first two derivatives.
as_json
([cache, option])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.
exact_hash
()Method to calculate and return a hash representing the exact state of the object.
from_json
(json_repr[, cache])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.- 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 .
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- property d3a_alpha_dninjnks¶
Helper method for calculating the third mole number derivatives of a_alpha. Note this is independent of the phase.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- property da_alpha_dT_dns¶
Helper method for calculating the mole number derivatives of da_alpha_dT. Note this is independent of the phase.
- 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.
- 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.
- 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.
- 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.
- 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.
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.
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.
- 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.
- 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.
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- property dna_alpha_dT_dns¶
Helper method for calculating the mole number derivatives of da_alpha_dT. Note this is independent of the phase.
- 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.
- 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.
Notes
This derivative is checked numerically.
- classmethod from_json(json_repr, cache=None)[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.
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].For reference, several expressions for fugacity of a component are as follows, shown in [1] and [2].
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.