From fa662db83a863f848abe99bea93c1e5a9171cc81 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Thu, 28 May 2026 11:32:55 -0500 Subject: [PATCH 1/4] implement solve method --- .../compositional/functions/RachfordRice.hpp | 223 +++++++++++++++++- 1 file changed, 222 insertions(+), 1 deletion(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp index 4b997c2c45b..f6e6199876b 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp @@ -248,10 +248,231 @@ struct RachfordRice } } + /** + * @brief Computes the objective function, gradient vector, and Hessian matrix. + * + * @details Evaluates Michelsen's objective function reformulated for the negative flash + * region as described in Leibovici and Nichita (2008), Section 3, Equations 10-14. + * Paper: "A new look at multiphase Rachford-Rice equations for negative flashes" + * DOI: 10.1016/j.fluid.2008.03.006 + * The function F is convex and its unbounded minimization yields the phase fractions. + * Reference phase is Phase 1 (implicitly index 1). + * + * @param kValues Array slice of equilibrium constants (K-values). + * @param feed Array slice of feed composition (mole fractions). + * @param presentComponentIds Array slice of indices for components present in the mixture. + * @param v2 Mole fraction of the second phase. + * @param v3 Mole fraction of the third phase. + * @param F Computed objective function value (Equation 10). + * @param g Computed gradient vector of size 2 (Equation 13). + * @param H Computed Hessian matrix of size 4 (explicitly computed 2x2 matrix). + */ + template< integer USD1, integer USD2 > + GEOS_HOST_DEVICE + static void computeObjective( + arraySlice2d< real64 const, USD2 > const & kValues, + arraySlice1d< real64 const, USD1 > const & feed, + arraySlice1d< integer const > const & presentComponentIds, + real64 const v2, real64 const v3, + real64 & F, real64 g[2], real64 H[4] ) + { + F = 0.0; + g[0] = 0.0; + g[1] = 0.0; + H[0] = 0.0; + H[1] = 0.0; + H[2] = 0.0; + H[3] = 0.0; + + for( integer const & ic : presentComponentIds ) + { + real64 const z = feed[ic]; + + real64 const k2 = kValues( 0, ic ); + real64 const k3 = kValues( 1, ic ); + + real64 const k2Minus1 = k2 - 1.0; + real64 const k3Minus1 = k3 - 1.0; + + // E_i = 1 + (K_2i - 1)v_2 + (K_3i - 1)v_3 (Equation 12) + real64 const e = 1.0 + k2Minus1 * v2 + k3Minus1 * v3; + + // Objective function summation (Equation 10) + F -= z * LvArray::math::log( e ); + + // Gradients (Equation 13) + real64 const term1 = z / e; + g[0] -= term1 * k2Minus1; + g[1] -= term1 * k3Minus1; + + // Hessian entries (symmetric 2x2 matrix computed explicitly) + real64 const term2 = term1 / e; + H[0] += term2 * k2Minus1 * k2Minus1; + H[1] += term2 * k2Minus1 * k3Minus1; + H[2] += term2 * k3Minus1 * k2Minus1; + H[3] += term2 * k3Minus1 * k3Minus1; + } + } + + /** + * @brief Solves the 3-phase Rachford-Rice equations allowing negative phase fractions. + * + * @details Implements the constrained optimization approach by Michelsen, + * extended to the negative flash region by Leibovici and Nichita (2008). + * Paper: "A new look at multiphase Rachford-Rice equations for negative flashes" + * DOI: 10.1016/j.fluid.2008.03.006 + * The problem is formulated as an unbounded minimization with linear constraints + * (hyperplanes E_i > 0) to ensure continuous differentiability at phase boundaries. + * The inner loop uses a bounded Newton-Raphson scheme with Armijo backtracking line search. + * + * @param kValues Array slice of equilibrium constants (K-values). + * @param feed Array slice of feed composition (mole fractions). + * @param presentComponentIds Array slice of indices for components present in the mixture. + * @param v2 Output mole fraction of the second phase. Serves as initial guess if feasible. + * @param v3 Output mole fraction of the third phase. Serves as initial guess if feasible. + * @return bool True if the minimization converges successfully within tolerances, false otherwise. + */ + template< integer USD1, integer USD2 > + GEOS_HOST_DEVICE + static bool solve( + arraySlice2d< real64 const, USD2 > const & kValues, + arraySlice1d< real64 const, USD1 > const & feed, + arraySlice1d< integer const > const & presentComponentIds, + real64 & v2, + real64 & v3 ) + { + // 1. Initial feasibility check + // Evaluate if the provided initial conditions (v2, v3) are feasible (E_i > 0). + bool feasible = true; + for( integer const & ic : presentComponentIds ) + { + real64 const k2 = kValues( 0, ic ); + real64 const k3 = kValues( 1, ic ); + real64 const e = 1.0 + (k2 - 1.0) * v2 + (k3 - 1.0) * v3; + if( e <= 0.0 ) + { + feasible = false; + break; + } + } + + // Fallback inherently feasible initialization (1 / np) for 3 phases + if( !feasible ) + { + v2 = 1.0 / 3.0; + v3 = 1.0 / 3.0; + } + + // 2. Bound-constrained Newton-Raphson Optimization + real64 F = 0.0; + real64 g[2]{}; + real64 H[4]{}; + + for( integer iterations = 0; iterations < maxNewtonIterations; ++iterations ) + { + computeObjective( kValues, feed, presentComponentIds, v2, v3, F, g, H ); + + real64 const error = LvArray::math::max( LvArray::math::abs( g[0] ), LvArray::math::abs( g[1] )); + if( error <= newtonTolerance ) + { + return true; + } + + // Add small regularization to strictly enforce positive definiteness + // in cases where phases might artificially merge + H[0] += epsilon; + H[3] += epsilon; + + // Invert explicit 2x2 Hessian to compute Newton step (H * dv = -g) + real64 const determinant = H[0] * H[3] - H[1] * H[2]; + if( determinant <= epsilon ) + { + return false; + } + + real64 const dv2 = (-g[0] * H[3] + g[1] * H[1]) / determinant; + real64 const dv3 = (-g[1] * H[0] + g[0] * H[2]) / determinant; + + // Line Search Step 1: Find distance to hyperplane boundaries. + // The feasible domain is limited by hyperplanes E_i = 0 (Leibovici and Nichita 2008, Section 3). + // We compute the maximum step size alphaBound that keeps E_i > 0 for all components. + // The step along the search direction dv is restricted such that we do not cross the hyperplanes. + // For each component, if the step decreases E_i (i.e., de < 0), we find the intersection. + real64 alphaBound = 1.0; + for( integer const & ic : presentComponentIds ) + { + real64 const k2 = kValues( 0, ic ); + real64 const k3 = kValues( 1, ic ); + + real64 const de = (k2 - 1.0) * dv2 + (k3 - 1.0) * dv3; + if( de < 0.0 ) + { + real64 const e = 1.0 + (k2 - 1.0) * v2 + (k3 - 1.0) * v3; + real64 const alphaI = -e / de; + if( alphaI < alphaBound ) + { + alphaBound = alphaI; + } + } + } + + // Limit the maximum step length to remain strictly inside the domain. + // We scale the boundary by 1.0 - epsilon to prevent E_i from becoming exactly 0. + real64 alpha = (alphaBound < 1.0) ? (alphaBound * (1.0 - epsilon)) : 1.0; + + // Line Search Step 2: Backtracking (Armijo Rule). + // Ensures sufficient decrease in the objective function to guarantee global convergence. + // We start with the bounded step size 'alpha' and iteratively shrink it by half. + // The Armijo condition checks if the new objective value FNew is sufficiently smaller + // than the current value F plus a fraction (c1) of the directional derivative. + real64 const c1 = 1e-4; + real64 const directionalDerivative = g[0] * dv2 + g[1] * dv3; + bool stepAccepted = false; + + for( integer lineSearchIteration = 0; lineSearchIteration < 20; ++lineSearchIteration ) + { + real64 const v2New = v2 + alpha * dv2; + real64 const v3New = v3 + alpha * dv3; + + bool valid = true; + real64 FNew = 0.0; + + for( integer const & ic : presentComponentIds ) + { + real64 const e = 1.0 + (kValues( 0, ic ) - 1.0) * v2New + (kValues( 1, ic ) - 1.0) * v3New; + if( e <= 0.0 ) + { + valid = false; + break; + } + FNew -= feed[ic] * LvArray::math::log( e ); + } + + // Armijo condition check: F(x + alpha * p) <= F(x) + c1 * alpha * grad(F)^T * p + if( valid && FNew <= F + c1 * alpha * directionalDerivative ) + { + v2 = v2New; + v3 = v3New; + stepAccepted = true; + break; + } + + // Step too large; shrink + alpha *= 0.5; + } + + if( !stepAccepted ) + { + // Step size became too small (likely converged to machine precision limit) + return false; + } + } + + return false; + } }; } // namespace constitutive - } // namespace geos #endif //GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_COMPOSITIONAL_FUNCTIONS_RACHFORDRICE_HPP_ From 12111852ae6a31d06e67066e505b8639c10162dd Mon Sep 17 00:00:00 2001 From: dkachuma Date: Thu, 28 May 2026 16:40:27 -0500 Subject: [PATCH 2/4] Unit tests --- .../compositional/functions/RachfordRice.hpp | 124 +++++-- .../constitutive/unitTests/CMakeLists.txt | 1 + .../unitTests/testRachfordRice3Phase.cpp | 327 ++++++++++++++++++ 3 files changed, 414 insertions(+), 38 deletions(-) create mode 100644 src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp index f6e6199876b..07516de3efe 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp @@ -43,6 +43,8 @@ struct RachfordRice static constexpr integer maxNewtonIterations = MultiFluidConstants::maxNewtonIterations; /// Epsilon used in the calculations static constexpr real64 epsilon = LvArray::NumericLimits< real64 >::epsilon; + /// Used to avoid exploring boundary of feasibility region + static constexpr real64 threshold = 1.0 - 1.0e-4; /** * @brief Function solving the Rachford-Rice equation @@ -266,10 +268,11 @@ struct RachfordRice * @param F Computed objective function value (Equation 10). * @param g Computed gradient vector of size 2 (Equation 13). * @param H Computed Hessian matrix of size 4 (explicitly computed 2x2 matrix). + * @return The L2 norm of the error */ template< integer USD1, integer USD2 > GEOS_HOST_DEVICE - static void computeObjective( + static real64 computeObjective( arraySlice2d< real64 const, USD2 > const & kValues, arraySlice1d< real64 const, USD1 > const & feed, arraySlice1d< integer const > const & presentComponentIds, @@ -288,32 +291,31 @@ struct RachfordRice { real64 const z = feed[ic]; - real64 const k2 = kValues( 0, ic ); - real64 const k3 = kValues( 1, ic ); - - real64 const k2Minus1 = k2 - 1.0; - real64 const k3Minus1 = k3 - 1.0; + real64 const k2 = kValues( 0, ic ) - 1.0; + real64 const k3 = kValues( 1, ic ) - 1.0; // E_i = 1 + (K_2i - 1)v_2 + (K_3i - 1)v_3 (Equation 12) - real64 const e = 1.0 + k2Minus1 * v2 + k3Minus1 * v3; + real64 const e = 1.0 + k2 * v2 + k3 * v3; // Objective function summation (Equation 10) F -= z * LvArray::math::log( e ); // Gradients (Equation 13) real64 const term1 = z / e; - g[0] -= term1 * k2Minus1; - g[1] -= term1 * k3Minus1; + g[0] -= term1 * k2; + g[1] -= term1 * k3; // Hessian entries (symmetric 2x2 matrix computed explicitly) real64 const term2 = term1 / e; - H[0] += term2 * k2Minus1 * k2Minus1; - H[1] += term2 * k2Minus1 * k3Minus1; - H[2] += term2 * k3Minus1 * k2Minus1; - H[3] += term2 * k3Minus1 * k3Minus1; + H[0] += term2 * k2 * k2; + H[1] += term2 * k2 * k3; + H[2] += term2 * k3 * k2; + H[3] += term2 * k3 * k3; } + return LvArray::math::sqrt( g[0]*g[0] + g[1]*g[1] ); } +public: /** * @brief Solves the 3-phase Rachford-Rice equations allowing negative phase fractions. * @@ -341,14 +343,59 @@ struct RachfordRice real64 & v2, real64 & v3 ) { - // 1. Initial feasibility check - // Evaluate if the provided initial conditions (v2, v3) are feasible (E_i > 0). - bool feasible = true; + // Quick exit for trivial solutions + // Checks if the mixture universally prefers a single phase (e.g., single component). + // This avoids singularities in the Hessian matrix during Newton-Raphson. + + real64 maxK2 = -LvArray::NumericLimits< real64 >::max; + real64 minK2 = LvArray::NumericLimits< real64 >::max; + real64 maxK3 = -LvArray::NumericLimits< real64 >::max; + real64 minK3 = LvArray::NumericLimits< real64 >::max; + real64 maxK2OverK3 = -LvArray::NumericLimits< real64 >::max; + real64 minK2OverK3 = LvArray::NumericLimits< real64 >::max; + for( integer const & ic : presentComponentIds ) { real64 const k2 = kValues( 0, ic ); real64 const k3 = kValues( 1, ic ); - real64 const e = 1.0 + (k2 - 1.0) * v2 + (k3 - 1.0) * v3; + + maxK2 = LvArray::math::max( maxK2, k2 ); + minK2 = LvArray::math::min( minK2, k2 ); + maxK3 = LvArray::math::max( maxK3, k3 ); + minK3 = LvArray::math::min( minK3, k3 ); + + real64 const k2OverK3 = k2 / k3; + maxK2OverK3 = LvArray::math::max( maxK2OverK3, k2OverK3 ); + minK2OverK3 = LvArray::math::min( minK2OverK3, k2OverK3 ); + } + + if( maxK2 < 1.0 && maxK3 < 1.0 ) + { + v2 = 0.0; + v3 = 0.0; + return true; + } + if( minK2 > 1.0 && minK2OverK3 > 1.0 ) + { + v2 = 1.0; + v3 = 0.0; + return true; + } + if( minK3 > 1.0 && maxK2OverK3 < 1.0 ) + { + v2 = 0.0; + v3 = 1.0; + return true; + } + + // Initial feasibility check + // Evaluate if the provided initial conditions (v2, v3) are feasible (E_i > 0). + bool feasible = true; + for( integer const & ic : presentComponentIds ) + { + real64 const k2 = kValues( 0, ic ) - 1.0; + real64 const k3 = kValues( 1, ic ) - 1.0; + real64 const e = 1.0 + k2 * v2 + k3 * v3; if( e <= 0.0 ) { feasible = false; @@ -363,17 +410,15 @@ struct RachfordRice v3 = 1.0 / 3.0; } - // 2. Bound-constrained Newton-Raphson Optimization + // Bound-constrained Newton-Raphson Optimization real64 F = 0.0; real64 g[2]{}; real64 H[4]{}; for( integer iterations = 0; iterations < maxNewtonIterations; ++iterations ) { - computeObjective( kValues, feed, presentComponentIds, v2, v3, F, g, H ); - - real64 const error = LvArray::math::max( LvArray::math::abs( g[0] ), LvArray::math::abs( g[1] )); - if( error <= newtonTolerance ) + real64 const error = computeObjective( kValues, feed, presentComponentIds, v2, v3, F, g, H ); + if( error < newtonTolerance ) { return true; } @@ -385,7 +430,7 @@ struct RachfordRice // Invert explicit 2x2 Hessian to compute Newton step (H * dv = -g) real64 const determinant = H[0] * H[3] - H[1] * H[2]; - if( determinant <= epsilon ) + if( determinant < epsilon ) { return false; } @@ -393,6 +438,13 @@ struct RachfordRice real64 const dv2 = (-g[0] * H[3] + g[1] * H[1]) / determinant; real64 const dv3 = (-g[1] * H[0] + g[0] * H[2]) / determinant; + // If the step size is too small we will declare convergence + real64 const stepSize = LvArray::math::sqrt( dv2*dv2 + dv3*dv3 ); + if( stepSize < newtonTolerance ) + { + return true; + } + // Line Search Step 1: Find distance to hyperplane boundaries. // The feasible domain is limited by hyperplanes E_i = 0 (Leibovici and Nichita 2008, Section 3). // We compute the maximum step size alphaBound that keeps E_i > 0 for all components. @@ -405,27 +457,27 @@ struct RachfordRice real64 const k3 = kValues( 1, ic ); real64 const de = (k2 - 1.0) * dv2 + (k3 - 1.0) * dv3; - if( de < 0.0 ) + real64 const e = 1.0 + (k2 - 1.0) * v2 + (k3 - 1.0) * v3; + if( epsilon < LvArray::math::abs( de ) ) { - real64 const e = 1.0 + (k2 - 1.0) * v2 + (k3 - 1.0) * v3; real64 const alphaI = -e / de; - if( alphaI < alphaBound ) + if( 0.0 < alphaI && alphaI < alphaBound ) { - alphaBound = alphaI; + // We scale the boundary by 1.0 - eps to prevent E_i from becoming exactly 0. + alphaBound = threshold * alphaI; } } } // Limit the maximum step length to remain strictly inside the domain. - // We scale the boundary by 1.0 - epsilon to prevent E_i from becoming exactly 0. - real64 alpha = (alphaBound < 1.0) ? (alphaBound * (1.0 - epsilon)) : 1.0; + real64 alpha = alphaBound; // Line Search Step 2: Backtracking (Armijo Rule). // Ensures sufficient decrease in the objective function to guarantee global convergence. // We start with the bounded step size 'alpha' and iteratively shrink it by half. // The Armijo condition checks if the new objective value FNew is sufficiently smaller // than the current value F plus a fraction (c1) of the directional derivative. - real64 const c1 = 1e-4; + real64 const c1 = 1.0e-4; real64 const directionalDerivative = g[0] * dv2 + g[1] * dv3; bool stepAccepted = false; @@ -434,22 +486,18 @@ struct RachfordRice real64 const v2New = v2 + alpha * dv2; real64 const v3New = v3 + alpha * dv3; - bool valid = true; real64 FNew = 0.0; for( integer const & ic : presentComponentIds ) { - real64 const e = 1.0 + (kValues( 0, ic ) - 1.0) * v2New + (kValues( 1, ic ) - 1.0) * v3New; - if( e <= 0.0 ) - { - valid = false; - break; - } + real64 const k2 = kValues( 0, ic ) - 1.0; + real64 const k3 = kValues( 1, ic ) - 1.0; + real64 const e = 1.0 + k2 * v2New + k3 * v3New; FNew -= feed[ic] * LvArray::math::log( e ); } // Armijo condition check: F(x + alpha * p) <= F(x) + c1 * alpha * grad(F)^T * p - if( valid && FNew <= F + c1 * alpha * directionalDerivative ) + if( FNew <= F + c1 * alpha * directionalDerivative ) { v2 = v2New; v3 = v3New; diff --git a/src/coreComponents/constitutive/unitTests/CMakeLists.txt b/src/coreComponents/constitutive/unitTests/CMakeLists.txt index 9dfbfc2c8a3..f99e5134dba 100644 --- a/src/coreComponents/constitutive/unitTests/CMakeLists.txt +++ b/src/coreComponents/constitutive/unitTests/CMakeLists.txt @@ -37,6 +37,7 @@ set( gtest_geosx_tests testStabilityTest2Comp.cpp testStabilityTest9Comp.cpp testRachfordRice.cpp + testRachfordRice3Phase.cpp testTwoPhaseImmiscibleFluid.cpp ) set( dependencyList gtest blas lapack constitutive ${parallelDeps} ) diff --git a/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp b/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp new file mode 100644 index 00000000000..41f0df06c6e --- /dev/null +++ b/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp @@ -0,0 +1,327 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2024 TotalEnergies + * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2023-2024 Chevron + * Copyright (c) 2019- GEOS/GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + + +// Source includes +#include "codingUtilities/UnitTestUtilities.hpp" +#include "common/DataTypes.hpp" +#include "constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp" + +// TPL includes +#include + +using namespace geos; +using namespace geos::testing; +using namespace geos::constitutive; + +using RachfordRiceData = std::tuple< + integer const, // Number of components + std::vector< real64 > const, // composition + std::vector< real64 > const, // log of k-values + bool const, // expected success of solve + real64 const, // expected mole fractions of the 2-nd phase + real64 const // expected mole fractions of the 3-rd phase + >; + +class RachfordRice3PhaseFixture : public ::testing::TestWithParam< RachfordRiceData > +{ + static constexpr real64 relTol = 1.0e-5; + static constexpr real64 absTol = 1.0e-7; + static constexpr integer MAX_NUM_COMP = 12; + +public: + RachfordRice3PhaseFixture() = default; + ~RachfordRice3PhaseFixture() = default; + + void testSolve( RachfordRiceData const & data ) + { + integer const numComps = std::get< 0 >( data ); + stackArray1d< real64, MAX_NUM_COMP > composition( numComps ); + stackArray1d< integer, MAX_NUM_COMP > presentComponents; + createComposition( numComps, composition.toSlice(), presentComponents, std::get< 1 >( data )); + stackArray2d< real64, 2*MAX_NUM_COMP > kValues( 2, numComps ); + createKValues( numComps, kValues.toSlice(), std::get< 2 >( data )); + bool const expectedSuccess = std::get< 3 >( data ); + real64 const expectedV2 = std::get< 4 >( data ); + real64 const expectedV3 = std::get< 5 >( data ); + + real64 v2 = -1000.0; + real64 v3 = 4000.0; + bool const success = RachfordRice::solve( kValues.toSliceConst(), + composition.toSliceConst(), + presentComponents.toSliceConst(), + v2, + v3 ); + + ASSERT_EQ( success, expectedSuccess ); + + if( expectedSuccess ) + { + checkRelativeError( expectedV2, v2, relTol, absTol ); + checkRelativeError( expectedV3, v3, relTol, absTol ); + + for( integer ic = 0; ic < numComps; ic++ ) + { + real64 const k2 = kValues( 0, ic ) - 1.0; + real64 const k3 = kValues( 1, ic ) - 1.0; + real64 const w = composition[ic] / (1.0 + v2*k2 + v3*k3); + real64 const x = kValues( 0, ic ) * w; + real64 const y = kValues( 1, ic ) * w; + real64 const z = (1.0 - v2 - v3)*w + v2*x + v3*y; + checkRelativeError( composition[ic], z, relTol, absTol ); + } + } + } + +protected: + template< typename CONTAINER, typename ARRAY > + static void createComposition( integer const numComps, + arraySlice1d< real64 > const & array, + ARRAY & components, + CONTAINER const & data ) + { + for( integer ic = 0; ic < numComps; ++ic ) + { + array[ic] = data[ic]; + if( MultiFluidConstants::minForSpeciesPresence < array[ic] ) + { + components.emplace_back( ic ); + } + } + } + + template< typename CONTAINER > + static void createKValues( integer const numComps, + arraySlice2d< real64 > const & array, + CONTAINER const & data ) + { + for( integer ic = 0; ic < numComps; ++ic ) + { + array( 0, ic ) = LvArray::math::exp( data[ic] ); + array( 1, ic ) = LvArray::math::exp( data[ic+numComps] ); + } + } +}; + +TEST_P( RachfordRice3PhaseFixture, testSolve ) +{ + testSolve( GetParam() ); +} + +//------------------------------------------------------------------------------- +// Data +//------------------------------------------------------------------------------- + +/* UNCRUSTIFY-OFF */ + +// We store log(K_ij) for better precision + +INSTANTIATE_TEST_SUITE_P( + RachfordRice3PhaseTest, RachfordRice3PhaseFixture, + ::testing::ValuesIn({ + { 3, {0.500000, 0.300000, 0.200000}, + { 1.0000000000e+00, 1.0000000000e+00, 1.0000000000e+00, + 1.0000000000e+00, 1.0000000000e+00, 1.0000000000e+00}, + false, -1.0000000000e+03, 4.0000000000e+03}, + { 3, {0.000000, 0.000000, 1.000000}, + { 3.3830190000e+00, 1.6804790000e-01, 1.9504870000e+00, + 2.2630780000e+00, 8.3155190000e-01, 2.7823120000e-01}, + true, 1.0000000000e+00, 0.0000000000e+00}, + { 3, {0.500000, 0.300000, 0.200000}, + { 5.0000000000e-01, 8.0000000000e-01, 1.0000000000e-01, + 2.0000000000e-01, 4.0000000000e-01, 9.0000000000e-01}, + false, -7.9864728886e+03, 3.1989639312e+04}, + { 3, {0.500000, 0.300000, 0.200000}, + { 5.0000000000e+00, 3.0000000000e+00, 4.0000000000e+00, + 2.0000000000e+00, 5.0000000000e-01, 3.5000000000e+00}, + true, 1.0000000000e+00, 0.0000000000e+00}, + { 3, {0.500000, 0.300000, 0.200000}, + { 5.0000000000e-01, 4.0000000000e+00, 1.5000000000e+00, + 2.0000000000e+00, 5.0000000000e+00, 3.0000000000e+00}, + true, 0.0000000000e+00, 1.0000000000e+00}, + { 3, {0.000000, 0.000000, 1.000000}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, 1.0000000000e+00, 0.0000000000e+00}, + { 3, {0.000000, 1.000000, 0.000000}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, 0.0000000000e+00, 0.0000000000e+00}, + { 3, {1.000000, 0.000000, 0.000000}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, 1.0000000000e+00, 0.0000000000e+00}, + { 3, {0.111596, 0.741874, 0.146530}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, -1.0000103600e-01, -9.9997720942e-02}, + { 3, {0.155964, 0.719153, 0.124883}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, -9.9999826586e-02, 1.0000084611e-01}, + { 3, {0.244699, 0.673712, 0.081588}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, -1.0000111923e-01, 5.0000157786e-01}, + { 3, {0.195304, 0.629659, 0.175037}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, 9.9999309416e-02, -9.9996894774e-02}, + { 3, {0.239671, 0.606938, 0.153390}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + false, 9.9999890090e-02, 9.9999431656e-02}, + { 3, {0.328407, 0.561498, 0.110095}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + false, 9.9998646075e-02, 5.0000239580e-01}, + { 3, {0.362719, 0.405230, 0.232052}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + false, 5.0000029750e-01, -1.0000194607e-01}, + { 3, {0.407087, 0.382509, 0.210404}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, 4.9999980256e-01, 1.0000147161e-01}, + { 3, {0.495822, 0.337068, 0.167110}, + { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01, + 8.1672591888e-01, -1.8446156207e-01, -1.2793030292e+00}, + true, 5.0000081429e-01, 4.9999675272e-01}, + { 5, {0.000000, 0.000000, 0.731951, 0.073328, 0.194721}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + false, 9.1679932526e+03, 1.1737367759e+04}, + { 5, {0.000000, 0.182518, 0.236961, 0.580521, 0.000000}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, 2.0459464278e+03, 1.5652480141e+02}, + { 5, {0.000784, 0.000000, 0.779458, 0.000000, 0.219758}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + false, -1.0000000000e+03, 4.0000000000e+03}, + { 5, {0.026188, 0.854982, 0.000000, 0.000000, 0.118830}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + false, -8.0023626358e+03, -4.7600675154e+03}, + { 5, {0.011512, 0.527101, 0.000000, 0.461387, 0.000000}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + false, -1.1118829097e+03, -8.1135650210e+03}, + { 5, {0.004539, 0.241945, 0.350786, 0.321205, 0.081525}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, -1.0534590100e-01, -1.0772308968e-01}, + { 5, {0.004538, 0.241928, 0.350821, 0.321176, 0.081537}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, -9.5483646146e-02, 1.0204434544e-01}, + { 5, {0.004538, 0.241894, 0.350889, 0.321118, 0.081561}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, -1.0122107560e-01, 4.9622187638e-01}, + { 5, {0.004538, 0.241938, 0.350768, 0.321244, 0.081513}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, 9.7649735403e-02, -1.0151087436e-01}, + { 5, {0.004538, 0.241921, 0.350802, 0.321215, 0.081525}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, 9.4780692475e-02, 9.5577503933e-02}, + { 5, {0.004537, 0.241887, 0.350871, 0.321157, 0.081549}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, 1.0177533214e-01, 5.0243391729e-01}, + { 5, {0.004537, 0.241924, 0.350730, 0.321322, 0.081488}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, 4.9255575728e-01, -1.0599864927e-01}, + { 5, {0.004536, 0.241906, 0.350764, 0.321293, 0.081500}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, 5.0660678790e-01, 1.0628624388e-01}, + { 5, {0.004536, 0.241872, 0.350833, 0.321235, 0.081524}, + {-6.9304756911e-04, -1.4660652030e-04, -2.6889257320e-04, 6.0839535321e-04, -7.6764553660e-04, + -2.1516846477e-04, -3.5183071939e-04, 4.8918631492e-04, -4.5208735271e-04, 7.3100545510e-04}, + true, 5.0217831837e-01, 5.0363617471e-01}, + { 8, {0.168799, 0.000000, 0.212965, 0.000000, 0.231750, 0.086919, 0.182901, 0.116666}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + false, -2.2701217834e+04, -2.3761073058e+04}, + { 8, {0.104908, 0.000000, 0.062125, 0.320612, 0.397158, 0.037219, 0.077978, 0.000000}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + false, -2.8228967009e+04, 2.5173998572e+03}, + { 8, {0.043758, 0.163929, 0.000000, 0.411593, 0.373857, 0.000368, 0.000000, 0.006495}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, 2.1407663043e-02, 1.0228609834e+00}, + { 8, {0.047907, 0.144408, 0.000000, 0.416483, 0.384744, 0.002319, 0.004140, 0.000000}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, -1.5503853108e-01, 1.1793468460e+00}, + { 8, {0.026861, 0.540869, 0.149219, 0.000000, 0.000000, 0.011865, 0.023858, 0.247327}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + false, 8.0136034767e+03, -1.5029515340e+04}, + { 8, {0.008818, 0.583033, 0.127774, 0.035018, 0.000000, 0.000586, 0.000000, 0.244771}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, 1.0745348115e+00, -4.9554362793e-02}, + { 8, {0.117524, 0.139845, 0.162070, 0.073145, 0.209566, 0.056175, 0.117842, 0.123833}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, -1.0000062870e-01, -1.0000139599e-01}, + { 8, {0.106349, 0.135111, 0.133313, 0.135455, 0.243741, 0.047173, 0.098843, 0.100016}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, -9.9999829926e-02, 1.0000022159e-01}, + { 8, {0.084000, 0.125642, 0.075799, 0.260073, 0.312091, 0.029169, 0.060844, 0.052381}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, -1.0000057048e-01, 5.0000154802e-01}, + { 8, {0.099079, 0.219212, 0.158342, 0.061187, 0.169390, 0.047015, 0.098417, 0.147357}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, 1.0000150084e-01, -1.0000027109e-01}, + { 8, {0.087905, 0.214477, 0.129585, 0.123497, 0.203565, 0.038013, 0.079418, 0.123540}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + false, 9.9999948208e-02, 1.0000108238e-01}, + { 8, {0.065556, 0.205009, 0.072071, 0.248115, 0.271915, 0.020009, 0.041420, 0.075906}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, 1.0000063311e-01, 5.0000028120e-01}, + { 8, {0.062190, 0.377944, 0.150886, 0.037271, 0.089038, 0.028696, 0.059569, 0.194406}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, 4.9999979592e-01, -1.0000116306e-01}, + { 8, {0.051015, 0.373210, 0.122129, 0.099580, 0.123213, 0.019694, 0.040570, 0.170589}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, 5.0000032676e-01, 9.9998653307e-02}, + { 8, {0.028666, 0.363741, 0.064615, 0.224199, 0.191563, 0.001690, 0.002572, 0.122955}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, 4.9999863787e-01, 4.9999833178e-01}, + { 8, {0.065556, 0.205009, 0.072071, 0.248115, 0.271915, 0.020009, 0.041420, 0.075906}, + {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, + -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, + true, 1.0000063311e-01, 5.0000028120e-01}, + + + }) +); + +/* UNCRUSTIFY-ON */ From 21f2e13b157e9c0fa1c2d0cd79842a61b4daa51c Mon Sep 17 00:00:00 2001 From: dkachuma Date: Thu, 28 May 2026 16:54:22 -0500 Subject: [PATCH 3/4] Fix test --- .../multifluid/compositional/functions/RachfordRice.hpp | 3 ++- .../constitutive/unitTests/testRachfordRice3Phase.cpp | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp index 07516de3efe..e6d5c5a723b 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/RachfordRice.hpp @@ -344,7 +344,7 @@ struct RachfordRice real64 & v3 ) { // Quick exit for trivial solutions - // Checks if the mixture universally prefers a single phase (e.g., single component). + // Checks if the mixture universally prefers a single phase // This avoids singularities in the Hessian matrix during Newton-Raphson. real64 maxK2 = -LvArray::NumericLimits< real64 >::max; @@ -521,6 +521,7 @@ struct RachfordRice }; } // namespace constitutive + } // namespace geos #endif //GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_COMPOSITIONAL_FUNCTIONS_RACHFORDRICE_HPP_ diff --git a/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp b/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp index 41f0df06c6e..1d50b2c1eb4 100644 --- a/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp +++ b/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp @@ -35,7 +35,7 @@ using RachfordRiceData = std::tuple< real64 const // expected mole fractions of the 3-rd phase >; -class RachfordRice3PhaseFixture : public ::testing::TestWithParam< RachfordRiceData > +class RachfordRice3PhaseFixture : public ::testing::TestWithParam< RachfordRiceData > { static constexpr real64 relTol = 1.0e-5; static constexpr real64 absTol = 1.0e-7; @@ -134,7 +134,7 @@ INSTANTIATE_TEST_SUITE_P( { 3, {0.500000, 0.300000, 0.200000}, { 1.0000000000e+00, 1.0000000000e+00, 1.0000000000e+00, 1.0000000000e+00, 1.0000000000e+00, 1.0000000000e+00}, - false, -1.0000000000e+03, 4.0000000000e+03}, + false, 0.0000000000e+00, 0.0000000000e+00}, { 3, {0.000000, 0.000000, 1.000000}, { 3.3830190000e+00, 1.6804790000e-01, 1.9504870000e+00, 2.2630780000e+00, 8.3155190000e-01, 2.7823120000e-01}, @@ -319,8 +319,6 @@ INSTANTIATE_TEST_SUITE_P( {-2.2814889188e+00, 1.1755562066e+00, -1.3676598100e-01, -9.3677872669e-01, -3.5926177892e+00, -3.5927625099e+00, -4.1802279589e+00, 6.6832724278e-01, -7.8517340846e-01, -1.4342801215e-01, -4.2683565131e+00, 1.4275956340e+00, 6.0279236588e-01, -3.1178288149e+00, -3.3009136757e+00, -3.2914364198e+00}, true, 1.0000063311e-01, 5.0000028120e-01}, - - }) ); From f9ed0c5af349ee1cdbecf1ab0e2b1822744388c9 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Wed, 3 Jun 2026 14:50:40 -0500 Subject: [PATCH 4/4] Some more tests --- .../unitTests/testRachfordRice3Phase.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp b/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp index 1d50b2c1eb4..2f692009c0d 100644 --- a/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp +++ b/src/coreComponents/constitutive/unitTests/testRachfordRice3Phase.cpp @@ -28,8 +28,8 @@ using namespace geos::constitutive; using RachfordRiceData = std::tuple< integer const, // Number of components - std::vector< real64 > const, // composition - std::vector< real64 > const, // log of k-values + stdVector< real64 > const, // composition + stdVector< real64 > const, // log of k-values bool const, // expected success of solve real64 const, // expected mole fractions of the 2-nd phase real64 const // expected mole fractions of the 3-rd phase @@ -140,16 +140,16 @@ INSTANTIATE_TEST_SUITE_P( 2.2630780000e+00, 8.3155190000e-01, 2.7823120000e-01}, true, 1.0000000000e+00, 0.0000000000e+00}, { 3, {0.500000, 0.300000, 0.200000}, - { 5.0000000000e-01, 8.0000000000e-01, 1.0000000000e-01, - 2.0000000000e-01, 4.0000000000e-01, 9.0000000000e-01}, - false, -7.9864728886e+03, 3.1989639312e+04}, + { -6.9314718060e-01, -2.2314355130e-01, -2.3025850930e+00, + -1.6094379124e+00, -9.1629073190e-01, -1.0536051566e-01}, + true, 0.0000000000e+00, 0.0000000000e+00}, { 3, {0.500000, 0.300000, 0.200000}, - { 5.0000000000e+00, 3.0000000000e+00, 4.0000000000e+00, - 2.0000000000e+00, 5.0000000000e-01, 3.5000000000e+00}, + { 1.6094379124e+00, 1.0986122887e+00, 1.3862943611e+00, + 6.9314718056e-01, -6.9314718056e-01, 1.2527629685e+00}, true, 1.0000000000e+00, 0.0000000000e+00}, { 3, {0.500000, 0.300000, 0.200000}, - { 5.0000000000e-01, 4.0000000000e+00, 1.5000000000e+00, - 2.0000000000e+00, 5.0000000000e+00, 3.0000000000e+00}, + { -6.9314718056e-01, 1.3862943611e+00, 4.0546510810e-01, + 6.9314718056e-01, 1.6094379124e+00, 1.0986122887e+00}, true, 0.0000000000e+00, 1.0000000000e+00}, { 3, {0.000000, 0.000000, 1.000000}, { 1.2187684863e+00, -1.7835062893e+00, 6.6807885295e-01,