Cubic Equations of State Utilities (thermo.eos_mix_methods)¶
This file contains a number of overflow methods for EOSs which for various reasons are better implemented as functions. Documentation is not provided for this file and no methods are intended to be used outside this library.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Alpha Function Mixing Rules¶
These are where the bulk of the time is spent in solving the equation of state. For that reason, these functional forms often duplicate functionality but have different performance characteristics.
Implementations which store N^2 matrices for other calculations:
- thermo.eos_mix_methods.a_alpha_aijs_composition_independent(a_alphas, one_minus_kijs, a_alpha_ijs=None, a_alpha_roots=None, a_alpha_ij_roots_inv=None)[source]¶
Calculates the matrix as well as the array and the matrix .
This routine is efficient in both numba and PyPy, but it is generally better to avoid calculating and storing any N^2 matrices. However, this particular calculation only depends on T so in some circumstances this can be feasible.
- Parameters
- a_alphas
list
[float
] EOS attractive terms, [J^2/mol^2/Pa]
- one_minus_kijs
list
[list
[float
]] One minus the constant kijs, [-]
- a_alpha_ijs
list
[list
[float
]] Optional output array, [J^2/mol^2/Pa]
- a_alpha_roots
list
[float
] Optional output array, [J/mol/Pa^0.5]
- a_alpha_ij_roots_inv
list
[list
[float
]] Optional output array, [mol^2*Pa/J^2]
- a_alphas
- Returns
Examples
>>> kijs = [[0,.083],[0.083,0]] >>> one_minus_kijs = [[1.0 - kij for kij in row] for row in kijs] >>> a_alphas = [0.2491099357671155, 0.6486495863528039] >>> a_alpha_ijs, a_alpha_roots, a_alpha_ij_roots_inv = a_alpha_aijs_composition_independent(a_alphas, one_minus_kijs) >>> a_alpha_ijs [[0.249109935767, 0.36861239374], [0.36861239374, 0.64864958635]] >>> a_alpha_roots [0.49910914213, 0.80538784840] >>> a_alpha_ij_roots_inv [[4.0142919105, 2.487707997796], [2.487707997796, 1.54166443799]]
- thermo.eos_mix_methods.a_alpha_and_derivatives_full(a_alphas, da_alpha_dTs, d2a_alpha_dT2s, T, zs, one_minus_kijs, a_alpha_ijs=None, a_alpha_roots=None, a_alpha_ij_roots_inv=None)[source]¶
Calculates the a_alpha term, and its first two temperature derivatives, for an equation of state along with the matrix quantities calculated in the process.
- Parameters
- a_alphas
list
[float
] EOS attractive terms, [J^2/mol^2/Pa]
- da_alpha_dTs
list
[float
] Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]
- d2a_alpha_dT2s
list
[float
] Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]
- T
float
Temperature, not used, [K]
- zs
list
[float
] Mole fractions of each species
- one_minus_kijs
list
[list
[float
]] One minus the constant kijs, [-]
- a_alpha_ijs
list
[list
[float
]],optional
Matrix of , [J^2/mol^2/Pa]
- a_alpha_roots
list
[float
],optional
Array of values, [J/mol/Pa^0.5]
- a_alpha_ij_roots_inv
list
[list
[float
]],optional
Matrix of , [mol^2*Pa/J^2]
- a_alphas
- Returns
- a_alpha
float
EOS attractive term, [J^2/mol^2/Pa]
- da_alpha_dT
float
Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]
- d2a_alpha_dT2
float
Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]
- a_alpha_ijs
list
[list
[float
]],optional
Matrix of , [J^2/mol^2/Pa]
- da_alpha_dT_ijs
list
[list
[float
]],optional
Matrix of , [J^2/mol^2/Pa/K]
- d2a_alpha_dT2_ijs
list
[list
[float
]],optional
Matrix of , [J^2/mol^2/Pa/K^2]
- a_alpha
Examples
>>> kijs = [[0,.083],[0.083,0]] >>> one_minus_kijs = [[1.0 - kij for kij in row] for row in kijs] >>> zs = [0.1164203, 0.8835797] >>> a_alphas = [0.2491099357671155, 0.6486495863528039] >>> da_alpha_dTs = [-0.0005102028006086241, -0.0011131153520304886] >>> d2a_alpha_dT2s = [1.8651128859234162e-06, 3.884331923127011e-06] >>> a_alpha, da_alpha_dT, d2a_alpha_dT2, a_alpha_ijs, da_alpha_dT_ijs, d2a_alpha_dT2_ijs = a_alpha_and_derivatives_full(a_alphas=a_alphas, da_alpha_dTs=da_alpha_dTs, d2a_alpha_dT2s=d2a_alpha_dT2s, T=299.0, zs=zs, one_minus_kijs=one_minus_kijs) >>> a_alpha, da_alpha_dT, d2a_alpha_dT2 (0.58562139582, -0.001018667672, 3.56669817856e-06) >>> a_alpha_ijs [[0.2491099357, 0.3686123937], [0.36861239374, 0.64864958635]] >>> da_alpha_dT_ijs [[-0.000510202800, -0.0006937567844], [-0.000693756784, -0.00111311535]] >>> d2a_alpha_dT2_ijs [[1.865112885e-06, 2.4734471244e-06], [2.4734471244e-06, 3.8843319e-06]]
Compute only the alpha term itself:
- thermo.eos_mix_methods.a_alpha_and_derivatives(a_alphas, T, zs, one_minus_kijs, a_alpha_ijs=None, a_alpha_roots=None, a_alpha_ij_roots_inv=None)[source]¶
Faster implementations which do not store N^2 matrices:
- thermo.eos_mix_methods.a_alpha_quadratic_terms(a_alphas, a_alpha_roots, T, zs, one_minus_kijs, a_alpha_j_rows=None, vec0=None)[source]¶
Calculates the a_alpha term for an equation of state along with the vector quantities needed to compute the fugacities of the mixture. This routine is efficient in both numba and PyPy.
The secondary values are as follows:
- Parameters
- a_alphas
list
[float
] EOS attractive terms, [J^2/mol^2/Pa]
- a_alpha_roots
list
[float
] Square roots of a_alphas; provided for speed [J/mol/Pa^0.5]
- T
float
Temperature, not used, [K]
- zs
list
[float
] Mole fractions of each species
- one_minus_kijs
list
[list
[float
]] One minus the constant kijs, [-]
- a_alpha_j_rows
list
[float
],optional
EOS attractive term row destimation vector (does not need to be zeroed, should be provided to prevent allocations), [J^2/mol^2/Pa]
- vec0
list
[float
],optional
Empty vector, used in internal calculations, provide to avoid the allocations; does not need to be zeroed, [-]
- a_alphas
- Returns
Notes
Tried moving the i=j loop out, no difference in speed, maybe got a bit slower in PyPy.
Examples
>>> kijs = [[0,.083],[0.083,0]] >>> one_minus_kijs = [[1.0 - kij for kij in row] for row in kijs] >>> zs = [0.1164203, 0.8835797] >>> a_alphas = [0.2491099357671155, 0.6486495863528039] >>> a_alpha_roots = [i**0.5 for i in a_alphas] >>> a_alpha, a_alpha_j_rows = a_alpha_quadratic_terms(a_alphas, a_alpha_roots, 299.0, zs, one_minus_kijs) >>> a_alpha, a_alpha_j_rows (0.58562139582, [0.35469988173, 0.61604757237])
- thermo.eos_mix_methods.a_alpha_and_derivatives_quadratic_terms(a_alphas, a_alpha_roots, da_alpha_dTs, d2a_alpha_dT2s, T, zs, one_minus_kijs, a_alpha_j_rows=None, da_alpha_dT_j_rows=None)[source]¶
Calculates the a_alpha term, and its first two temperature derivatives, for an equation of state along with the vector quantities needed to compute the fugacitie and temperature derivatives of fugacities of the mixture. This routine is efficient in both numba and PyPy.
The secondary values are as follows:
- Parameters
- a_alphas
list
[float
] EOS attractive terms, [J^2/mol^2/Pa]
- a_alpha_roots
list
[float
] Square roots of a_alphas; provided for speed [J/mol/Pa^0.5]
- da_alpha_dTs
list
[float
] Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]
- d2a_alpha_dT2s
list
[float
] Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]
- T
float
Temperature, not used, [K]
- zs
list
[float
] Mole fractions of each species
- one_minus_kijs
list
[list
[float
]] One minus the constant kijs, [-]
- a_alphas
- Returns
- a_alpha
float
EOS attractive term, [J^2/mol^2/Pa]
- da_alpha_dT
float
Temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K]
- d2a_alpha_dT2
float
Second temperature derivative of coefficient calculated by EOS-specific method, [J^2/mol^2/Pa/K**2]
- a_alpha_j_rows
list
[float
] EOS attractive term row sums, [J^2/mol^2/Pa]
- da_alpha_dT_j_rows
list
[float
] Temperature derivative of EOS attractive term row sums, [J^2/mol^2/Pa/K]
- a_alpha
Examples
>>> kijs = [[0,.083],[0.083,0]] >>> one_minus_kijs = [[1.0 - kij for kij in row] for row in kijs] >>> zs = [0.1164203, 0.8835797] >>> a_alphas = [0.2491099357671155, 0.6486495863528039] >>> a_alpha_roots = [i**0.5 for i in a_alphas] >>> da_alpha_dTs = [-0.0005102028006086241, -0.0011131153520304886] >>> d2a_alpha_dT2s = [1.8651128859234162e-06, 3.884331923127011e-06] >>> a_alpha_and_derivatives_quadratic_terms(a_alphas, a_alpha_roots, da_alpha_dTs, d2a_alpha_dT2s, 299.0, zs, one_minus_kijs) (0.58562139582, -0.001018667672, 3.56669817856e-06, [0.35469988173, 0.61604757237], [-0.000672387374, -0.001064293501])