...In this case the Peng Robinson Equation of State. Equations of state are empirical equations with parameters derived from experimental data. They are used to predict pure component and mixture properties such as compressibility, fugacity, and mixture equilibriums. See Wikipedia. Although I'm dealing with a Peng-Robinson EOS here, the algorithm can be applied to any other cubic EOS such as Van der Waals or Redlich–Kwong.
The equation is defined as such:
$p=\frac{R T}{V_m-b}-\frac{a}{-b^2+2 b V_m+V_m^2}$
where
$a=\frac{0.457235 R^2 T_c^2}{p_c} \alpha(T)$
$b = 0.07780 \frac{R T_c}{p_c}$
$\alpha(T) = [1+\kappa(1-(\frac{T}{T_c})^\frac{1}{2})]^2$
$\kappa = 0.37464+1.54226\omega-0.26992\omega^2$.
Translated into polynomial form:
$A = \frac{a p}{R^2 T^2}$ and $B = \frac{b p}{R T}$ which leads to the cubic form:
$Z^3-(1-B)Z^2+(A-2B-3B^2)Z-(A B - B^2 -B^3)=0$
When dealing with multi-component mixtures, Van der Waals mixing rules can be implemented as such:
$amix =\sum_{i=1}^N \sum_{j=1}^N x_i x_j Aij $
$bmix = \sum_{i=1}^N x_i b_i$
where
$Aij = Aji = (a_i a_j)^\frac{1}{2} (1-kij)$
The experimental parameters provided from literature are $T_c$ (critical temperatures), $P_c$ (critical pressures), $R$ (universal gas constant), $\omega$ (acentric factor), and $kij$ (binary interaction parameters). The component molar compositions are $x_i$ and is $N$ in length.
When solving the cubic equation there will, of course, be three roots. The max real root is the vapor root, and if a liquid phase is present, the min real root is the liquid root. The middle root is a fake root. If there is no liquid phase present, the vapor root will be the only real root.
What is the most efficient (both in terms of memory and speed) way to implement this algorithm to calculate the vapor z-factor?
Root[]'s numbering system is somewhat clear:Root[poly, 1]is the smallest root, andRoot[poly, 3]is the biggest one. – J. M.♦ Aug 22 '12 at 15:50