Skip to content

Use in the Flash and Column Solvers

The pressure-vapor-fraction and temperature-vapor-fraction flashes use \(\partial K_{i}/\partial T\) from the K-value derivative relations above to form the temperature Newton step, replacing a three-point finite-difference stencil.

The rigorous column solvers assemble an analytical block-tridiagonal Jacobian. The equilibrium rows use the analytical K-value temperature and composition derivatives; the material-balance rows are exact; the energy rows use the phase-enthalpy derivatives. This analytical Jacobian is enabled by default for absorption, distillation, reboiled and refluxed columns and can be disabled with the environment variable SW_ANALYTIC_JAC set to zero. A verification mode compares the analytical Jacobian against finite differences and reports the largest relative discrepancy per equation type.

Every derivative documented in this appendix was validated against high-quality central finite differences, taken on the very function the package answers with. That qualification is not pedantry. A package may expose more than one route to the K-values, and pairing the Jacobian of one route with the residual of another is worse for a solver than having no analytical Jacobian at all, so the comparison is always made against the route that is actually in force. The composition derivatives match to relative errors on the order of ten to the minus eight to ten to the minus nine; the temperature derivatives are frequently limited by the truncation of the finite-difference reference rather than by the analytical expression, and where the two can be compared against the finite-difference implementation they replace, the analytical form is two to three orders of magnitude closer to the truth.

The practical effect on a rigorous column is worth stating in concrete terms. On a sour-water stripper solved with the Newton method, replacing the numerical Jacobian with the analytical one reduces the solution time by a factor of about two and a half on both electrolyte packages, reaching the same converged profile, the same product flows and the same stage temperatures. Larger columns benefit more, because the numerical Jacobian costs one full residual evaluation per variable while the analytical one is assembled in a single pass; very small columns can be marginally slower, which is what the environment variable that disables the analytical Jacobian is for.

Two cautions apply to anyone extending this work. First, a verification that compares only where the reference is significant will not see a wrong entry wherever the reference is near zero, and those entries can still destroy a Newton direction; an absolute or row-scaled measure is needed to catch them. Second, a finite difference of a quantity that is itself obtained by iteration cannot be taken with an arbitrarily small step: below the convergence tolerance of the inner solve, the difference quotient returns noise amplified by the reciprocal of the step. Where such a derivative is unavoidable, the step must be relative to the variable and floored well above that tolerance.