From 95d81f330327acdbb717be0027501fbee7f3fe7d Mon Sep 17 00:00:00 2001 From: Ian Bell <ian.bell@nist.gov> Date: Mon, 10 May 2021 15:11:57 -0400 Subject: [PATCH] Fix PC-SAFT Check length of compositions, output type --- include/teqp/models/pcsaft.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/teqp/models/pcsaft.hpp b/include/teqp/models/pcsaft.hpp index 9b39958..d1c4512 100644 --- a/include/teqp/models/pcsaft.hpp +++ b/include/teqp/models/pcsaft.hpp @@ -237,6 +237,10 @@ public: std::size_t N = m.size(); + if (mole_fractions.size() != N) { + throw std::invalid_argument("Length of mole_fractions (" + std::to_string(mole_fractions.size()) + ") is not the length of components (" + std::to_string(N) + ")"); + } + using TRHOType = std::common_type_t<decltype(T), decltype(mole_fractions[0]), decltype(m[0])>; SAFTCalc<TTYPE, TRHOType> c; @@ -265,7 +269,7 @@ public: std::vector<ta> zeta(4); for (std::size_t n = 0; n < 4; ++n) { // Eqn A.8 - Eigen::ArrayX<TTYPE> dn = c.d.pow(n); + auto dn = c.d.pow(n).eval(); TRHOType xmdn = forceeval((mole_fractions*m*dn).sum()); zeta[n] = forceeval(pi6*rho_A3*xmdn); } -- GitLab