From e064ae1e178f7306bad841b4356c10aafd344898 Mon Sep 17 00:00:00 2001 From: Dickson Kachuma <81433670+dkachuma@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:36:13 -0600 Subject: [PATCH] Use ComponentProperties in calculation functions (#2799) * Create another copy of CompositionalMultiphaseFluid * Create template parameterised Compositional multiphase fluid * Create phase models * Replace template parameter pack with individual parameters * Rename CompositionalMultiphaseFluidPVT to CompositionalMultiphaseFluidPVTPackage * Lump component molecular weight and component names into ComponentProperties * Implement water phase index * Use ComponentProperties --------- --- .../functions/CompositionalProperties.cpp | 5 + .../functions/CompositionalProperties.hpp | 5 + .../functions/CubicEOSPhaseModel.hpp | 117 ++++++++-------- .../functions/KValueInitialization.hpp | 17 ++- .../functions/NegativeTwoPhaseFlash.hpp | 51 +++---- .../models/NegativeTwoPhaseFlashModel.cpp | 9 +- .../models/NegativeTwoPhaseFlashModel.hpp | 8 +- .../constitutive/unitTests/TestFluid.hpp | 35 +++-- .../unitTests/testCompositionalProperties.cpp | 80 +++++------ .../constitutive/unitTests/testCubicEOS.cpp | 126 +++++++----------- .../unitTests/testKValueInitialization.cpp | 45 ++++--- .../unitTests/testNegativeTwoPhaseFlash.cpp | 20 +-- 12 files changed, 259 insertions(+), 259 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CompositionalProperties.cpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CompositionalProperties.cpp index f56894a0c4a..2f9e760574a 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CompositionalProperties.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CompositionalProperties.cpp @@ -25,6 +25,9 @@ namespace geos namespace constitutive { +namespace compositional +{ + /* * Calculate the molar volume and apply the Peneloux shift parameters. The parameters should be in * dimensional form. @@ -142,6 +145,8 @@ void CompositionalProperties::computeMassDensity( integer const numComps, } } +} // namespace compositional + } // namespace constitutive } // namespace geos diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CompositionalProperties.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CompositionalProperties.hpp index f03b5ef8296..84f886df626 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CompositionalProperties.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CompositionalProperties.hpp @@ -27,6 +27,9 @@ namespace geos namespace constitutive { +namespace compositional +{ + struct CompositionalProperties { public: @@ -122,6 +125,8 @@ struct CompositionalProperties arraySlice1d< real64 > const & dMassDensity_dz ); }; +} //namespace compositional + } // namespace constitutive } // namespace geos diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CubicEOSPhaseModel.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CubicEOSPhaseModel.hpp index 0de0d2c7aca..2cfbaae1dac 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CubicEOSPhaseModel.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/CubicEOSPhaseModel.hpp @@ -21,6 +21,7 @@ #include "common/DataTypes.hpp" #include "constitutive/fluid/multifluid/MultiFluidConstants.hpp" +#include "constitutive/fluid/multifluid/compositional/models/ComponentProperties.hpp" namespace geos { @@ -28,6 +29,9 @@ namespace geos namespace constitutive { +namespace compositional +{ + struct PengRobinsonEOS { static constexpr real64 omegaA = 0.457235529; @@ -44,6 +48,8 @@ struct PengRobinsonEOS ? 0.37464 + 1.54226 * omega - 0.26992 * omega * omega : 0.3796 + 1.485 * omega - 0.164423 * omega * omega + 0.016666 * omega * omega * omega; } + + static constexpr char const * catalogName(){ return "PengRobinson"; } }; struct SoaveRedlichKwongEOS @@ -60,36 +66,38 @@ struct SoaveRedlichKwongEOS { return 0.480 + 1.574 * omega - 0.176 * omega * omega; } + + static constexpr char const * catalogName(){ return "SoaveRedlichKwong"; } }; template< typename EOS_TYPE > struct CubicEOSPhaseModel { public: + /** + * @brief Generate a catalog name + */ + static constexpr char const * catalogName(){ return EOS_TYPE::catalogName(); } + /** * @brief Main entry point of the cubic EOS model + * @details Computes the logarithm of the fugacity coefficients * @param[in] numComps number of components * @param[in] pressure pressure * @param[in] temperature temperature * @param[in] composition composition of the phase - * @param[in] criticalPressure critical pressures - * @param[in] criticalTemperature critical temperatures - * @param[in] acentricFactor acentric factors - * @param[in] binaryInteractionCoefficients binary coefficients (currently not implemented) + * @param[in] componentProperties The compositional component properties * @param[out] logFugacityCoefficients log of the fugacity coefficients */ GEOS_HOST_DEVICE GEOS_FORCE_INLINE static void - compute( integer const numComps, - real64 const & pressure, - real64 const & temperature, - arrayView1d< real64 const > const composition, - arrayView1d< real64 const > const criticalPressure, - arrayView1d< real64 const > const criticalTemperature, - arrayView1d< real64 const > const acentricFactor, - real64 const & binaryInteractionCoefficients, - arraySlice1d< real64 > const logFugacityCoefficients ); + computeLogFugacityCoefficients( integer const numComps, + real64 const & pressure, + real64 const & temperature, + arrayView1d< real64 const > const composition, + ComponentProperties::KernelWrapper const & componentProperties, + arraySlice1d< real64 > const logFugacityCoefficients ); /** * @brief Compute the mixture coefficients using pressure, temperature, composition and input @@ -97,10 +105,7 @@ struct CubicEOSPhaseModel * @param[in] pressure pressure * @param[in] temperature temperature * @param[in] composition composition of the phase - * @param[in] criticalPressure critical pressures - * @param[in] criticalTemperature critical temperatures - * @param[in] acentricFactor acentric factors - * @param[in] binaryInteractionCoefficients binary coefficients (currently not implemented) + * @param[in] componentProperties The compositional component properties * @param[out] aPureCoefficient pure coefficient (A) * @param[out] bPureCoefficient pure coefficient (B) * @param[out] aMixtureCoefficient mixture coefficient (A) @@ -113,10 +118,7 @@ struct CubicEOSPhaseModel real64 const & pressure, real64 const & temperature, arrayView1d< real64 const > const composition, - arrayView1d< real64 const > const criticalPressure, - arrayView1d< real64 const > const criticalTemperature, - arrayView1d< real64 const > const acentricFactor, - real64 const & binaryInteractionCoefficients, + ComponentProperties::KernelWrapper const & componentProperties, arraySlice1d< real64 > const aPureCoefficient, arraySlice1d< real64 > const bPureCoefficient, real64 & aMixtureCoefficient, @@ -128,10 +130,7 @@ struct CubicEOSPhaseModel * @param[in] pressure pressure * @param[in] temperature temperature * @param[in] composition composition of the phase - * @param[in] criticalPressure critical pressures - * @param[in] criticalTemperature critical temperatures - * @param[in] acentricFactor acentric factors - * @param[in] binaryInteractionCoefficients binary coefficients (currently not implemented) + * @param[in] componentProperties The compositional component properties * @param[in] aPureCoefficient pure coefficient (A) * @param[in] bPureCoefficient pure coefficient (B) * @param[in] aMixtureCoefficient mixture coefficient (A) @@ -151,10 +150,7 @@ struct CubicEOSPhaseModel real64 const & pressure, real64 const & temperature, arrayView1d< real64 const > const composition, - arrayView1d< real64 const > const criticalPressure, - arrayView1d< real64 const > const criticalTemperature, - arrayView1d< real64 const > const acentricFactor, - real64 const & binaryInteractionCoefficients, + ComponentProperties::KernelWrapper const & componentProperties, arraySlice1d< real64 const > const aPureCoefficient, arraySlice1d< real64 const > const bPureCoefficient, real64 const aMixtureCoefficient, @@ -182,7 +178,7 @@ struct CubicEOSPhaseModel static void computeCompressibilityFactor( integer const numComps, arrayView1d< real64 const > const composition, - real64 const & binaryInteractionCoefficients, + arrayView2d< real64 const > const & binaryInteractionCoefficients, arraySlice1d< real64 const > const aPureCoefficient, arraySlice1d< real64 const > const bPureCoefficient, real64 const & aMixtureCoefficient, @@ -240,7 +236,7 @@ struct CubicEOSPhaseModel static void computeLogFugacityCoefficients( integer const numComps, arrayView1d< real64 const > const composition, - real64 const & binaryInteractionCoefficients, + arrayView2d< real64 const > const & binaryInteractionCoefficients, real64 const & compressibilityFactor, arraySlice1d< real64 const > const aPureCoefficient, arraySlice1d< real64 const > const bPureCoefficient, @@ -274,15 +270,12 @@ template< typename EOS_TYPE > GEOS_HOST_DEVICE void CubicEOSPhaseModel< EOS_TYPE >:: -compute( integer const numComps, - real64 const & pressure, - real64 const & temperature, - arrayView1d< real64 const > const composition, - arrayView1d< real64 const > const criticalPressure, - arrayView1d< real64 const > const criticalTemperature, - arrayView1d< real64 const > const acentricFactor, - real64 const & binaryInteractionCoefficients, - arraySlice1d< real64 > const logFugacityCoefficients ) +computeLogFugacityCoefficients( integer const numComps, + real64 const & pressure, + real64 const & temperature, + arrayView1d< real64 const > const composition, + ComponentProperties::KernelWrapper const & componentProperties, + arraySlice1d< real64 > const logFugacityCoefficients ) { // step 0: allocate the stack memory needed for the update stackArray1d< real64, MultiFluidConstants::MAX_NUM_COMPONENTS > aPureCoefficient( numComps ); @@ -291,15 +284,14 @@ compute( integer const numComps, real64 bMixtureCoefficient = 0.0; real64 compressibilityFactor = 0.0; + arrayView2d< real64 const > const & binaryInteractionCoefficients = componentProperties.m_componentBinaryCoeff; + // step 1: compute the mixture coefficients aPureCoefficient, bPureCoefficient, aMixtureCoefficient, bMixtureCoefficient computeMixtureCoefficients( numComps, // number of components pressure, // cell input temperature, composition, - criticalPressure, // user input - criticalTemperature, - acentricFactor, - binaryInteractionCoefficients, + componentProperties, // user input, aPureCoefficient, // output bPureCoefficient, aMixtureCoefficient, @@ -335,15 +327,17 @@ computeMixtureCoefficients( integer const numComps, real64 const & pressure, real64 const & temperature, arrayView1d< real64 const > const composition, - arrayView1d< real64 const > const criticalPressure, - arrayView1d< real64 const > const criticalTemperature, - arrayView1d< real64 const > const acentricFactor, - real64 const & binaryInteractionCoefficients, + ComponentProperties::KernelWrapper const & componentProperties, arraySlice1d< real64 > const aPureCoefficient, arraySlice1d< real64 > const bPureCoefficient, real64 & aMixtureCoefficient, real64 & bMixtureCoefficient ) { + arrayView1d< real64 const > const & criticalPressure = componentProperties.m_componentCriticalPressure; + arrayView1d< real64 const > const & criticalTemperature = componentProperties.m_componentCriticalTemperature; + arrayView1d< real64 const > const & acentricFactor = componentProperties.m_componentAcentricFactor; + arrayView2d< real64 const > const & binaryInteractionCoefficients = componentProperties.m_componentBinaryCoeff; + // mixture coefficients for( integer ic = 0; ic < numComps; ++ic ) { @@ -360,7 +354,7 @@ computeMixtureCoefficients( integer const numComps, { for( integer jc = 0; jc < numComps; ++jc ) { - aMixtureCoefficient += ( composition[ic] * composition[jc] * ( 1.0 - binaryInteractionCoefficients ) * sqrt( aPureCoefficient[ic] * aPureCoefficient[jc] ) ); + aMixtureCoefficient += ( composition[ic] * composition[jc] * ( 1.0 - binaryInteractionCoefficients( ic, jc ) ) * sqrt( aPureCoefficient[ic] * aPureCoefficient[jc] ) ); } bMixtureCoefficient += composition[ic] * bPureCoefficient[ic]; } @@ -374,10 +368,7 @@ computeMixtureCoefficients( integer const numComps, real64 const & pressure, real64 const & temperature, arrayView1d< real64 const > const composition, - arrayView1d< real64 const > const criticalPressure, - arrayView1d< real64 const > const criticalTemperature, - arrayView1d< real64 const > const acentricFactor, - real64 const & binaryInteractionCoefficients, + ComponentProperties::KernelWrapper const & componentProperties, arraySlice1d< real64 const > const aPureCoefficient, arraySlice1d< real64 const > const bPureCoefficient, real64 const aMixtureCoefficient, @@ -389,11 +380,16 @@ computeMixtureCoefficients( integer const numComps, arraySlice1d< real64 > const daMixtureCoefficient_dz, arraySlice1d< real64 > const dbMixtureCoefficient_dz ) { - GEOS_UNUSED_VAR( criticalPressure ); + arrayView1d< real64 const > const & criticalTemperature = componentProperties.m_componentCriticalTemperature; + arrayView1d< real64 const > const & acentricFactor = componentProperties.m_componentAcentricFactor; + arrayView2d< real64 const > const & binaryInteractionCoefficients = componentProperties.m_componentBinaryCoeff; + stackArray1d< real64, MultiFluidConstants::MAX_NUM_COMPONENTS > daPureCoefficient_dx( numComps ); + // Calculate pressure derivatives daMixtureCoefficient_dp = aMixtureCoefficient / pressure; dbMixtureCoefficient_dp = bMixtureCoefficient / pressure; + // Calculate temperature derivatives for( integer ic = 0; ic < numComps; ++ic ) { @@ -404,14 +400,16 @@ computeMixtureCoefficients( integer const numComps, } daMixtureCoefficient_dt = 0.0; dbMixtureCoefficient_dt = -bMixtureCoefficient / temperature; + for( integer ic = 0; ic < numComps; ++ic ) { for( integer jc = 0; jc < numComps; ++jc ) { - real64 const coeff = composition[ic] * composition[jc] * ( 1.0 - binaryInteractionCoefficients ) / sqrt( aPureCoefficient[ic] * aPureCoefficient[jc] ); + real64 const coeff = composition[ic] * composition[jc] * ( 1.0 - binaryInteractionCoefficients( ic, jc ) ) / sqrt( aPureCoefficient[ic] * aPureCoefficient[jc] ); daMixtureCoefficient_dt += 0.5 * coeff * (daPureCoefficient_dx[ic]*aPureCoefficient[jc] + daPureCoefficient_dx[jc]*aPureCoefficient[ic]); } } + // Calculate composition derivatives for( integer ic = 0; ic < numComps; ++ic ) { @@ -422,7 +420,7 @@ computeMixtureCoefficients( integer const numComps, { for( integer jc = 0; jc < numComps; ++jc ) { - real64 const coeff = ( 1.0 - binaryInteractionCoefficients ) * sqrt( aPureCoefficient[ic] * aPureCoefficient[jc] ); + real64 const coeff = ( 1.0 - binaryInteractionCoefficients( ic, jc ) ) * sqrt( aPureCoefficient[ic] * aPureCoefficient[jc] ); daMixtureCoefficient_dz[ic] += coeff * composition[jc]; daMixtureCoefficient_dz[jc] += coeff * composition[ic]; } @@ -436,7 +434,7 @@ void CubicEOSPhaseModel< EOS_TYPE >:: computeCompressibilityFactor( integer const numComps, arrayView1d< real64 const > const composition, - real64 const & binaryInteractionCoefficients, + arrayView2d< real64 const > const & binaryInteractionCoefficients, arraySlice1d< real64 const > const aPureCoefficient, arraySlice1d< real64 const > const bPureCoefficient, real64 const & aMixtureCoefficient, @@ -568,7 +566,7 @@ void CubicEOSPhaseModel< EOS_TYPE >:: computeLogFugacityCoefficients( integer const numComps, arrayView1d< real64 const > const composition, - real64 const & binaryInteractionCoefficients, + arrayView2d< real64 const > const & binaryInteractionCoefficients, real64 const & compressibilityFactor, arraySlice1d< real64 const > const aPureCoefficient, arraySlice1d< real64 const > const bPureCoefficient, @@ -583,7 +581,7 @@ computeLogFugacityCoefficients( integer const numComps, { for( integer jc = 0; jc < numComps; ++jc ) { - ki[ic] += composition[jc] * ( 1.0 - binaryInteractionCoefficients ) * sqrt( aPureCoefficient[ic] * aPureCoefficient[jc] ); + ki[ic] += composition[jc] * ( 1.0 - binaryInteractionCoefficients( ic, jc ) ) * sqrt( aPureCoefficient[ic] * aPureCoefficient[jc] ); } } @@ -646,6 +644,7 @@ solveCubicPolynomial( real64 const & m3, } } +} // namespace compositional } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/KValueInitialization.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/KValueInitialization.hpp index 7d8d45d22d2..0ef7352233e 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/KValueInitialization.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/KValueInitialization.hpp @@ -20,6 +20,7 @@ #define GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_COMPOSITIONAL_FUNCTIONS_KVALUEINITIALIZATION_HPP_ #include "common/DataTypes.hpp" +#include "constitutive/fluid/multifluid/compositional/models/ComponentProperties.hpp" namespace geos { @@ -27,6 +28,9 @@ namespace geos namespace constitutive { +namespace compositional +{ + struct KValueInitialization { public: @@ -35,9 +39,7 @@ struct KValueInitialization * @param[in] numComps number of components * @param[in] pressure pressure * @param[in] temperature temperature - * @param[in] criticalPressure critical pressures - * @param[in] criticalTemperature critical temperatures - * @param[in] acentricFactor acentric factors + * @param[in] componentProperties The compositional component properties * @param[out] kValues the calculated k-values **/ GEOS_HOST_DEVICE @@ -46,11 +48,12 @@ struct KValueInitialization computeWilsonGasLiquidKvalue( integer const numComps, real64 const pressure, real64 const temperature, - arrayView1d< real64 const > const criticalPressure, - arrayView1d< real64 const > const criticalTemperature, - arrayView1d< real64 const > const acentricFactor, + ComponentProperties::KernelWrapper const & componentProperties, arraySlice1d< real64 > const kValues ) { + arrayView1d< real64 const > const & criticalPressure = componentProperties.m_componentCriticalPressure; + arrayView1d< real64 const > const & criticalTemperature = componentProperties.m_componentCriticalTemperature; + arrayView1d< real64 const > const & acentricFactor = componentProperties.m_componentAcentricFactor; for( integer ic = 0; ic < numComps; ++ic ) { real64 const pr = criticalPressure[ic] / pressure; @@ -76,6 +79,8 @@ struct KValueInitialization }; +} // namespace compositional + } // namespace constitutive } // namespace geos diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/NegativeTwoPhaseFlash.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/NegativeTwoPhaseFlash.hpp index 11392c4fec0..7cd8e9508cf 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/NegativeTwoPhaseFlash.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/functions/NegativeTwoPhaseFlash.hpp @@ -20,10 +20,10 @@ #define GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_COMPOSITIONAL_FUNCTIONS_NEGATIVETWOPHASEFLASH_HPP_ #include "common/DataTypes.hpp" -#include "CubicEOSPhaseModel.hpp" #include "RachfordRice.hpp" #include "KValueInitialization.hpp" #include "constitutive/fluid/multifluid/MultiFluidConstants.hpp" +#include "constitutive/fluid/multifluid/compositional/models/ComponentProperties.hpp" namespace geos { @@ -31,6 +31,9 @@ namespace geos namespace constitutive { +namespace compositional +{ + struct NegativeTwoPhaseFlash { public: @@ -40,10 +43,7 @@ struct NegativeTwoPhaseFlash * @param[in] pressure pressure * @param[in] temperature temperature * @param[in] composition composition of the mixture - * @param[in] criticalPressure critical pressures - * @param[in] criticalTemperature critical temperatures - * @param[in] acentricFactor acentric factors - * @param[in] binaryInteractionCoefficients binary coefficients (currently not implemented) + * @param[in] componentProperties The compositional component properties * @param[out] vapourPhaseMoleFraction the calculated vapour (gas) mole fraction * @param[out] liquidComposition the calculated liquid phase composition * @param[out] vapourComposition the calculated vapour phase composition @@ -55,10 +55,7 @@ struct NegativeTwoPhaseFlash real64 const pressure, real64 const temperature, arrayView1d< real64 const > const composition, - arrayView1d< real64 const > const criticalPressure, - arrayView1d< real64 const > const criticalTemperature, - arrayView1d< real64 const > const acentricFactor, - real64 const & binaryInteractionCoefficients, + ComponentProperties::KernelWrapper const & componentProperties, real64 & vapourPhaseMoleFraction, arrayView1d< real64 > const liquidComposition, arrayView1d< real64 > const vapourComposition ) @@ -91,9 +88,7 @@ struct NegativeTwoPhaseFlash KValueInitialization::computeWilsonGasLiquidKvalue( numComps, pressure, temperature, - criticalPressure, - criticalTemperature, - acentricFactor, + componentProperties, kVapourLiquid ); bool converged = false; @@ -113,24 +108,18 @@ struct NegativeTwoPhaseFlash normalizeComposition( numComps, vapourComposition ); // Compute the phase fugacities - CubicEOSPhaseModel< EOS_TYPE_LIQUID >::compute( numComps, - pressure, - temperature, - liquidComposition, - criticalPressure, - criticalTemperature, - acentricFactor, - binaryInteractionCoefficients, - logLiquidFugacity ); - CubicEOSPhaseModel< EOS_TYPE_VAPOUR >::compute( numComps, - pressure, - temperature, - vapourComposition, - criticalPressure, - criticalTemperature, - acentricFactor, - binaryInteractionCoefficients, - logVapourFugacity ); + EOS_TYPE_LIQUID::computeLogFugacityCoefficients( numComps, + pressure, + temperature, + liquidComposition, + componentProperties, + logLiquidFugacity ); + EOS_TYPE_VAPOUR::computeLogFugacityCoefficients( numComps, + pressure, + temperature, + vapourComposition, + componentProperties, + logVapourFugacity ); // Compute fugacity ratios and check convergence converged = true; @@ -203,6 +192,8 @@ struct NegativeTwoPhaseFlash } }; +} // namespace compositional + } // namespace constitutive } // namespace geos diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.cpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.cpp index 381e6eb13cb..48048202020 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.cpp @@ -26,15 +26,12 @@ namespace constitutive namespace compositional { -template< typename EOS_TYPE > struct EOSCatalogName {}; -template<> struct EOSCatalogName< PengRobinsonEOS > { static constexpr char const * catalogName() { return "PengRobinson"; } }; -template<> struct EOSCatalogName< SoaveRedlichKwongEOS > { static constexpr char const * catalogName() { return "SoaveRedlichKwong"; } }; // Naming conventions template< typename EOS_TYPE_LIQUID, typename EOS_TYPE_VAPOUR > string NegativeTwoPhaseFlashModel< EOS_TYPE_LIQUID, EOS_TYPE_VAPOUR >::catalogName() { - return EOSCatalogName< EOS_TYPE_LIQUID >::catalogName(); + return EOS_TYPE_LIQUID::catalogName(); } template< typename EOS_TYPE_LIQUID, typename EOS_TYPE_VAPOUR > @@ -58,8 +55,8 @@ NegativeTwoPhaseFlashModelUpdate( integer const numComponents ): {} // Explicit instantiation of the model template. -template class NegativeTwoPhaseFlashModel< PengRobinsonEOS, PengRobinsonEOS >; -template class NegativeTwoPhaseFlashModel< SoaveRedlichKwongEOS, SoaveRedlichKwongEOS >; +template class NegativeTwoPhaseFlashModel< CubicEOSPhaseModel< PengRobinsonEOS >, CubicEOSPhaseModel< PengRobinsonEOS > >; +template class NegativeTwoPhaseFlashModel< CubicEOSPhaseModel< SoaveRedlichKwongEOS >, CubicEOSPhaseModel< SoaveRedlichKwongEOS > >; } // end namespace compositional diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.hpp index b0e8165856e..e9d6d17ef6c 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.hpp @@ -122,8 +122,12 @@ class NegativeTwoPhaseFlashModel : public FunctionBase KernelWrapper createKernelWrapper() const; }; -using NegativeTwoPhaseFlashPRPR = NegativeTwoPhaseFlashModel< PengRobinsonEOS, PengRobinsonEOS >; -using NegativeTwoPhaseFlashSRKSRK = NegativeTwoPhaseFlashModel< SoaveRedlichKwongEOS, SoaveRedlichKwongEOS >; +using NegativeTwoPhaseFlashPRPR = NegativeTwoPhaseFlashModel< + CubicEOSPhaseModel< PengRobinsonEOS >, + CubicEOSPhaseModel< PengRobinsonEOS > >; +using NegativeTwoPhaseFlashSRKSRK = NegativeTwoPhaseFlashModel< + CubicEOSPhaseModel< SoaveRedlichKwongEOS >, + CubicEOSPhaseModel< SoaveRedlichKwongEOS > >; } // end namespace compositional diff --git a/src/coreComponents/constitutive/unitTests/TestFluid.hpp b/src/coreComponents/constitutive/unitTests/TestFluid.hpp index 11d4bb34020..e9f2f1fbf76 100644 --- a/src/coreComponents/constitutive/unitTests/TestFluid.hpp +++ b/src/coreComponents/constitutive/unitTests/TestFluid.hpp @@ -20,6 +20,7 @@ #define GEOS_CONSTITUTIVE_UNITTESTS_TESTFLUID_HPP_ #include "common/DataTypes.hpp" +#include "constitutive/fluid/multifluid/compositional/models/ComponentProperties.hpp" namespace geos { @@ -45,11 +46,12 @@ struct Fluid static constexpr integer Pc = 0; static constexpr integer Tc = 1; - static constexpr integer Ac = 2; - static constexpr integer Mw = 3; - static constexpr integer Vs = 4; + static constexpr integer Vc = 2; + static constexpr integer Ac = 3; + static constexpr integer Mw = 4; + static constexpr integer Vs = 5; - static std::array< real64, 55 > data; + static std::array< real64, 66 > data; }; template< int NC > @@ -66,18 +68,25 @@ class TestFluid std::unique_ptr< TestFluid< NC > > testFluid( new TestFluid() ); createArray( testFluid->criticalPressure, components, Fluid::Pc, Fluid::data ); createArray( testFluid->criticalTemperature, components, Fluid::Tc, Fluid::data ); + createArray( testFluid->criticalVolume, components, Fluid::Vc, Fluid::data ); createArray( testFluid->acentricFactor, components, Fluid::Ac, Fluid::data ); createArray( testFluid->molecularWeight, components, Fluid::Mw, Fluid::data ); createArray( testFluid->volumeShift, components, Fluid::Vs, Fluid::data ); + testFluid->binaryCoeff.resize( NC, NC ); return testFluid; } - arrayView1d< real64 const > const getCriticalPressure() const { return criticalPressure.toViewConst(); } - arrayView1d< real64 const > const getCriticalTemperature() const { return criticalTemperature.toViewConst(); } - arrayView1d< real64 const > const getCriticalVolume() const { return criticalVolume.toViewConst(); } - arrayView1d< real64 const > const getAcentricFactor() const { return acentricFactor.toViewConst(); } - arrayView1d< real64 const > const getMolecularWeight() const { return molecularWeight.toViewConst(); } - arrayView1d< real64 const > const getVolumeShift() const { return volumeShift.toViewConst(); } + constitutive::compositional::ComponentProperties::KernelWrapper createKernelWrapper() const + { + return constitutive::compositional::ComponentProperties::KernelWrapper( + molecularWeight, + criticalPressure, + criticalTemperature, + criticalVolume, + acentricFactor, + volumeShift, + binaryCoeff ); + } private: TestFluid() = default; @@ -88,6 +97,7 @@ class TestFluid array1d< real64 > acentricFactor; array1d< real64 > molecularWeight; array1d< real64 > volumeShift; + array2d< real64 > binaryCoeff; private: template< typename ARRAY, typename LIST, typename DATAARRAY > @@ -109,13 +119,16 @@ class TestFluid } }; -std::array< real64, 55 > Fluid::data = { +std::array< real64, 66 > Fluid::data = { // -- Pc 2.2050e+07, 7.3750e+06, 3.4000e+06, 8.9630e+06, 1.2960e+06, 4.8721e+06, 4.2481e+06, 3.6400e+06, 4.5990e+06, 2.5300e+06, 1.4600e+06, // -- Tc 6.4700e+02, 3.0410e+02, 1.2620e+02, 3.7353e+02, 3.3150e+01, 3.0532e+02, 3.6983e+02, 4.0785e+02, 1.9060e+02, 6.2200e+02, 7.8200e+02, + // -- Vc + 6.4920e-05, 9.1025e-05, 8.1615e-05, 9.2053e-05, 5.5585e-05, 1.3810e-04, + 1.9170e-04, 2.4649e-04, 9.1302e-05, 5.3923e-04, 1.1664e-03, // -- Ac 3.4400e-01, 2.3900e-01, 4.0000e-02, 9.4200e-02, -2.1900e-01, 9.9500e-02, 1.5230e-01, 1.8440e-01, 1.1400e-02, 4.4300e-01, 8.1600e-01, diff --git a/src/coreComponents/constitutive/unitTests/testCompositionalProperties.cpp b/src/coreComponents/constitutive/unitTests/testCompositionalProperties.cpp index 3680bfe236c..c41428ed2da 100644 --- a/src/coreComponents/constitutive/unitTests/testCompositionalProperties.cpp +++ b/src/coreComponents/constitutive/unitTests/testCompositionalProperties.cpp @@ -18,6 +18,8 @@ #include "TestFluid.hpp" #include "TestFluidUtilities.hpp" +using namespace geos::constitutive::compositional; + namespace geos { namespace testing @@ -195,11 +197,9 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar real64 computeMolarDensity( real64 const pressure, real64 const temperature, arrayView1d< real64 const > const & composition ) const { - auto criticalPressure = m_fluid->getCriticalPressure(); - auto criticalTemperature = m_fluid->getCriticalTemperature(); - auto acentricFactor = m_fluid->getAcentricFactor(); - auto volumeShift = m_fluid->getVolumeShift(); - real64 const binaryInteractionCoefficients = 0.0; + auto const componentProperties = this->m_fluid->createKernelWrapper(); + auto const binaryInteractionCoefficients = componentProperties.m_componentBinaryCoeff; + auto const volumeShift = componentProperties.m_componentVolumeShift; real64 compressibilityFactor = 0.0; real64 molarDensity = 0.0; @@ -208,21 +208,18 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar real64 aMixtureCoefficient = 0.0; real64 bMixtureCoefficient = 0.0; - constitutive::CubicEOSPhaseModel< EOS_TYPE >:: + CubicEOSPhaseModel< EOS_TYPE >:: computeMixtureCoefficients( numComps, pressure, temperature, composition, - criticalPressure, - criticalTemperature, - acentricFactor, - binaryInteractionCoefficients, + componentProperties, aPureCoefficient, bPureCoefficient, aMixtureCoefficient, bMixtureCoefficient ); - constitutive::CubicEOSPhaseModel< EOS_TYPE >:: + CubicEOSPhaseModel< EOS_TYPE >:: computeCompressibilityFactor( numComps, composition, binaryInteractionCoefficients, @@ -232,13 +229,13 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar bMixtureCoefficient, compressibilityFactor ); - constitutive::CompositionalProperties::computeMolarDensity( numComps, - pressure, - temperature, - composition, - volumeShift, - compressibilityFactor, - molarDensity ); + CompositionalProperties::computeMolarDensity( numComps, + pressure, + temperature, + composition, + volumeShift, + compressibilityFactor, + molarDensity ); return molarDensity; } @@ -249,11 +246,9 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar real64 & dMolarDensity_dt, arraySlice1d< real64 > const dMolarDensity_dz ) const { - auto criticalPressure = m_fluid->getCriticalPressure(); - auto criticalTemperature = m_fluid->getCriticalTemperature(); - auto acentricFactor = m_fluid->getAcentricFactor(); - auto volumeShift = m_fluid->getVolumeShift(); - real64 const binaryInteractionCoefficients = 0.0; + auto const componentProperties = this->m_fluid->createKernelWrapper(); + auto const binaryInteractionCoefficients = componentProperties.m_componentBinaryCoeff; + auto const volumeShift = componentProperties.m_componentVolumeShift; real64 compressibilityFactor = 0.0; array1d< real64 > aPureCoefficient( numComps ); @@ -261,15 +256,12 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar real64 aMixtureCoefficient = 0.0; real64 bMixtureCoefficient = 0.0; - constitutive::CubicEOSPhaseModel< EOS_TYPE >:: + CubicEOSPhaseModel< EOS_TYPE >:: computeMixtureCoefficients( numComps, pressure, temperature, composition, - criticalPressure, - criticalTemperature, - acentricFactor, - binaryInteractionCoefficients, + componentProperties, aPureCoefficient, bPureCoefficient, aMixtureCoefficient, @@ -282,15 +274,12 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar array1d< real64 > daMixtureCoefficient_dz( numComps ); array1d< real64 > dbMixtureCoefficient_dz( numComps ); - constitutive::CubicEOSPhaseModel< EOS_TYPE >:: + CubicEOSPhaseModel< EOS_TYPE >:: computeMixtureCoefficients( numComps, pressure, temperature, composition, - criticalPressure, - criticalTemperature, - acentricFactor, - binaryInteractionCoefficients, + componentProperties, aPureCoefficient, bPureCoefficient, aMixtureCoefficient, @@ -302,7 +291,7 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar daMixtureCoefficient_dz, dbMixtureCoefficient_dz ); - constitutive::CubicEOSPhaseModel< EOS_TYPE >:: + CubicEOSPhaseModel< EOS_TYPE >:: computeCompressibilityFactor( numComps, composition, binaryInteractionCoefficients, @@ -316,7 +305,7 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar real64 dCompressibilityFactor_dt = 0.0; array1d< real64 > dCompressibilityFactor_dz( numComps ); - constitutive::CubicEOSPhaseModel< EOS_TYPE >:: + CubicEOSPhaseModel< EOS_TYPE >:: computeCompressibilityFactor( numComps, aMixtureCoefficient, bMixtureCoefficient, @@ -331,7 +320,7 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar dCompressibilityFactor_dt, dCompressibilityFactor_dz ); - constitutive::CompositionalProperties:: + CompositionalProperties:: computeMolarDensity( numComps, pressure, temperature, @@ -340,7 +329,7 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar compressibilityFactor, molarDensity ); - constitutive::CompositionalProperties:: + CompositionalProperties:: computeMolarDensity( numComps, pressure, temperature, @@ -359,11 +348,12 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar real64 computeMassDensity( real64 const pressure, real64 const temperature, arrayView1d< real64 const > const & composition ) const { - auto molecularWeight = m_fluid->getMolecularWeight(); + auto const componentProperties = this->m_fluid->createKernelWrapper(); + auto const molecularWeight = componentProperties.m_componentMolarWeight; real64 const molarDensity = computeMolarDensity( pressure, temperature, composition ); real64 massDensity = 0.0; - constitutive::CompositionalProperties:: + CompositionalProperties:: computeMassDensity( numComps, composition, molecularWeight, @@ -379,7 +369,9 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar real64 & dMassDensity_dt, arraySlice1d< real64 > const dMassDensity_dz ) const { - auto molecularWeight = m_fluid->getMolecularWeight(); + auto const componentProperties = this->m_fluid->createKernelWrapper(); + auto const molecularWeight = componentProperties.m_componentMolarWeight; + massDensity = computeMassDensity( pressure, temperature, composition ); real64 molarDensity = 0.0; @@ -393,7 +385,7 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar dMolarDensity_dt, dMolarDensity_dz ); - constitutive::CompositionalProperties:: + CompositionalProperties:: computeMassDensity( numComps, molecularWeight, molarDensity, @@ -410,7 +402,7 @@ class CompositionalPropertiesTestDataTestFixture : public ::testing::TestWithPar std::unique_ptr< TestFluid< NC > > m_fluid; }; -using PR4Comp = CompositionalPropertiesTestDataTestFixture< constitutive::PengRobinsonEOS, 4 >; +using PR4Comp = CompositionalPropertiesTestDataTestFixture< PengRobinsonEOS, 4 >; TEST_P( PR4Comp, testMolarDensity ) { @@ -435,7 +427,7 @@ TEST_P( PR4Comp, testMassDensityDerivative ) // Test data generated from PVT package // All compositions are single phase template<> -std::vector< CompositionalPropertiesTestData< 4 > > generateTestData< constitutive::PengRobinsonEOS, 4 >() +std::vector< CompositionalPropertiesTestData< 4 > > generateTestData< PengRobinsonEOS, 4 >() { return { { 1.000000e+05, 2.771500e+02, { 0.000000, 0.495099, 0.495118, 0.009783 }, 3.733061e+03, 1.271768e+02, 4.747588e+05 }, @@ -510,7 +502,7 @@ std::vector< CompositionalPropertiesTestData< 4 > > generateTestData< constituti INSTANTIATE_TEST_SUITE_P( CompositionalPropertiesTest, PR4Comp, - ::testing::ValuesIn( generateTestData< constitutive::PengRobinsonEOS, 4 >()) + ::testing::ValuesIn( generateTestData< PengRobinsonEOS, 4 >()) ); } // testing diff --git a/src/coreComponents/constitutive/unitTests/testCubicEOS.cpp b/src/coreComponents/constitutive/unitTests/testCubicEOS.cpp index 036927a0b97..e453e225787 100644 --- a/src/coreComponents/constitutive/unitTests/testCubicEOS.cpp +++ b/src/coreComponents/constitutive/unitTests/testCubicEOS.cpp @@ -23,7 +23,7 @@ using namespace geos; using namespace geos::testing; -using namespace geos::constitutive; +using namespace geos::constitutive::compositional; static constexpr real64 relTol = 1.0e-5; @@ -33,10 +33,7 @@ TEST( CubicEOSTest, testCubicEOSTwoComponentsSRK ) auto fluid = TestFluid< numComps >::create( {Fluid::C1, Fluid::C5} ); - auto criticalPressure = fluid->getCriticalPressure(); - auto criticalTemperature = fluid->getCriticalTemperature(); - auto omega = fluid->getAcentricFactor(); - real64 binaryInteractionCoefficients = 0.0; // not implemented yet + auto componentProperties = fluid->createKernelWrapper(); real64 pressure = 0.0; real64 temperature = 0.0; @@ -55,10 +52,10 @@ TEST( CubicEOSTest, testCubicEOSTwoComponentsSRK ) expectedLogFugacityCoefficients[1] = -0.00820777; CubicEOSPhaseModel< SoaveRedlichKwongEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -74,10 +71,10 @@ TEST( CubicEOSTest, testCubicEOSTwoComponentsSRK ) expectedLogFugacityCoefficients[1] = -0.0701117; CubicEOSPhaseModel< SoaveRedlichKwongEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -93,10 +90,10 @@ TEST( CubicEOSTest, testCubicEOSTwoComponentsSRK ) expectedLogFugacityCoefficients[1] = -0.00589892; CubicEOSPhaseModel< SoaveRedlichKwongEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -112,10 +109,10 @@ TEST( CubicEOSTest, testCubicEOSTwoComponentsSRK ) expectedLogFugacityCoefficients[1] = -0.00629384; CubicEOSPhaseModel< SoaveRedlichKwongEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -128,10 +125,7 @@ TEST( CubicEOSTest, testCubicEOSFourComponentsPR ) auto fluid = TestFluid< numComps >::create( {Fluid::N2, Fluid::C8, Fluid::C10, Fluid::H2O} ); - auto criticalPressure = fluid->getCriticalPressure(); - auto criticalTemperature = fluid->getCriticalTemperature(); - auto omega = fluid->getAcentricFactor(); - real64 binaryInteractionCoefficients = 0.0; // not implemented yet + auto componentProperties = fluid->createKernelWrapper(); real64 pressure = 0.0; real64 temperature = 0.0; @@ -154,10 +148,10 @@ TEST( CubicEOSTest, testCubicEOSFourComponentsPR ) expectedLogFugacityCoefficients[3] = -5.33003; CubicEOSPhaseModel< PengRobinsonEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -179,10 +173,10 @@ TEST( CubicEOSTest, testCubicEOSFourComponentsPR ) expectedLogFugacityCoefficients[3] = 0.361984; CubicEOSPhaseModel< PengRobinsonEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -204,10 +198,10 @@ TEST( CubicEOSTest, testCubicEOSFourComponentsPR ) expectedLogFugacityCoefficients[3] = -3.42481; CubicEOSPhaseModel< PengRobinsonEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -222,10 +216,7 @@ TEST( CubicEOSTest, testCubicEOSFourComponentsSRK ) auto fluid = TestFluid< numComps >::create( {Fluid::N2, Fluid::C8, Fluid::C10, Fluid::H2O} ); - auto criticalPressure = fluid->getCriticalPressure(); - auto criticalTemperature = fluid->getCriticalTemperature(); - auto omega = fluid->getAcentricFactor(); - real64 binaryInteractionCoefficients = 0.0; // not implemented yet + auto componentProperties = fluid->createKernelWrapper(); real64 pressure = 0.0; real64 temperature = 0.0; @@ -248,10 +239,10 @@ TEST( CubicEOSTest, testCubicEOSFourComponentsSRK ) expectedLogFugacityCoefficients[3] = -0.618972; CubicEOSPhaseModel< SoaveRedlichKwongEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -273,10 +264,10 @@ TEST( CubicEOSTest, testCubicEOSFourComponentsSRK ) expectedLogFugacityCoefficients[3] = -0.00664411; CubicEOSPhaseModel< SoaveRedlichKwongEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -298,10 +289,10 @@ TEST( CubicEOSTest, testCubicEOSFourComponentsSRK ) expectedLogFugacityCoefficients[3] = -2.69792; CubicEOSPhaseModel< SoaveRedlichKwongEOS >:: - compute( numComps, - pressure, temperature, composition, - criticalPressure, criticalTemperature, omega, binaryInteractionCoefficients, - logFugacityCoefficients ); + computeLogFugacityCoefficients( numComps, + pressure, temperature, composition, + componentProperties, + logFugacityCoefficients ); checkRelativeError( logFugacityCoefficients[0], expectedLogFugacityCoefficients[0], relTol ); checkRelativeError( logFugacityCoefficients[1], expectedLogFugacityCoefficients[1], relTol ); @@ -397,11 +388,7 @@ class MixCoeffDerivativeTestFixture : public DerivativeTestFixture< EOS, NC > public: void testNumericalDerivatives( ParamType const & testData ) const { - auto const & fluid = *this->m_fluid; - auto criticalPressure = fluid.getCriticalPressure(); - auto criticalTemperature = fluid.getCriticalTemperature(); - auto omega = fluid.getAcentricFactor(); - real64 constexpr binaryInteractionCoefficients = 0.0; // not implemented yet + auto componentProperties = this->m_fluid->createKernelWrapper(); array1d< real64 > aPureCoefficient( numComps ); array1d< real64 > bPureCoefficient( numComps ); @@ -424,8 +411,7 @@ class MixCoeffDerivativeTestFixture : public DerivativeTestFixture< EOS, NC > CubicEOSPhaseModel< EOS >::computeMixtureCoefficients( numComps, p, t, zmf, - criticalPressure, criticalTemperature, omega, - binaryInteractionCoefficients, + componentProperties, aPureCoefficient, bPureCoefficient, a, b @@ -442,10 +428,7 @@ class MixCoeffDerivativeTestFixture : public DerivativeTestFixture< EOS, NC > pressure, temperature, composition, - criticalPressure, - criticalTemperature, - omega, - binaryInteractionCoefficients, + componentProperties, aPureCoefficient, bPureCoefficient, aMixtureCoefficient, @@ -564,11 +547,8 @@ class CompressibilityDerivativeTestFixture : public DerivativeTestFixture< EOS, public: void testNumericalDerivatives( ParamType const & testData ) const { - auto const & fluid = *this->m_fluid; - auto criticalPressure = fluid.getCriticalPressure(); - auto criticalTemperature = fluid.getCriticalTemperature(); - auto omega = fluid.getAcentricFactor(); - real64 constexpr binaryInteractionCoefficients = 0.0; // not implemented yet + auto const componentProperties = this->m_fluid->createKernelWrapper(); + auto const binaryInteractionCoefficients = componentProperties.m_componentBinaryCoeff; array1d< real64 > aPureCoefficient( numComps ); array1d< real64 > bPureCoefficient( numComps ); @@ -595,8 +575,7 @@ class CompressibilityDerivativeTestFixture : public DerivativeTestFixture< EOS, CubicEOSPhaseModel< EOS >::computeMixtureCoefficients( numComps, p, t, zmf, - criticalPressure, criticalTemperature, omega, - binaryInteractionCoefficients, + componentProperties, aPureCoefficient, bPureCoefficient, aMixtureCoefficient, bMixtureCoefficient @@ -622,10 +601,7 @@ class CompressibilityDerivativeTestFixture : public DerivativeTestFixture< EOS, pressure, temperature, composition, - criticalPressure, - criticalTemperature, - omega, - binaryInteractionCoefficients, + componentProperties, aPureCoefficient, bPureCoefficient, aMixtureCoefficient, diff --git a/src/coreComponents/constitutive/unitTests/testKValueInitialization.cpp b/src/coreComponents/constitutive/unitTests/testKValueInitialization.cpp index 1e03c31ff8f..de5548fd714 100644 --- a/src/coreComponents/constitutive/unitTests/testKValueInitialization.cpp +++ b/src/coreComponents/constitutive/unitTests/testKValueInitialization.cpp @@ -20,6 +20,8 @@ // TPL includes #include +using namespace geos::constitutive::compositional; + namespace geos { namespace testing @@ -49,21 +51,18 @@ class WilsonKValueInitializationTestFixture : void testKValues() { - real64 const pressure = std::get< 0 >( GetParam()); - real64 const temperature = std::get< 1 >( GetParam()); - integer const compIndex = std::get< 2 >( GetParam()); - real64 const expectedKValue = std::get< 3 >( GetParam()); + real64 const pressure = std::get< 0 >( GetParam() ); + real64 const temperature = std::get< 1 >( GetParam() ); + integer const compIndex = std::get< 2 >( GetParam() ); + real64 const expectedKValue = std::get< 3 >( GetParam() ); array1d< real64 > kValues( numComps ); - constitutive::KValueInitialization:: - computeWilsonGasLiquidKvalue( numComps, - pressure, - temperature, - criticalPressure, - criticalTemperature, - acentricFactor, - kValues ); + KValueInitialization::computeWilsonGasLiquidKvalue( numComps, + pressure, + temperature, + createKernelWrapper(), + kValues ); ASSERT_EQ( kValues.size(), NC ); checkRelativeError( expectedKValue, kValues[compIndex], relTol ); @@ -78,11 +77,25 @@ class WilsonKValueInitializationTestFixture : } } + ComponentProperties::KernelWrapper createKernelWrapper() const + { + return ComponentProperties::KernelWrapper( + discarded, + criticalPressure, + criticalTemperature, + discarded, + acentricFactor, + discarded, + discarded2d ); + } + protected: const integer numComps; array1d< real64 > criticalPressure; array1d< real64 > criticalTemperature; array1d< real64 > acentricFactor; + array1d< real64 > discarded; + array2d< real64 > discarded2d; }; class WilsonKValues2CompFixture : public WilsonKValueInitializationTestFixture< 2 > @@ -182,11 +195,11 @@ class GasWaterKValueInitializationTestFixture : void testKValues() { - real64 const pressure = std::get< 0 >( GetParam()); - real64 const temperature = std::get< 1 >( GetParam()); - real64 const expectedKValue = std::get< 2 >( GetParam()); + real64 const pressure = std::get< 0 >( GetParam() ); + real64 const temperature = std::get< 1 >( GetParam() ); + real64 const expectedKValue = std::get< 2 >( GetParam() ); - real64 calculatedKValue = constitutive::KValueInitialization::computeWaterGasKvalue( pressure, temperature ); + real64 calculatedKValue = KValueInitialization::computeWaterGasKvalue( pressure, temperature ); checkRelativeError( expectedKValue, calculatedKValue, relTol ); } }; diff --git a/src/coreComponents/constitutive/unitTests/testNegativeTwoPhaseFlash.cpp b/src/coreComponents/constitutive/unitTests/testNegativeTwoPhaseFlash.cpp index d9b52111ee0..bfc074c578d 100644 --- a/src/coreComponents/constitutive/unitTests/testNegativeTwoPhaseFlash.cpp +++ b/src/coreComponents/constitutive/unitTests/testNegativeTwoPhaseFlash.cpp @@ -18,6 +18,8 @@ #include "constitutive/fluid/multifluid/compositional/functions/CubicEOSPhaseModel.hpp" #include "TestFluid.hpp" +using namespace geos::constitutive::compositional; + namespace geos { namespace testing @@ -71,6 +73,8 @@ class NegativeTwoPhaseFlashTestFixture : public ::testing::TestWithParam< Flash void testFlash( FlashData< NC > const & data ) { + auto componentProperties = this->m_fluid->createKernelWrapper(); + real64 const pressure = std::get< 0 >( data ); real64 const temperature = std::get< 1 >( data ); array1d< real64 > composition; @@ -88,15 +92,12 @@ class NegativeTwoPhaseFlashTestFixture : public ::testing::TestWithParam< Flash array1d< real64 > liquidComposition( numComps ); array1d< real64 > vapourComposition( numComps ); - bool status = constitutive::NegativeTwoPhaseFlash::compute< EOS_TYPE, EOS_TYPE >( + bool status = NegativeTwoPhaseFlash::compute< EOS_TYPE, EOS_TYPE >( numComps, pressure, temperature, composition, - m_fluid->getCriticalPressure(), - m_fluid->getCriticalTemperature(), - m_fluid->getAcentricFactor(), - binaryInteractionCoefficients, + componentProperties, vapourFraction, liquidComposition, vapourComposition ); @@ -132,14 +133,13 @@ class NegativeTwoPhaseFlashTestFixture : public ::testing::TestWithParam< Flash } protected: - real64 const binaryInteractionCoefficients{0.0}; std::unique_ptr< TestFluid< NC > > m_fluid{}; }; -using NegativeTwoPhaseFlash2CompPR = NegativeTwoPhaseFlashTestFixture< 2, constitutive::PengRobinsonEOS >; -using NegativeTwoPhaseFlash2CompSRK = NegativeTwoPhaseFlashTestFixture< 2, constitutive::SoaveRedlichKwongEOS >; -using NegativeTwoPhaseFlash4CompPR = NegativeTwoPhaseFlashTestFixture< 4, constitutive::PengRobinsonEOS >; -using NegativeTwoPhaseFlash4CompSRK = NegativeTwoPhaseFlashTestFixture< 4, constitutive::SoaveRedlichKwongEOS >; +using NegativeTwoPhaseFlash2CompPR = NegativeTwoPhaseFlashTestFixture< 2, CubicEOSPhaseModel< PengRobinsonEOS > >; +using NegativeTwoPhaseFlash2CompSRK = NegativeTwoPhaseFlashTestFixture< 2, CubicEOSPhaseModel< SoaveRedlichKwongEOS > >; +using NegativeTwoPhaseFlash4CompPR = NegativeTwoPhaseFlashTestFixture< 4, CubicEOSPhaseModel< PengRobinsonEOS > >; +using NegativeTwoPhaseFlash4CompSRK = NegativeTwoPhaseFlashTestFixture< 4, CubicEOSPhaseModel< SoaveRedlichKwongEOS > >; TEST_P( NegativeTwoPhaseFlash2CompPR, testNegativeFlash ) {