From acf0be6df261c440fc379085313b93f9bce25716 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Mon, 31 Jan 2022 18:39:04 -0800 Subject: [PATCH 1/7] modified the CO2-brine model to support thermal simulation --- .../constitutive/CMakeLists.txt | 7 +- .../constitutive/fluid/BlackOilFluid.cpp | 6 + .../constitutive/fluid/BlackOilFluid.hpp | 26 +- .../constitutive/fluid/BlackOilFluidBase.cpp | 4 + .../constitutive/fluid/BlackOilFluidBase.hpp | 2 + .../constitutive/fluid/CO2BrineFluid.cpp | 437 ++++++++++++++++++ ...tiComponentFluid.hpp => CO2BrineFluid.hpp} | 367 ++++++++++----- .../fluid/CompositionalMultiphaseFluid.cpp | 6 + .../fluid/CompositionalMultiphaseFluid.hpp | 14 + .../constitutive/fluid/DeadOilFluid.cpp | 6 + .../constitutive/fluid/DeadOilFluid.hpp | 17 +- .../constitutive/fluid/MultiFluidBase.cpp | 51 +- .../constitutive/fluid/MultiFluidBase.hpp | 47 ++ .../fluid/MultiFluidExtrinsicData.hpp | 64 +++ .../fluid/MultiPhaseMultiComponentFluid.cpp | 288 ------------ .../fluid/PVTFunctions/NoOpPVTFunction.hpp | 126 +++++ .../fluid/PVTFunctions/PVTFunctionBase.hpp | 2 +- .../constitutive/fluid/multiFluidSelector.hpp | 2 +- .../CompositionalMultiphaseBaseKernels.hpp | 10 + .../schema/docs/BlackOilFluid_other.rst | 81 ++-- .../docs/CO2BrineEzrokhiFluid_other.rst | 69 +-- .../docs/CO2BrineEzrokhiThermalFluid.rst | 14 + .../CO2BrineEzrokhiThermalFluid_other.rst | 43 ++ .../docs/CO2BrinePhillipsFluid_other.rst | 69 +-- .../docs/CO2BrinePhillipsThermalFluid.rst | 14 + .../CO2BrinePhillipsThermalFluid_other.rst | 43 ++ .../CompositionalMultiphaseFluid_other.rst | 69 +-- .../schema/docs/Constitutive.rst | 2 + .../schema/docs/Constitutive_other.rst | 2 + .../schema/docs/DeadOilFluid_other.rst | 79 ++-- .../schema/docs/domain_other.rst | 1 - src/coreComponents/schema/schema.xsd | 30 ++ src/coreComponents/schema/schema.xsd.other | 255 +++++++++- .../constitutiveTests/testMultiFluid.cpp | 20 + src/docs/sphinx/CompleteXMLSchema.rst | 42 +- 35 files changed, 1699 insertions(+), 616 deletions(-) create mode 100644 src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp rename src/coreComponents/constitutive/fluid/{MultiPhaseMultiComponentFluid.hpp => CO2BrineFluid.hpp} (65%) delete mode 100644 src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/NoOpPVTFunction.hpp create mode 100644 src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid.rst create mode 100644 src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst create mode 100644 src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid.rst create mode 100644 src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst diff --git a/src/coreComponents/constitutive/CMakeLists.txt b/src/coreComponents/constitutive/CMakeLists.txt index 6ff413f4d70..794ac5f365c 100644 --- a/src/coreComponents/constitutive/CMakeLists.txt +++ b/src/coreComponents/constitutive/CMakeLists.txt @@ -24,11 +24,11 @@ set( constitutive_headers fluid/BlackOilFluidBase.hpp fluid/BlackOilFluid.hpp fluid/CompressibleSinglePhaseFluid.hpp + fluid/CO2BrineFluid.hpp fluid/DeadOilFluid.hpp fluid/MultiFluidBase.hpp fluid/MultiFluidUtils.hpp fluid/MultiFluidExtrinsicData.hpp - fluid/MultiPhaseMultiComponentFluid.hpp fluid/PVTDriver.hpp fluid/PVTOData.hpp fluid/PVTFunctions/PhillipsBrineDensity.hpp @@ -38,7 +38,8 @@ set( constitutive_headers fluid/PVTFunctions/CO2Solubility.hpp fluid/PVTFunctions/FenghourCO2Viscosity.hpp fluid/PVTFunctions/FlashModelBase.hpp - fluid/PVTFunctions/PVTFunctionBase.hpp + fluid/PVTFunctions/PVTFunctionBase.hpp + fluid/PVTFunctions/NoOpPVTFunction.hpp fluid/PVTFunctions/PVTFunctionHelpers.hpp fluid/PVTFunctions/SpanWagnerCO2Density.hpp fluid/PVTFunctions/BrineEnthalpy.hpp @@ -128,11 +129,11 @@ set( constitutive_sources contact/CoulombContact.cpp contact/FrictionlessContact.cpp fluid/CompressibleSinglePhaseFluid.cpp + fluid/CO2BrineFluid.cpp fluid/BlackOilFluidBase.cpp fluid/BlackOilFluid.cpp fluid/DeadOilFluid.cpp fluid/MultiFluidBase.cpp - fluid/MultiPhaseMultiComponentFluid.cpp fluid/PVTDriver.cpp fluid/PVTOData.cpp fluid/PVTFunctions/PhillipsBrineDensity.cpp diff --git a/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp b/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp index dc360b62a3b..b865964fb99 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp @@ -486,6 +486,8 @@ BlackOilFluid::KernelWrapper:: PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ) : BlackOilFluidBase::KernelWrapper( std::move( phaseTypes ), @@ -501,6 +503,8 @@ BlackOilFluid::KernelWrapper:: std::move( phaseDensity ), std::move( phaseMassDensity ), std::move( phaseViscosity ), + std::move( phaseEnthalpy ), + std::move( phaseInternalEnergy ), std::move( phaseCompFraction ), std::move( totalDensity ) ), m_PVTOView( PVTO.createKernelWrapper() ) @@ -523,6 +527,8 @@ BlackOilFluid::createKernelWrapper() m_phaseDensity.toView(), m_phaseMassDensity.toView(), m_phaseViscosity.toView(), + m_phaseEnthalpy.toView(), + m_phaseInternalEnergy.toView(), m_phaseCompFraction.toView(), m_totalDensity.toView() ); } diff --git a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp index 9d12043d155..7e487b688e7 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp @@ -61,6 +61,8 @@ class BlackOilFluid : public BlackOilFluidBase arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice2d< real64, multifluid::USD_PHASE_COMP-2 > const & phaseCompFraction, real64 & totalDensity ) const override; @@ -72,6 +74,8 @@ class BlackOilFluid : public BlackOilFluidBase PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const override; @@ -100,6 +104,8 @@ class BlackOilFluid : public BlackOilFluidBase PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ); @@ -261,19 +267,13 @@ BlackOilFluid::KernelWrapper:: arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice2d< real64, multifluid::USD_PHASE_COMP - 2 > const & phaseCompFraction, real64 & totalDens ) const { - GEOSX_UNUSED_VAR( pressure ); - GEOSX_UNUSED_VAR( temperature ); - GEOSX_UNUSED_VAR( composition ); - GEOSX_UNUSED_VAR( phaseFraction ); - GEOSX_UNUSED_VAR( phaseDensity ); - GEOSX_UNUSED_VAR( phaseMassDensity ); - GEOSX_UNUSED_VAR( phaseViscosity ); - GEOSX_UNUSED_VAR( phaseCompFraction ); - GEOSX_UNUSED_VAR( totalDens ); - + GEOSX_UNUSED_VAR( pressure, temperature, composition, phaseFraction, phaseDensity, phaseMassDensity, + phaseViscosity, phaseEnthalpy, phaseInternalEnergy, phaseCompFraction, totalDens ); GEOSX_ERROR( "BlackOilFluid: this compute function is not implemented" ); } @@ -287,10 +287,12 @@ BlackOilFluid::KernelWrapper:: PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const { - GEOSX_UNUSED_VAR( temperature ); + GEOSX_UNUSED_VAR( temperature, phaseEnthalpy, phaseInternalEnergy ); real64 compMoleFrac[NC_BO]{}; real64 dCompMoleFrac_dCompMassFrac[NC_BO][NC_BO]{}; @@ -1090,6 +1092,8 @@ BlackOilFluid::KernelWrapper:: m_phaseDensity( k, q ), m_phaseMassDensity( k, q ), m_phaseViscosity( k, q ), + m_phaseEnthalpy( k, q ), + m_phaseInternalEnergy( k, q ), m_phaseCompFraction( k, q ), m_totalDensity( k, q ) ); } diff --git a/src/coreComponents/constitutive/fluid/BlackOilFluidBase.cpp b/src/coreComponents/constitutive/fluid/BlackOilFluidBase.cpp index d19bca6e30b..6699b06ac33 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluidBase.cpp @@ -285,6 +285,8 @@ BlackOilFluidBase::KernelWrapper:: PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ) : MultiFluidBase::KernelWrapper( std::move( componentMolarWeight ), @@ -293,6 +295,8 @@ BlackOilFluidBase::KernelWrapper:: std::move( phaseDensity ), std::move( phaseMassDensity ), std::move( phaseViscosity ), + std::move( phaseEnthalpy ), + std::move( phaseInternalEnergy ), std::move( phaseCompFraction ), std::move( totalDensity ) ), m_phaseTypes( std::move( phaseTypes ) ), diff --git a/src/coreComponents/constitutive/fluid/BlackOilFluidBase.hpp b/src/coreComponents/constitutive/fluid/BlackOilFluidBase.hpp index a76521b2b54..3a4b1f34f20 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluidBase.hpp @@ -98,6 +98,8 @@ class BlackOilFluidBase : public MultiFluidBase PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ); diff --git a/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp b/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp new file mode 100644 index 00000000000..69e6be4bbe1 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp @@ -0,0 +1,437 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file CO2BrineFluid.cpp + */ +#include "CO2BrineFluid.hpp" + +#include "constitutive/fluid/MultiFluidExtrinsicData.hpp" +#include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" + +namespace geosx +{ + +using namespace dataRepository; + +namespace constitutive +{ + +using namespace PVTProps; + +namespace +{ +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > class + TwoPhaseCatalogNames {}; + +template<> class + TwoPhaseCatalogNames< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::CO2Solubility > +{ +public: + static string name() { return "CO2BrinePhillipsFluid"; } +}; +template<> class + TwoPhaseCatalogNames< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + PVTProps::CO2Solubility > +{ +public: + static string name() { return "CO2BrinePhillipsThermalFluid"; } +}; + +template<> class + TwoPhaseCatalogNames< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::CO2Solubility > +{ +public: + static string name() { return "CO2BrineEzrokhiFluid"; } +}; +template<> class + TwoPhaseCatalogNames< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + PVTProps::CO2Solubility > +{ +public: + static string name() { return "CO2BrineEzrokhiThermalFluid"; } +}; + +} // end namespace + +// provide a definition for catalogName() +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +string CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::catalogName() +{ + return TwoPhaseCatalogNames< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::name(); +} + +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >:: +CO2BrineFluid( string const & name, Group * const parent ): + MultiFluidBase( name, parent ) +{ + registerWrapper( viewKeyStruct::phasePVTParaFilesString(), &m_phasePVTParaFiles ). + setInputFlag( InputFlags::REQUIRED ). + setRestartFlags( RestartFlags::NO_WRITE ). + setDescription( "Names of the files defining the parameters of the viscosity and density models" ); + + registerWrapper( viewKeyStruct::flashModelParaFileString(), &m_flashModelParaFile ). + setInputFlag( InputFlags::REQUIRED ). + setRestartFlags( RestartFlags::NO_WRITE ). + setDescription( "Name of the file defining the parameters of the flash model" ); + + m_thermalFlag = ( P1ENTH::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && + P1INTENERGY::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && + P2ENTH::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && + P2INTENERGY::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ); + + // if this is a thermal model, we need to make sure that the arrays will be properly displayed and saved to restart + if( m_thermalFlag ) + { + getExtrinsicData< extrinsicMeshData::multifluid::phaseEnthalpy >(). + setPlotLevel( PlotLevel::LEVEL_0 ). + setRestartFlags( RestartFlags::WRITE_AND_READ ); + + getExtrinsicData< extrinsicMeshData::multifluid::phaseInternalEnergy >(). + setPlotLevel( PlotLevel::LEVEL_0 ). + setRestartFlags( RestartFlags::WRITE_AND_READ ); + } +} + +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +std::unique_ptr< ConstitutiveBase > +CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >:: +deliverClone( string const & name, Group * const parent ) const +{ + std::unique_ptr< ConstitutiveBase > clone = MultiFluidBase::deliverClone( name, parent ); + + CO2BrineFluid & newConstitutiveRelation = dynamicCast< CO2BrineFluid & >( *clone ); + newConstitutiveRelation.m_p1Index = m_p1Index; + newConstitutiveRelation.m_p2Index = m_p2Index; + + newConstitutiveRelation.createPVTModels(); + + return clone; +} + +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +integer CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::getWaterPhaseIndex() const +{ + string const expectedWaterPhaseNames[] = { "Water", "water", "Liquid", "liquid" }; + return PVTFunctionHelpers::findName( m_phaseNames, expectedWaterPhaseNames, viewKeyStruct::phaseNamesString() ); +} + + +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::postProcessInput() +{ + MultiFluidBase::postProcessInput(); + + GEOSX_THROW_IF_NE_MSG( numFluidPhases(), 2, + GEOSX_FMT( "{}: invalid number of phases", getFullName() ), + InputError ); + GEOSX_THROW_IF_NE_MSG( numFluidComponents(), 2, + GEOSX_FMT( "{}: invalid number of components", getFullName() ), + InputError ); + GEOSX_THROW_IF_NE_MSG( m_phasePVTParaFiles.size(), 2, + GEOSX_FMT( "{}: invalid number of values in attribute '{}'", getFullName() ), + InputError ); + + // NOTE: for now, the names of the phases are still hardcoded here + // Later, we could read them from the XML file and we would then have a general class here + + string const expectedWaterPhaseNames[] = { "Water", "water", "Liquid", "liquid" }; + m_p1Index = PVTFunctionHelpers::findName( m_phaseNames, expectedWaterPhaseNames, viewKeyStruct::phaseNamesString() ); + + string const expectedGasPhaseNames[] = { "CO2", "co2", "gas", "Gas" }; + m_p2Index = PVTFunctionHelpers::findName( m_phaseNames, expectedGasPhaseNames, viewKeyStruct::phaseNamesString() ); + + createPVTModels(); +} + +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::createPVTModels() +{ + + // TODO: get rid of these external files and move into XML, this is too error prone + + // 1) Create the viscosity and density models + for( string const & filename : m_phasePVTParaFiles ) + { + std::ifstream is( filename ); + string str; + while( std::getline( is, str ) ) + { + string_array const strs = stringutilities::tokenize( str, " " ); + + if( strs[0] == "DensityFun" ) + { + if( strs[1] == P1DENS::catalogName() ) + { + m_p1Density = std::make_unique< P1DENS >( getName() + '_' + P1DENS::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + } + else if( strs[1] == P2DENS::catalogName() ) + { + m_p2Density = std::make_unique< P2DENS >( getName() + '_' + P2DENS::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + } + } + else if( strs[0] == "ViscosityFun" ) + { + if( strs[1] == P1VISC::catalogName() ) + { + m_p1Viscosity = std::make_unique< P1VISC >( getName() + '_' + P1VISC::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + } + else if( strs[1] == P2VISC::catalogName() ) + { + m_p2Viscosity = std::make_unique< P2VISC >( getName() + '_' + P2VISC::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + } + } + else if( strs[0] == "EnthalpyFun" ) + { + if( strs[1] == P1ENTH::catalogName() ) + { + m_p1Enthalpy = std::make_unique< P1ENTH >( getName() + '_' + P1ENTH::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + } + else if( strs[1] == P2ENTH::catalogName() ) + { + m_p2Enthalpy = std::make_unique< P2ENTH >( getName() + '_' + P2ENTH::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + } + } + else if( strs[0] == "InternalEnergyFun" ) + { + if( strs[1] == P1INTENERGY::catalogName() ) + { + m_p1IntEnergy = std::make_unique< P1INTENERGY >( getName() + '_' + P1INTENERGY::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + } + else if( strs[1] == P2INTENERGY::catalogName() ) + { + m_p2IntEnergy = std::make_unique< P2INTENERGY >( getName() + '_' + P2INTENERGY::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + } + } + else + { + GEOSX_THROW( GEOSX_FMT( "{}: invalid PVT function type '{}'", getFullName(), strs[0] ), InputError ); + } + } + is.close(); + } + + // at this point, we have read the file, and we can detect any inconsistency arising in the enthalpy/internal energy models + GEOSX_THROW_IF( m_p1Enthalpy == nullptr && ( P1ENTH::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1ENTH::catalogName() ), + InputError ); + GEOSX_THROW_IF( m_p1IntEnergy == nullptr && ( P1INTENERGY::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1INTENERGY::catalogName() ), + InputError ); + GEOSX_THROW_IF( m_p2Enthalpy == nullptr && ( P2ENTH::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2ENTH::catalogName() ), + InputError ); + GEOSX_THROW_IF( m_p2IntEnergy == nullptr && ( P2INTENERGY::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2INTENERGY::catalogName() ), + InputError ); + // we also check the consistency of non-thermal models + GEOSX_THROW_IF( m_p1Density == nullptr, + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1DENS::catalogName() ), + InputError ); + GEOSX_THROW_IF( m_p2Density == nullptr, + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2DENS::catalogName() ), + InputError ); + GEOSX_THROW_IF( m_p1Viscosity == nullptr, + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1VISC::catalogName() ), + InputError ); + GEOSX_THROW_IF( m_p2Viscosity == nullptr, + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2VISC::catalogName() ), + InputError ); + + // for non-thermal models, the user skips the definition of the enthalpy/internal energy models, so we create NoOp models now + if( m_p1Enthalpy == nullptr ) + { + m_p1Enthalpy = std::make_unique< P1ENTH >( getName() + '_' + P1ENTH::catalogName(), string_array(), m_componentNames, m_componentMolarWeight ); + } + if( m_p2Enthalpy == nullptr ) + { + m_p2Enthalpy = std::make_unique< P2ENTH >( getName() + '_' + P2ENTH::catalogName(), string_array(), m_componentNames, m_componentMolarWeight ); + } + if( m_p1IntEnergy == nullptr ) + { + m_p1IntEnergy = std::make_unique< P1INTENERGY >( getName() + '_' + P1INTENERGY::catalogName(), string_array(), m_componentNames, m_componentMolarWeight ); + } + if( m_p2IntEnergy == nullptr ) + { + m_p2IntEnergy = std::make_unique< P2INTENERGY >( getName() + '_' + P2INTENERGY::catalogName(), string_array(), m_componentNames, m_componentMolarWeight ); + } + + // 2) Create the flash model + { + std::ifstream is( m_flashModelParaFile ); + string str; + while( std::getline( is, str ) ) + { + string_array const strs = stringutilities::tokenize( str, " " ); + if( strs[0] == "FlashModel" ) + { + if( strs[1] == FLASH::catalogName() ) + { + m_flash = std::make_unique< FLASH >( getName() + '_' + FLASH::catalogName(), strs, m_phaseNames, m_componentNames, m_componentMolarWeight ); + } + } + else + { + GEOSX_THROW( GEOSX_FMT( "{}: invalid flash model type '{}'", getFullName(), strs[0] ), InputError ); + } + } + is.close(); + } + + GEOSX_THROW_IF( m_flash == nullptr, + GEOSX_FMT( "{}: flash model {} not found in input files", getFullName(), FLASH::catalogName() ), + InputError ); +} + +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +typename CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::KernelWrapper +CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::createKernelWrapper() +{ + return KernelWrapper( m_p1Index, + m_p2Index, + *m_p1Density, + *m_p1Viscosity, + *m_p1Enthalpy, + *m_p1IntEnergy, + *m_p2Density, + *m_p2Viscosity, + *m_p2Enthalpy, + *m_p2IntEnergy, + *m_flash, + m_componentMolarWeight.toViewConst(), + m_useMass, + m_phaseFraction.toView(), + m_phaseDensity.toView(), + m_phaseMassDensity.toView(), + m_phaseViscosity.toView(), + m_phaseEnthalpy.toView(), + m_phaseInternalEnergy.toView(), + m_phaseCompFraction.toView(), + m_totalDensity.toView() ); +} + +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::KernelWrapper:: + KernelWrapper( integer const p1Index, + integer const p2Index, + P1DENS const & p1Density, + P1VISC const & p1Viscosity, + P1ENTH const & p1Enthalpy, + P1INTENERGY const & p1IntEnergy, + P2DENS const & p2Density, + P2VISC const & p2Viscosity, + P2ENTH const & p2Enthalpy, + P2INTENERGY const & p2IntEnergy, + FLASH const & flash, + arrayView1d< geosx::real64 const > componentMolarWeight, + bool const useMass, + PhaseProp::ViewType phaseFraction, + PhaseProp::ViewType phaseDensity, + PhaseProp::ViewType phaseMassDensity, + PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, + PhaseComp::ViewType phaseCompFraction, + FluidProp::ViewType totalDensity ) + : MultiFluidBase::KernelWrapper( std::move( componentMolarWeight ), + useMass, + std::move( phaseFraction ), + std::move( phaseDensity ), + std::move( phaseMassDensity ), + std::move( phaseViscosity ), + std::move( phaseEnthalpy ), + std::move( phaseInternalEnergy ), + std::move( phaseCompFraction ), + std::move( totalDensity ) ), + m_p1Index( p1Index ), + m_p2Index( p2Index ), + m_p1Density( p1Density.createKernelWrapper() ), + m_p1Viscosity( p1Viscosity.createKernelWrapper() ), + m_p1Enthalpy( p1Enthalpy.createKernelWrapper() ), + m_p1IntEnergy( p1IntEnergy.createKernelWrapper() ), + m_p2Density( p2Density.createKernelWrapper() ), + m_p2Viscosity( p2Viscosity.createKernelWrapper() ), + m_p2Enthalpy( p2Enthalpy.createKernelWrapper() ), + m_p2IntEnergy( p2IntEnergy.createKernelWrapper() ), + m_flash( flash.createKernelWrapper() ) +{} + +// explicit instantiation of the model template; unfortunately we can't use the aliases for this +template class CO2BrineFluid< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::CO2Solubility >; +template class CO2BrineFluid< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + PVTProps::CO2Solubility >; + +template class CO2BrineFluid< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::CO2Solubility >; +template class CO2BrineFluid< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + PVTProps::CO2Solubility >; + +REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrinePhillipsFluid, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrinePhillipsThermalFluid, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrineEzrokhiFluid, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrineEzrokhiThermalFluid, string const &, Group * const ) + +} //namespace constitutive + +} //namespace geosx diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp similarity index 65% rename from src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp rename to src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp index 615ba55c1ae..789cb21666b 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ b/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp @@ -13,22 +13,28 @@ */ /** - * @file MultiPhaseMultiComponentFluid.hpp + * @file CO2BrineFluid.hpp */ -#ifndef GEOSX_CONSTITUTIVE_FLUID_MULTIPHASEMULTICOMPONENTFLUID_HPP_ -#define GEOSX_CONSTITUTIVE_FLUID_MULTIPHASEMULTICOMPONENTFLUID_HPP_ +#ifndef GEOSX_CONSTITUTIVE_FLUID_CO2BRINEFLUID_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_CO2BRINEFLUID_HPP_ #include "constitutive/fluid/MultiFluidBase.hpp" #include "constitutive/fluid/MultiFluidUtils.hpp" -#include "constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp" -#include "constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp" +#include "constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp" +#include "constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp" +#include "constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp" +#include "constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp" +#include "constitutive/fluid/PVTFunctions/CO2Solubility.hpp" #include "constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp" #include "constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp" -#include "constitutive/fluid/PVTFunctions/CO2Solubility.hpp" #include "constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp" +#include "constitutive/fluid/PVTFunctions/NoOpPVTFunction.hpp" +#include "constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp" +#include "constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp" #include "constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp" + #include namespace geosx @@ -37,27 +43,28 @@ namespace geosx namespace constitutive { -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -class MultiPhaseMultiComponentFluid : public MultiFluidBase +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > +class CO2BrineFluid : public MultiFluidBase { public: using exec_policy = parallelDevicePolicy<>; - MultiPhaseMultiComponentFluid( string const & name, - Group * const parent ); + CO2BrineFluid( string const & name, + Group * const parent ); virtual std::unique_ptr< ConstitutiveBase > deliverClone( string const & name, Group * const parent ) const override; - static string catalogName(); virtual string getCatalogName() const override { return catalogName(); } /** - * @brief Kernel wrapper class for MultiPhaseMultiComponentFluid. + * @brief Kernel wrapper class for CO2BrineFluid. */ class KernelWrapper final : public MultiFluidBase::KernelWrapper { @@ -71,6 +78,8 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice2d< real64, multifluid::USD_PHASE_COMP-2 > const & phaseCompFraction, real64 & totalDensity ) const override; @@ -82,6 +91,8 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const override; @@ -94,29 +105,38 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase private: - friend class MultiPhaseMultiComponentFluid; - - KernelWrapper( localIndex p1Index, - localIndex p2Index, - P1DENS const & p1DensityWrapper, - P1VISC const & p1ViscosityWrapper, - P2DENS const & p2DensityWrapper, - P2VISC const & p2ViscosityWrapper, - FLASH const & flashWrapper, + friend class CO2BrineFluid; + + KernelWrapper( integer p1Index, + integer p2Index, + P1DENS const & p1Density, + P1VISC const & p1Viscosity, + P1ENTH const & p1Enthalpy, + P1INTENERGY const & p1IntEnergy, + P2DENS const & p2Density, + P2VISC const & p2Viscosity, + P2ENTH const & p2Enthalpy, + P2INTENERGY const & p2IntEnergy, + FLASH const & flash, arrayView1d< real64 const > componentMolarWeight, bool const useMass, PhaseProp::ViewType phaseFraction, PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ); /// Index of the liquid phase - localIndex m_p1Index; + integer m_p1Index; /// Index of the gas phase - localIndex m_p2Index; + integer m_p2Index; + + + // Brine constitutive kernel wrappers /// Kernel wrapper for brine density updates typename P1DENS::KernelWrapper m_p1Density; @@ -124,12 +144,30 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase /// Kernel wrapper for brine viscosity updates typename P1VISC::KernelWrapper m_p1Viscosity; + /// Kernel wrapper for brine enthalpy updates + typename P1ENTH::KernelWrapper m_p1Enthalpy; + + /// Kernel wrapper for brine internal energy updates + typename P1INTENERGY::KernelWrapper m_p1IntEnergy; + + + // CO2 constitutive kernel wrapper + /// Kernel wrapper for CO2 density updates typename P2DENS::KernelWrapper m_p2Density; /// Kernel wrapper for CO2 viscosity updates typename P2VISC::KernelWrapper m_p2Viscosity; + /// Kernel wrapper for CO2 enthalpy updates + typename P2ENTH::KernelWrapper m_p2Enthalpy; + + /// Kernel wrapper for CO2 internal energy updates + typename P2INTENERGY::KernelWrapper m_p2IntEnergy; + + + // Flash kernel wrapper + /// Kernel wrapper for phase fraction and phase component fraction updates typename FLASH::KernelWrapper m_flash; }; @@ -168,39 +206,71 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase /// Index of the gas phase integer m_p2Index; + + // Brine constitutive models + /// Pointer to the brine density model std::unique_ptr< P1DENS > m_p1Density; /// Pointer to the brine viscosity model std::unique_ptr< P1VISC > m_p1Viscosity; + /// Pointer to the brine enthalpy model + std::unique_ptr< P1ENTH > m_p1Enthalpy; + + /// Pointer to the brine internal energy model + std::unique_ptr< P1INTENERGY > m_p1IntEnergy; + + + // CO2 constitutive models + /// Pointer to the CO2 density model std::unique_ptr< P2DENS > m_p2Density; /// Pointer to the CO2 viscosity model std::unique_ptr< P2VISC > m_p2Viscosity; + /// Pointer to the CO2 enthalpy model + std::unique_ptr< P2ENTH > m_p2Enthalpy; + + /// Pointer to the CO2 internal energy model + std::unique_ptr< P2INTENERGY > m_p2IntEnergy; + + + // Flash model + /// Pointer to the flash model std::unique_ptr< FLASH > m_flash; -}; - -// this alias will be useful in constitutive dispatch -using CO2BrinePhillipsFluid = MultiPhaseMultiComponentFluid< PVTProps::PhillipsBrineDensity, - PVTProps::PhillipsBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility >; -using CO2BrineEzrokhiFluid = MultiPhaseMultiComponentFluid< PVTProps::EzrokhiBrineDensity, - PVTProps::EzrokhiBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility >; +}; -template< typename P1DENSWRAPPER, typename P1VISCWRAPPER, typename P2DENSWRAPPER, typename P2VISCWRAPPER, typename FLASHWRAPPER > +// these aliases are useful in constitutive dispatch +using CO2BrinePhillipsFluid = + CO2BrineFluid< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::CO2Solubility >; +using CO2BrinePhillipsThermalFluid = + CO2BrineFluid< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + PVTProps::CO2Solubility >; + +using CO2BrineEzrokhiFluid = + CO2BrineFluid< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + PVTProps::CO2Solubility >; +using CO2BrineEzrokhiThermalFluid = + CO2BrineFluid< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, + PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + PVTProps::CO2Solubility >; + +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > GEOSX_HOST_DEVICE inline void -MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VISCWRAPPER, FLASHWRAPPER >::KernelWrapper:: +CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::KernelWrapper:: compute( real64 pressure, real64 temperature, arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition, @@ -208,13 +278,15 @@ MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VI arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice2d< real64, multifluid::USD_PHASE_COMP-2 > const & phaseCompFraction, real64 & totalDensity ) const { - constexpr localIndex numComps = 2; - constexpr localIndex numPhases = 2; - localIndex const ip1 = m_p1Index; - localIndex const ip2 = m_p2Index; + integer constexpr numComps = 2; + integer constexpr numPhases = 2; + integer const ip1 = m_p1Index; + integer const ip2 = m_p2Index; // 1. Convert input mass fractions to mole fractions and keep derivatives @@ -222,7 +294,7 @@ MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VI if( m_useMass ) { real64 totalMolality = 0.0; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { real64 const mwInv = 1.0 / m_componentMolarWeight[ic]; compMoleFrac[ic] = composition[ic] * mwInv; // this is molality (units of mole/mass) @@ -230,14 +302,14 @@ MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VI } real64 const totalMolalityInv = 1.0 / totalMolality; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { compMoleFrac[ic] *= totalMolalityInv; } } else { - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { compMoleFrac[ic] = composition[ic]; } @@ -276,7 +348,31 @@ MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VI phaseViscosity[ip2], m_useMass ); - // 4. Depending on the m_useMass flag, convert to mass variables or simply compute mass density + // 4. Compute enthalpy and internal energy + + m_p1Enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseEnthalpy[ip1], + m_useMass ); + m_p1IntEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseInternalEnergy[ip1], + m_useMass ); + + m_p2Enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseEnthalpy[ip2], + m_useMass ); + m_p2IntEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseInternalEnergy[ip2], + m_useMass ); + + // 5. Depending on the m_useMass flag, convert to mass variables or simply compute mass density // TODO: for now the treatment of molar/mass density requires too many interpolations in the tables, it needs to be fixed // we should modify the PVT functions so that they can return phaseMassDens, phaseDens, and phaseMW in one call @@ -284,12 +380,12 @@ MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VI if( m_useMass ) { - // 4.1. Convert phase fractions (requires two passes) + // 5.1. Convert phase fractions (requires two passes) real64 totalMass{}; - // 4.1.0. Compute the phase molecular weights (ultimately, get that from the PVT function) - real64 phaseMW[2]; - real64 phaseMolarDens; + // 5.1.0. Compute the phase molecular weights (ultimately, get that from the PVT function) + real64 phaseMW[2]{}; + real64 phaseMolarDens = 0.0; m_p1Density.compute( pressure, temperatureInCelsius, phaseCompFraction[ip1].toSliceConst(), @@ -304,31 +400,31 @@ MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VI false ); phaseMW[ip2] = phaseDensity[ip2] / phaseMolarDens; - // 4.1.1. Compute mass of each phase and total mass (on a 1-mole basis) - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 5.1.1. Compute mass of each phase and total mass (on a 1-mole basis) + for( integer ip = 0; ip < numPhases; ++ip ) { phaseFraction[ip] *= phaseMW[ip]; totalMass += phaseFraction[ip]; } - // 4.1.2. Normalize to get mass fractions + // 5.1.2. Normalize to get mass fractions real64 const totalMassInv = 1.0 / totalMass; - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { phaseFraction[ip] *= totalMassInv; } - // 4.2. Convert phase compositions - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 5.2. Convert phase compositions + for( integer ip = 0; ip < numPhases; ++ip ) { real64 const phaseMWInv = 1.0 / phaseMW[ip]; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { real64 const compMW = m_componentMolarWeight[ic]; phaseCompFraction[ip][ic] = phaseCompFraction[ip][ic] * compMW * phaseMWInv; } } - // 4.3 Copy the phase densities into the phase mass densities - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 5.3 Copy the phase densities into the phase mass densities + for( integer ip = 0; ip < numPhases; ++ip ) { phaseMassDensity[ip] = phaseDensity[ip]; } @@ -350,25 +446,29 @@ MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VI // TODO: extract the following piece of code and write a function that can be used here and in MultiFluidPVTPackageWrapper - // 5. Compute total fluid mass/molar density and derivatives + // 6. Compute total fluid mass/molar density and derivatives { totalDensity = 0.0; - // 5.1. Sum mass/molar fraction/density ratio over all phases to get the inverse of density - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 6.1. Sum mass/molar fraction/density ratio over all phases to get the inverse of density + for( integer ip = 0; ip < numPhases; ++ip ) { real64 const densInv = 1.0 / phaseDensity[ip]; real64 const value = phaseFraction[ip] * densInv; totalDensity += value; } - // 5.2. Invert the previous quantity to get actual density + // 6.2. Invert the previous quantity to get actual density totalDensity = 1.0 / totalDensity; } } -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > GEOSX_HOST_DEVICE inline void -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWrapper:: +CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::KernelWrapper:: compute( real64 const pressure, real64 const temperature, arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition, @@ -376,13 +476,15 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const { - constexpr localIndex numComps = 2; - constexpr localIndex numPhases = 2; - localIndex const ip1 = m_p1Index; - localIndex const ip2 = m_p2Index; + integer constexpr numComps = 2; + integer constexpr numPhases = 2; + integer const ip1 = m_p1Index; + integer const ip2 = m_p2Index; // 1. Convert input mass fractions to mole fractions and keep derivatives @@ -392,7 +494,7 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr if( m_useMass ) { real64 totalMolality = 0.0; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { real64 const mwInv = 1.0 / m_componentMolarWeight[ic]; compMoleFrac[ic] = composition[ic] * mwInv; // this is molality (units of mole/mass) @@ -401,11 +503,11 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr } real64 const totalMolalityInv = 1.0 / totalMolality; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { compMoleFrac[ic] *= totalMolalityInv; - for( localIndex jc = 0; jc < numComps; ++jc ) + for( integer jc = 0; jc < numComps; ++jc ) { dCompMoleFrac_dCompMassFrac[ic][jc] -= compMoleFrac[ic] / m_componentMolarWeight[jc]; dCompMoleFrac_dCompMassFrac[ic][jc] *= totalMolalityInv; @@ -414,7 +516,7 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr } else { - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { compMoleFrac[ic] = composition[ic]; } @@ -460,7 +562,40 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr phaseViscosity.dTemp[ip2], phaseViscosity.dComp[ip2], m_useMass ); - // 4. Depending on the m_useMass flag, convert to mass variables or simply compute mass density + + // 4. Compute enthalpy and internal energy + + m_p1Enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), + phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), + phaseEnthalpy.value[ip1], phaseEnthalpy.dPres[ip1], + phaseEnthalpy.dTemp[ip1], phaseEnthalpy.dComp[ip1], + m_useMass ); + m_p1IntEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), + phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), + phaseInternalEnergy.value[ip1], phaseInternalEnergy.dPres[ip1], + phaseInternalEnergy.dTemp[ip1], phaseInternalEnergy.dComp[ip1], + m_useMass ); + + m_p2Enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), + phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), + phaseEnthalpy.value[ip2], phaseEnthalpy.dPres[ip2], + phaseEnthalpy.dTemp[ip2], phaseEnthalpy.dComp[ip2], + m_useMass ); + m_p2IntEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), + phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), + phaseInternalEnergy.value[ip2], phaseInternalEnergy.dPres[ip2], + phaseInternalEnergy.dTemp[ip2], phaseInternalEnergy.dComp[ip2], + m_useMass ); + + // 5. Depending on the m_useMass flag, convert to mass variables or simply compute mass density // TODO: for now the treatment of molar/mass density requires too many interpolations in the tables, it needs to be fixed // we should modify the PVT functions so that they can return phaseMassDens, phaseDens, and phaseMW in one call @@ -468,20 +603,20 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr if( m_useMass ) { - // 4.1. Convert phase fractions (requires two passes) + // 5.1. Convert phase fractions (requires two passes) real64 totalMass{}; real64 dTotalMass_dP{}; real64 dTotalMass_dT{}; real64 dTotalMass_dC[2]{}; - // 4.1.0. Compute the phase molecular weights (ultimately, get that from the PVT function) - real64 phaseMW[2]; - real64 dPhaseMW_dPres[2]; - real64 dPhaseMW_dTemp[2]; - real64 dPhaseMW_dComp[2][2]; - real64 phaseMolarDens; - real64 dPhaseMolarDens_dPres; - real64 dPhaseMolarDens_dTemp; + // 5.1.0. Compute the phase molecular weights (ultimately, get that from the PVT function) + real64 phaseMW[2]{}; + real64 dPhaseMW_dPres[2]{}; + real64 dPhaseMW_dTemp[2]{}; + real64 dPhaseMW_dComp[2][2]{}; + real64 phaseMolarDens = 0.0; + real64 dPhaseMolarDens_dPres = 0.0; + real64 dPhaseMolarDens_dTemp = 0.0; stackArray1d< real64, numComps > dPhaseMolarDens_dComp( 2 ); m_p2Density.compute( pressure, temperatureInCelsius, @@ -493,7 +628,7 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr phaseMW[ip2] = phaseDensity.value[ip2] / phaseMolarDens; dPhaseMW_dPres[ip2] = phaseDensity.dPres[ip2] / phaseMolarDens - phaseMW[ip2] * dPhaseMolarDens_dPres / phaseMolarDens; dPhaseMW_dTemp[ip2] = phaseDensity.dTemp[ip2] / phaseMolarDens - phaseMW[ip2] * dPhaseMolarDens_dTemp / phaseMolarDens; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { dPhaseMW_dComp[ip2][ic] = phaseDensity.dComp[ip2][ic] / phaseMolarDens - phaseMW[ip2] * dPhaseMolarDens_dComp[ic] / phaseMolarDens; } @@ -507,14 +642,14 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr phaseMW[ip1] = phaseDensity.value[ip1] / phaseMolarDens; dPhaseMW_dPres[ip1] = phaseDensity.dPres[ip1] / phaseMolarDens - phaseMW[ip1] * dPhaseMolarDens_dPres / phaseMolarDens; dPhaseMW_dTemp[ip1] = phaseDensity.dTemp[ip1] / phaseMolarDens - phaseMW[ip1] * dPhaseMolarDens_dTemp / phaseMolarDens; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { dPhaseMW_dComp[ip1][ic] = phaseDensity.dComp[ip1][ic] / phaseMolarDens - phaseMW[ip1] * dPhaseMolarDens_dComp[ic] / phaseMolarDens; } - // 4.1.1. Compute mass of each phase and total mass (on a 1-mole basis) - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 5.1.1. Compute mass of each phase and total mass (on a 1-mole basis) + for( integer ip = 0; ip < numPhases; ++ip ) { real64 const nu = phaseFraction.value[ip]; @@ -526,33 +661,33 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr dTotalMass_dP += phaseFraction.dPres[ip]; dTotalMass_dT += phaseFraction.dTemp[ip]; - for( localIndex jc = 0; jc < numComps; ++jc ) + for( integer jc = 0; jc < numComps; ++jc ) { phaseFraction.dComp[ip][jc] = phaseFraction.dComp[ip][jc] * phaseMW[ip] + nu * dPhaseMW_dComp[ip][jc]; dTotalMass_dC[jc] += phaseFraction.dComp[ip][jc]; } } - // 4.1.2. Normalize to get mass fractions + // 5.1.2. Normalize to get mass fractions real64 const totalMassInv = 1.0 / totalMass; - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { phaseFraction.value[ip] *= totalMassInv; phaseFraction.dPres[ip] = ( phaseFraction.dPres[ip] - phaseFraction.value[ip] * dTotalMass_dP ) * totalMassInv; phaseFraction.dTemp[ip] = ( phaseFraction.dTemp[ip] - phaseFraction.value[ip] * dTotalMass_dT ) * totalMassInv; - for( localIndex jc = 0; jc < numComps; ++jc ) + for( integer jc = 0; jc < numComps; ++jc ) { phaseFraction.dComp[ip][jc] = ( phaseFraction.dComp[ip][jc] - phaseFraction.value[ip] * dTotalMass_dC[jc] ) * totalMassInv; } } - // 4.2. Convert phase compositions - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 5.2. Convert phase compositions + for( integer ip = 0; ip < numPhases; ++ip ) { real64 const phaseMWInv = 1.0 / phaseMW[ip]; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { real64 const compMW = m_componentMolarWeight[ic]; @@ -563,7 +698,7 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr phaseCompFraction.dTemp[ip][ic] = ( phaseCompFraction.dTemp[ip][ic] * compMW - phaseCompFraction.value[ip][ic] * dPhaseMW_dTemp[ip] ) * phaseMWInv; - for( localIndex jc = 0; jc < numComps; ++jc ) + for( integer jc = 0; jc < numComps; ++jc ) { phaseCompFraction.dComp[ip][ic][jc] = ( phaseCompFraction.dComp[ip][ic][jc] * compMW - phaseCompFraction.value[ip][ic] * dPhaseMW_dComp[ip][jc] ) * phaseMWInv; @@ -571,26 +706,26 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr } } - // 4.3. Update derivatives w.r.t. mole fractions to derivatives w.r.t mass fractions - real64 work[numComps]; - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 5.3. Update derivatives w.r.t. mole fractions to derivatives w.r.t mass fractions + real64 work[numComps]{}; + for( integer ip = 0; ip < numPhases; ++ip ) { applyChainRuleInPlace( numComps, dCompMoleFrac_dCompMassFrac, phaseFraction.dComp[ip], work ); applyChainRuleInPlace( numComps, dCompMoleFrac_dCompMassFrac, phaseDensity.dComp[ip], work ); - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { applyChainRuleInPlace( numComps, dCompMoleFrac_dCompMassFrac, phaseCompFraction.dComp[ip][ic], work ); } } - // 4.4 Copy the phase densities into the phase mass densities - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 5.4 Copy the phase densities into the phase mass densities + for( integer ip = 0; ip < numPhases; ++ip ) { phaseMassDensity.value[ip] = phaseDensity.value[ip]; phaseMassDensity.dPres[ip] = phaseDensity.dPres[ip]; phaseMassDensity.dTemp[ip] = phaseDensity.dTemp[ip]; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { phaseMassDensity.dComp[ip][ic] = phaseDensity.dComp[ip][ic]; } @@ -617,18 +752,18 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr // TODO: extract the following piece of code and write a function that can be used here and in MultiFluidPVTPackageWrapper - // 5. Compute total fluid mass/molar density and derivatives + // 6. Compute total fluid mass/molar density and derivatives { totalDensity.value = 0.0; totalDensity.dPres = 0.0; totalDensity.dTemp = 0.0; - for( localIndex jc = 0; jc < numComps; ++jc ) + for( integer jc = 0; jc < numComps; ++jc ) { totalDensity.dComp[jc] = 0.0; } - // 5.1. Sum mass/molar fraction/density ratio over all phases to get the inverse of density - for( localIndex ip = 0; ip < numPhases; ++ip ) + // 6.1. Sum mass/molar fraction/density ratio over all phases to get the inverse of density + for( integer ip = 0; ip < numPhases; ++ip ) { real64 const densInv = 1.0 / phaseDensity.value[ip]; real64 const value = phaseFraction.value[ip] * densInv; @@ -637,28 +772,32 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr totalDensity.dPres += ( phaseFraction.dPres[ip] - value * phaseDensity.dPres[ip] ) * densInv; totalDensity.dTemp += ( phaseFraction.dTemp[ip] - value * phaseDensity.dTemp[ip] ) * densInv; - for( localIndex jc = 0; jc < numComps; ++jc ) + for( integer jc = 0; jc < numComps; ++jc ) { totalDensity.dComp[jc] += ( phaseFraction.dComp[ip][jc] - value * phaseDensity.dComp[ip][jc] ) * densInv; } } - // 5.2. Invert the previous quantity to get actual density + // 6.2. Invert the previous quantity to get actual density totalDensity.value = 1.0 / totalDensity.value; real64 const minusDens2 = -totalDensity.value * totalDensity.value; totalDensity.dPres *= minusDens2; totalDensity.dTemp *= minusDens2; - for( localIndex jc = 0; jc < numComps; ++jc ) + for( integer jc = 0; jc < numComps; ++jc ) { totalDensity.dComp[jc] *= minusDens2; } } } -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > +template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, + typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, + typename FLASH > GEOSX_HOST_DEVICE inline void -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWrapper:: +CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, + P2DENS, P2VISC, P2ENTH, P2INTENERGY, + FLASH >::KernelWrapper:: update( localIndex const k, localIndex const q, real64 const pressure, @@ -672,12 +811,14 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr m_phaseDensity( k, q ), m_phaseMassDensity( k, q ), m_phaseViscosity( k, q ), + m_phaseEnthalpy( k, q ), + m_phaseInternalEnergy( k, q ), m_phaseCompFraction( k, q ), m_totalDensity( k, q ) ); } -} //namespace constitutive +} // namespace constitutive -} //namespace geosx +} // namespace geosx #endif //GEOSX_CONSTITUTIVE_FLUID_MULTIPHASEMULTICOMPONENTFLUID_HPP_ diff --git a/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.cpp b/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.cpp index ab78db2a55a..7fe93103cb1 100644 --- a/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.cpp +++ b/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.cpp @@ -173,6 +173,8 @@ CompositionalMultiphaseFluid::KernelWrapper:: PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ) : MultiFluidBase::KernelWrapper( componentMolarWeight, @@ -181,6 +183,8 @@ CompositionalMultiphaseFluid::KernelWrapper:: std::move( phaseDensity ), std::move( phaseMassDensity ), std::move( phaseViscosity ), + std::move( phaseEnthalpy ), + std::move( phaseInternalEnergy ), std::move( phaseCompFraction ), std::move( totalDensity ) ), m_fluid( fluid ), @@ -198,6 +202,8 @@ CompositionalMultiphaseFluid::createKernelWrapper() m_phaseDensity.toView(), m_phaseMassDensity.toView(), m_phaseViscosity.toView(), + m_phaseEnthalpy.toView(), + m_phaseInternalEnergy.toView(), m_phaseCompFraction.toView(), m_totalDensity.toView() ); } diff --git a/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp b/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp index 769dbbc4424..cdf5631d22d 100644 --- a/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp +++ b/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp @@ -71,6 +71,8 @@ class CompositionalMultiphaseFluid : public MultiFluidBase arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseFraction, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, arraySlice2d< real64, multifluid::USD_PHASE_COMP-2 > const & phaseCompFraction, real64 & totalDensity ) const override; @@ -83,6 +85,8 @@ class CompositionalMultiphaseFluid : public MultiFluidBase PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const override; @@ -105,6 +109,8 @@ class CompositionalMultiphaseFluid : public MultiFluidBase PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ); @@ -157,9 +163,12 @@ CompositionalMultiphaseFluid::KernelWrapper:: arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDens, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDens, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseVisc, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice2d< real64, multifluid::USD_PHASE_COMP - 2 > const & phaseCompFrac, real64 & totalDens ) const { + GEOSX_UNUSED_VAR( phaseEnthalpy, phaseInternalEnergy ); #if defined(__CUDA_ARCH__) GEOSX_ERROR( "This function cannot be used on GPU" ); #else @@ -286,6 +295,8 @@ CompositionalMultiphaseFluid::KernelWrapper:: m_phaseDensity( k, q ), m_phaseMassDensity( k, q ), m_phaseViscosity( k, q ), + m_phaseEnthalpy( k, q ), + m_phaseInternalEnergy( k, q ), m_phaseCompFraction( k, q ), m_totalDensity( k, q ) ); } @@ -300,9 +311,12 @@ CompositionalMultiphaseFluid::KernelWrapper:: PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const { + GEOSX_UNUSED_VAR( phaseEnthalpy, phaseInternalEnergy ); #if defined(__CUDA_ARCH__) GEOSX_ERROR( "This function cannot be used on GPU" ); #else diff --git a/src/coreComponents/constitutive/fluid/DeadOilFluid.cpp b/src/coreComponents/constitutive/fluid/DeadOilFluid.cpp index 476c5b8dfbb..029db89c4eb 100644 --- a/src/coreComponents/constitutive/fluid/DeadOilFluid.cpp +++ b/src/coreComponents/constitutive/fluid/DeadOilFluid.cpp @@ -126,6 +126,8 @@ DeadOilFluid::KernelWrapper:: PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ) : BlackOilFluidBase::KernelWrapper( std::move( phaseTypes ), @@ -141,6 +143,8 @@ DeadOilFluid::KernelWrapper:: std::move( phaseDensity ), std::move( phaseMassDensity ), std::move( phaseViscosity ), + std::move( phaseEnthalpy ), + std::move( phaseInternalEnergy ), std::move( phaseCompFraction ), std::move( totalDensity ) ) {} @@ -161,6 +165,8 @@ DeadOilFluid::createKernelWrapper() m_phaseDensity.toView(), m_phaseMassDensity.toView(), m_phaseViscosity.toView(), + m_phaseEnthalpy.toView(), + m_phaseInternalEnergy.toView(), m_phaseCompFraction.toView(), m_totalDensity.toView() ); } diff --git a/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp b/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp index 8d862d1875f..08a48491838 100644 --- a/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp @@ -53,6 +53,8 @@ class DeadOilFluid : public BlackOilFluidBase arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice2d< real64, multifluid::USD_PHASE_COMP-2 > const & phaseCompFraction, real64 & totalDensity ) const override; @@ -64,6 +66,8 @@ class DeadOilFluid : public BlackOilFluidBase PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const override; @@ -91,6 +95,8 @@ class DeadOilFluid : public BlackOilFluidBase PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ); @@ -279,10 +285,13 @@ DeadOilFluid::KernelWrapper:: arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice2d< real64, multifluid::USD_PHASE_COMP - 2 > const & phaseCompFraction, real64 & totalDens ) const { - GEOSX_UNUSED_VAR( temperature ); + GEOSX_UNUSED_VAR( temperature, phaseEnthalpy, phaseInternalEnergy ); + integer const nComps = numComponents(); integer const nPhases = numPhases(); @@ -329,10 +338,12 @@ DeadOilFluid::KernelWrapper:: PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const { - GEOSX_UNUSED_VAR( temperature ); + GEOSX_UNUSED_VAR( temperature, phaseEnthalpy, phaseInternalEnergy ); integer const nComps = numComponents(); integer const nPhases = numPhases(); @@ -418,6 +429,8 @@ DeadOilFluid::KernelWrapper:: m_phaseDensity( k, q ), m_phaseMassDensity( k, q ), m_phaseViscosity( k, q ), + m_phaseEnthalpy( k, q ), + m_phaseInternalEnergy( k, q ), m_phaseCompFraction( k, q ), m_totalDensity( k, q ) ); } diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp index f32baa9fc9a..9df18f9b245 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp @@ -30,6 +30,7 @@ namespace constitutive MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) : ConstitutiveBase( name, parent ), + m_thermalFlag( false ), m_useMass( false ) { // We make base inputs optional here, since derived classes may want to predefine/hardcode @@ -47,6 +48,9 @@ MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) setInputFlag( InputFlags::OPTIONAL ). setDescription( "List of fluid phases" ); + registerWrapper( viewKeyStruct::thermalFlagString(), &m_thermalFlag ). + setRestartFlags( RestartFlags::NO_WRITE ); + registerWrapper( viewKeyStruct::useMassString(), &m_useMass ). setRestartFlags( RestartFlags::NO_WRITE ); @@ -70,6 +74,16 @@ MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseViscosity_dTemperature{}, &m_phaseViscosity.dTemp ); registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseViscosity_dGlobalCompFraction{}, &m_phaseViscosity.dComp ); + registerExtrinsicData( extrinsicMeshData::multifluid::phaseEnthalpy{}, &m_phaseEnthalpy.value ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseEnthalpy_dPressure{}, &m_phaseEnthalpy.dPres ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseEnthalpy_dTemperature{}, &m_phaseEnthalpy.dTemp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseEnthalpy_dGlobalCompFraction{}, &m_phaseEnthalpy.dComp ); + + registerExtrinsicData( extrinsicMeshData::multifluid::phaseInternalEnergy{}, &m_phaseInternalEnergy.value ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseInternalEnergy_dPressure{}, &m_phaseInternalEnergy.dPres ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseInternalEnergy_dTemperature{}, &m_phaseInternalEnergy.dTemp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseInternalEnergy_dGlobalCompFraction{}, &m_phaseInternalEnergy.dComp ); + registerExtrinsicData( extrinsicMeshData::multifluid::phaseCompFraction{}, &m_phaseCompFraction.value ); registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure{}, &m_phaseCompFraction.dPres ); registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseCompFraction_dTemperature{}, &m_phaseCompFraction.dTemp ); @@ -120,6 +134,33 @@ void MultiFluidBase::resizeFields( localIndex const size, localIndex const numPt m_totalDensity.dComp.resize( size, numPts, numComp ); m_initialTotalMassDensity.resize( size, numPts ); + + // special treatment for the (thermal) enthalpy and internal energy fields to save a little bit of space + if( m_thermalFlag ) + { + m_phaseEnthalpy.value.resize( size, numPts, numPhase ); + m_phaseEnthalpy.dPres.resize( size, numPts, numPhase ); + m_phaseEnthalpy.dTemp.resize( size, numPts, numPhase ); + m_phaseEnthalpy.dComp.resize( size, numPts, numPhase, numComp ); + + m_phaseInternalEnergy.value.resize( size, numPts, numPhase ); + m_phaseInternalEnergy.dPres.resize( size, numPts, numPhase ); + m_phaseInternalEnergy.dTemp.resize( size, numPts, numPhase ); + m_phaseInternalEnergy.dComp.resize( size, numPts, numPhase, numComp ); + } + else + { + m_phaseEnthalpy.value.resize( size, numPts, 0 ); + m_phaseEnthalpy.dPres.resize( size, numPts, 0 ); + m_phaseEnthalpy.dTemp.resize( size, numPts, 0 ); + m_phaseEnthalpy.dComp.resize( size, numPts, 0, 0 ); + + m_phaseInternalEnergy.value.resize( size, numPts, 0 ); + m_phaseInternalEnergy.dPres.resize( size, numPts, 0 ); + m_phaseInternalEnergy.dTemp.resize( size, numPts, 0 ); + m_phaseInternalEnergy.dComp.resize( size, numPts, 0, 0 ); + } + } void MultiFluidBase::setLabels() @@ -136,6 +177,12 @@ void MultiFluidBase::setLabels() getExtrinsicData< extrinsicMeshData::multifluid::phaseViscosity >(). setDimLabels( 2, m_phaseNames ); + getExtrinsicData< extrinsicMeshData::multifluid::phaseEnthalpy >(). + setDimLabels( 2, m_phaseNames ); + + getExtrinsicData< extrinsicMeshData::multifluid::phaseInternalEnergy >(). + setDimLabels( 2, m_phaseNames ); + getExtrinsicData< extrinsicMeshData::multifluid::phaseCompFraction >(). setDimLabels( 2, m_phaseNames ). setDimLabels( 3, m_componentNames ); @@ -178,6 +225,6 @@ void MultiFluidBase::postProcessInput() setLabels(); } -} //namespace constitutive +} // namespace constitutive -} //namespace geosx +} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index d2c031073e6..b904a1cc80f 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -89,6 +89,14 @@ class MultiFluidBase : public ConstitutiveBase */ virtual integer getWaterPhaseIndex() const = 0; + /** + * @brief Get the thermal flag. + * @return boolean value indicating whether the model can be used to assemble the energy balance equation or not + * @detail if thermalFlag is true, the constitutive model compute the enthalpy and internal energy of the phase. + * This can be used to check the compatibility of the constitutive model with the solver + */ + bool getThermalFlag() const { return m_thermalFlag; } + /** * @brief Get the mass flag. * @return boolean value indicating whether the model is using mass-based quantities (as opposed to mole-based) @@ -179,6 +187,29 @@ class MultiFluidBase : public ConstitutiveBase arrayView2d< real64 const, multifluid::USD_FLUID > initialTotalMassDensity() const { return m_initialTotalMassDensity.toViewConst(); } + arrayView3d< real64 const, multifluid::USD_PHASE > phaseEnthalpy() const + { return m_phaseEnthalpy.value; } + + arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseEnthalpy_dPressure() const + { return m_phaseEnthalpy.dPres; } + + arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseEnthalpy_dTemperature() const + { return m_phaseEnthalpy.dTemp; } + + arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseEnthalpy_dGlobalCompFraction() const + { return m_phaseEnthalpy.dComp; } + + arrayView3d< real64 const, multifluid::USD_PHASE > phaseInternalEnergy() const + { return m_phaseInternalEnergy.value; } + + arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseInternalEnergy_dPressure() const + { return m_phaseInternalEnergy.dPres; } + + arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseInternalEnergy_dTemperature() const + { return m_phaseInternalEnergy.dTemp; } + + arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseInternalEnergy_dGlobalCompFraction() const + { return m_phaseInternalEnergy.dComp; } struct viewKeyStruct : ConstitutiveBase::viewKeyStruct { @@ -186,6 +217,7 @@ class MultiFluidBase : public ConstitutiveBase static constexpr char const * componentMolarWeightString() { return "componentMolarWeight"; } static constexpr char const * phaseNamesString() { return "phaseNames"; } static constexpr char const * useMassString() { return "useMass"; } + static constexpr char const * thermalFlagString() { return "thermalFlag"; } }; protected: @@ -242,6 +274,8 @@ class MultiFluidBase : public ConstitutiveBase PhaseProp::ViewType phaseDensity, PhaseProp::ViewType phaseMassDensity, PhaseProp::ViewType phaseViscosity, + PhaseProp::ViewType phaseEnthalpy, + PhaseProp::ViewType phaseInternalEnergy, PhaseComp::ViewType phaseCompFraction, FluidProp::ViewType totalDensity ) : m_componentMolarWeight( std::move( componentMolarWeight ) ), @@ -250,6 +284,8 @@ class MultiFluidBase : public ConstitutiveBase m_phaseDensity( std::move( phaseDensity ) ), m_phaseMassDensity( std::move( phaseMassDensity ) ), m_phaseViscosity( std::move( phaseViscosity ) ), + m_phaseEnthalpy( std::move( phaseEnthalpy ) ), + m_phaseInternalEnergy( std::move( phaseInternalEnergy ) ), m_phaseCompFraction( std::move( phaseCompFraction ) ), m_totalDensity( std::move( totalDensity ) ) { } @@ -262,6 +298,8 @@ class MultiFluidBase : public ConstitutiveBase PhaseProp::ViewType m_phaseDensity; PhaseProp::ViewType m_phaseMassDensity; PhaseProp::ViewType m_phaseViscosity; + PhaseProp::ViewType m_phaseEnthalpy; + PhaseProp::ViewType m_phaseInternalEnergy; PhaseComp::ViewType m_phaseCompFraction; FluidProp::ViewType m_totalDensity; @@ -275,6 +313,8 @@ class MultiFluidBase : public ConstitutiveBase arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseEnthalpy, + arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, arraySlice2d< real64, multifluid::USD_PHASE_COMP-2 > const & phaseCompFraction, real64 & totalDensity ) const = 0; @@ -286,6 +326,8 @@ class MultiFluidBase : public ConstitutiveBase PhaseProp::SliceType const phaseDensity, PhaseProp::SliceType const phaseMassDensity, PhaseProp::SliceType const phaseViscosity, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, PhaseComp::SliceType const phaseCompFraction, FluidProp::SliceType const totalDensity ) const = 0; @@ -315,6 +357,9 @@ class MultiFluidBase : public ConstitutiveBase virtual void postProcessInput() override; + // flag indicating whether the constitutive model can be used to assemble the energy balance or not + int m_thermalFlag; + // flag indicating whether input/output component fractions are treated as mass fractions int m_useMass; @@ -330,6 +375,8 @@ class MultiFluidBase : public ConstitutiveBase PhaseProp m_phaseDensity; PhaseProp m_phaseMassDensity; PhaseProp m_phaseViscosity; + PhaseProp m_phaseEnthalpy; + PhaseProp m_phaseInternalEnergy; PhaseComp m_phaseCompFraction; FluidProp m_totalDensity; diff --git a/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp b/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp index 6bed4970a96..4307a74586a 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp @@ -166,6 +166,70 @@ EXTRINSIC_MESH_DATA_TRAIT( dPhaseViscosity_dGlobalCompFraction, NO_WRITE, "Derivative of phase viscosity with respect to global component fraction" ); +EXTRINSIC_MESH_DATA_TRAIT( phaseEnthalpy, + "phaseEnthalpy", + array3dLayoutPhase, + 0, + NOPLOT, // default behavior overridden by thermal models + NO_WRITE, + "Phase enthalpy" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseEnthalpy_dPressure, + "dPhaseEnthalpy_dPressure", + array3dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase enthalpy with respect to pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseEnthalpy_dTemperature, + "dPhaseEnthalpy_dTemperature", + array3dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase enthalpy with respect to temperature" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseEnthalpy_dGlobalCompFraction, + "dPhaseEnthalpy_dGlobalCompFraction", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase enthalpy with respect to global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseInternalEnergy, + "phaseInternalEnergy", + array3dLayoutPhase, + 0, + NOPLOT, // default behavior overridden by thermal models + NO_WRITE, + "Phase internal energy" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseInternalEnergy_dPressure, + "dPhaseInternalEnergy_dPressure", + array3dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase internal energy with respect to pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseInternalEnergy_dTemperature, + "dPhaseInternalEnergy_dTemperature", + array3dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase internal energy with respect to temperature" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseInternalEnergy_dGlobalCompFraction, + "dPhaseInternalEnergy_dGlobalCompFraction", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase internal energy with respect to global component fraction" ); + EXTRINSIC_MESH_DATA_TRAIT( phaseCompFraction, "phaseCompFraction", array4dLayoutPhaseComp, diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp deleted file mode 100644 index b8df793d38d..00000000000 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 TotalEnergies - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file MultiPhaseMultiComponentFluid.cpp - */ -#include "MultiPhaseMultiComponentFluid.hpp" - -#include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" - -namespace geosx -{ - -using namespace dataRepository; - -namespace constitutive -{ - -using namespace PVTProps; - -namespace -{ -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > class - TwoPhaseCatalogNames {}; - -template<> class - TwoPhaseCatalogNames< PVTProps::PhillipsBrineDensity, - PVTProps::PhillipsBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility > -{ -public: - static string name() { return "CO2BrinePhillipsFluid"; } -}; -template<> class - TwoPhaseCatalogNames< PVTProps::EzrokhiBrineDensity, - PVTProps::EzrokhiBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility > -{ -public: - static string name() { return "CO2BrineEzrokhiFluid"; } -}; -} // end namespace - -// provide a definition for catalogName() -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -string MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::catalogName() -{ - return TwoPhaseCatalogNames< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::name(); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >:: -MultiPhaseMultiComponentFluid( string const & name, Group * const parent ): - MultiFluidBase( name, parent ) -{ - registerWrapper( viewKeyStruct::phasePVTParaFilesString(), &m_phasePVTParaFiles ). - setInputFlag( InputFlags::REQUIRED ). - setRestartFlags( RestartFlags::NO_WRITE ). - setDescription( "Names of the files defining the parameters of the viscosity and density models" ); - - registerWrapper( viewKeyStruct::flashModelParaFileString(), &m_flashModelParaFile ). - setInputFlag( InputFlags::REQUIRED ). - setRestartFlags( RestartFlags::NO_WRITE ). - setDescription( "Name of the file defining the parameters of the flash model" ); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -std::unique_ptr< ConstitutiveBase > -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >:: -deliverClone( string const & name, Group * const parent ) const -{ - std::unique_ptr< ConstitutiveBase > clone = MultiFluidBase::deliverClone( name, parent ); - - MultiPhaseMultiComponentFluid & newConstitutiveRelation = dynamicCast< MultiPhaseMultiComponentFluid & >( *clone ); - newConstitutiveRelation.m_p1Index = m_p1Index; - newConstitutiveRelation.m_p2Index = m_p2Index; - - newConstitutiveRelation.createPVTModels(); - - return clone; -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -integer MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::getWaterPhaseIndex() const -{ - string const expectedWaterPhaseNames[] = { "Water", "water", "Liquid", "liquid" }; - return PVTFunctionHelpers::findName( m_phaseNames, expectedWaterPhaseNames, viewKeyStruct::phaseNamesString() ); -} - - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -void MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::postProcessInput() -{ - MultiFluidBase::postProcessInput(); - - GEOSX_THROW_IF_NE_MSG( numFluidPhases(), 2, - GEOSX_FMT( "{}: invalid number of phases", getFullName() ), - InputError ); - GEOSX_THROW_IF_NE_MSG( numFluidComponents(), 2, - GEOSX_FMT( "{}: invalid number of components", getFullName() ), - InputError ); - GEOSX_THROW_IF_NE_MSG( m_phasePVTParaFiles.size(), 2, - GEOSX_FMT( "{}: invalid number of values in attribute '{}'", getFullName() ), - InputError ); - - // NOTE: for now, the names of the phases are still hardcoded here - // Later, we could read them from the XML file and we would then have a general class here - - string const expectedWaterPhaseNames[] = { "Water", "water", "Liquid", "liquid" }; - m_p1Index = PVTFunctionHelpers::findName( m_phaseNames, expectedWaterPhaseNames, viewKeyStruct::phaseNamesString() ); - - string const expectedGasPhaseNames[] = { "CO2", "co2", "gas", "Gas" }; - m_p2Index = PVTFunctionHelpers::findName( m_phaseNames, expectedGasPhaseNames, viewKeyStruct::phaseNamesString() ); - - createPVTModels(); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -void MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::createPVTModels() -{ - // 1) Create the viscosity and density models - for( string const & filename : m_phasePVTParaFiles ) - { - std::ifstream is( filename ); - string str; - while( std::getline( is, str ) ) - { - string_array const strs = stringutilities::tokenize( str, " " ); - - if( strs[0] == "DensityFun" ) - { - if( strs[1] == P1DENS::catalogName() ) - { - m_p1Density = std::make_unique< P1DENS >( getName() + '_' + P1DENS::catalogName(), strs, m_componentNames, m_componentMolarWeight ); - } - else if( strs[1] == P2DENS::catalogName() ) - { - m_p2Density = std::make_unique< P2DENS >( getName() + '_' + P2DENS::catalogName(), strs, m_componentNames, m_componentMolarWeight ); - } - } - else if( strs[0] == "ViscosityFun" ) - { - if( strs[1] == P1VISC::catalogName() ) - { - m_p1Viscosity = std::make_unique< P1VISC >( getName() + '_' + P1VISC::catalogName(), strs, m_componentNames, m_componentMolarWeight ); - } - else if( strs[1] == P2VISC::catalogName() ) - { - m_p2Viscosity = std::make_unique< P2VISC >( getName() + '_' + P2VISC::catalogName(), strs, m_componentNames, m_componentMolarWeight ); - } - } - else - { - GEOSX_THROW( GEOSX_FMT( "{}: invalid PVT function type '{}'", getFullName(), strs[0] ), InputError ); - } - } - is.close(); - } - - GEOSX_THROW_IF( m_p1Density == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1DENS::catalogName() ), - InputError ); - GEOSX_THROW_IF( m_p2Density == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2DENS::catalogName() ), - InputError ); - GEOSX_THROW_IF( m_p1Viscosity == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1VISC::catalogName() ), - InputError ); - GEOSX_THROW_IF( m_p2Viscosity == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2VISC::catalogName() ), - InputError ); - - // 2) Create the flash model - { - std::ifstream is( m_flashModelParaFile ); - string str; - while( std::getline( is, str ) ) - { - string_array const strs = stringutilities::tokenize( str, " " ); - if( strs[0] == "FlashModel" ) - { - if( strs[1] == FLASH::catalogName() ) - { - m_flash = std::make_unique< FLASH >( getName() + '_' + FLASH::catalogName(), strs, m_phaseNames, m_componentNames, m_componentMolarWeight ); - } - } - else - { - GEOSX_THROW( GEOSX_FMT( "{}: invalid flash model type '{}'", getFullName(), strs[0] ), InputError ); - } - } - is.close(); - } - - GEOSX_THROW_IF( m_flash == nullptr, - GEOSX_FMT( "{}: flash model {} not found in input files", getFullName(), FLASH::catalogName() ), - InputError ); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -typename MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWrapper -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::createKernelWrapper() -{ - return KernelWrapper( m_p1Index, - m_p2Index, - *m_p1Density, - *m_p1Viscosity, - *m_p2Density, - *m_p2Viscosity, - *m_flash, - m_componentMolarWeight.toViewConst(), - m_useMass, - m_phaseFraction.toView(), - m_phaseDensity.toView(), - m_phaseMassDensity.toView(), - m_phaseViscosity.toView(), - m_phaseCompFraction.toView(), - m_totalDensity.toView() ); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWrapper:: - KernelWrapper( localIndex const p1Index, - localIndex const p2Index, - P1DENS const & p1DensityWrapper, - P1VISC const & p1ViscosityWrapper, - P2DENS const & p2DensityWrapper, - P2VISC const & p2ViscosityWrapper, - FLASH const & flashWrapper, - arrayView1d< geosx::real64 const > componentMolarWeight, - bool const useMass, - PhaseProp::ViewType phaseFraction, - PhaseProp::ViewType phaseDensity, - PhaseProp::ViewType phaseMassDensity, - PhaseProp::ViewType phaseViscosity, - PhaseComp::ViewType phaseCompFraction, - FluidProp::ViewType totalDensity ) - : MultiFluidBase::KernelWrapper( std::move( componentMolarWeight ), - useMass, - std::move( phaseFraction ), - std::move( phaseDensity ), - std::move( phaseMassDensity ), - std::move( phaseViscosity ), - std::move( phaseCompFraction ), - std::move( totalDensity ) ), - m_p1Index( p1Index ), - m_p2Index( p2Index ), - m_p1Density( p1DensityWrapper.createKernelWrapper() ), - m_p1Viscosity( p1ViscosityWrapper.createKernelWrapper() ), - m_p2Density( p2DensityWrapper.createKernelWrapper() ), - m_p2Viscosity( p2ViscosityWrapper.createKernelWrapper() ), - m_flash( flashWrapper.createKernelWrapper() ) -{} - -// explicit instantiation of the model template; unfortunately we can't use CO2BrinePhillipsFluid alias for this -template class MultiPhaseMultiComponentFluid< PVTProps::PhillipsBrineDensity, - PVTProps::PhillipsBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility >; - -template class MultiPhaseMultiComponentFluid< PVTProps::EzrokhiBrineDensity, - PVTProps::EzrokhiBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility >; - -REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrinePhillipsFluid, string const &, Group * const ) -REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrineEzrokhiFluid, string const &, Group * const ) - -} //namespace constitutive - -} //namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/NoOpPVTFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/NoOpPVTFunction.hpp new file mode 100644 index 00000000000..20696513f29 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/NoOpPVTFunction.hpp @@ -0,0 +1,126 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file NoOpPVTFunction.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_NOOPPVTFUNCTION_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_NOOPPVTFUNCTION_HPP_ + +#include "PVTFunctionBase.hpp" + +namespace geosx +{ + +namespace constitutive +{ + +namespace PVTProps +{ + +class NoOpPVTFunctionUpdate final : public PVTFunctionBaseUpdate +{ +public: + + NoOpPVTFunctionUpdate( arrayView1d< real64 const > const & componentMolarWeight ) + : PVTFunctionBaseUpdate( componentMolarWeight ) + {} + + template< int USD1 > + GEOSX_HOST_DEVICE + void compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const + { + GEOSX_UNUSED_VAR( pressure, temperature, phaseComposition, value, useMass ); + } + + template< int USD1, int USD2, int USD3, int USD4 > + GEOSX_HOST_DEVICE + void compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, + arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, + arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + bool useMass ) const + { + GEOSX_UNUSED_VAR( pressure, temperature, + phaseComposition, dPhaseComposition_dPressure, dPhaseComposition_dTemperature, dPhaseComposition_dTemperature, dPhaseComposition_dGlobalCompFraction, + value, dValue_dPressure, dValue_dTemperature, dValue_dGlobalCompFraction, + useMass ); + } + + virtual void move( LvArray::MemorySpace const space, bool const touch ) override + { + PVTFunctionBaseUpdate::move( space, touch ); + } + +}; + + +class NoOpPVTFunction : public PVTFunctionBase +{ +public: + + NoOpPVTFunction( string const & name, + string_array const & inputPara, + string_array const & componentNames, + array1d< real64 > const & componentMolarWeight ) + : PVTFunctionBase( name, + componentNames, + componentMolarWeight ) + { + GEOSX_UNUSED_VAR( inputPara ); + } + + virtual ~NoOpPVTFunction() override = default; + + static string catalogName() { return "NoOpPVTFunction"; } + + virtual string getCatalogName() const override final { return catalogName(); } + + virtual PVTFunctionType functionType() const override + { + return PVTFunctionType::UNKNOWN; + } + + /// Type of kernel wrapper for in-kernel update + using KernelWrapper = NoOpPVTFunctionUpdate; + + /** + * @brief Create an update kernel wrapper. + * @return the wrapper + */ + KernelWrapper createKernelWrapper() const + { + return KernelWrapper( m_componentMolarWeight ); + }; + +}; + +} // end namespace PVTProps + +} // end namespace constitutive + +} // end namespace geosx + +#endif //GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_NOOPPVTFUNCTION_HPP_ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp index 4968b9c7169..f1c432a5680 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp @@ -30,7 +30,7 @@ namespace constitutive namespace PVTProps { -enum class PVTFunctionType { UNKNOWN, DENSITY, VISCOSITY, ENTHALPY, INTERNAL_ENERGY}; +enum class PVTFunctionType { UNKNOWN, DENSITY, VISCOSITY, ENTHALPY, INTERNAL_ENERGY }; class PVTFunctionBaseUpdate { diff --git a/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp index 4a0f281169d..96321059c35 100644 --- a/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp @@ -21,7 +21,7 @@ #include "constitutive/ConstitutivePassThruHandler.hpp" #include "constitutive/fluid/DeadOilFluid.hpp" #include "constitutive/fluid/BlackOilFluid.hpp" -#include "constitutive/fluid/MultiPhaseMultiComponentFluid.hpp" +#include "constitutive/fluid/CO2BrineFluid.hpp" #include "common/GeosxConfig.hpp" #ifdef GEOSX_USE_PVTPackage diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp index 9116b51dd81..578309a0b0c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp @@ -1145,6 +1145,8 @@ struct HydrostaticPressureKernel StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseDens( 1, 1, numPhases ); StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseMassDens( 1, 1, numPhases ); StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseVisc( 1, 1, numPhases ); + StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseEnthalpy( 1, 1, numPhases ); + StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseInternalEnergy( 1, 1, numPhases ); StackArray< real64, 4, constitutive::MultiFluidBase::MAX_NUM_PHASES *constitutive::MultiFluidBase::MAX_NUM_COMPONENTS, multifluid::LAYOUT_PHASE_COMP > phaseCompFrac( 1, 1, numPhases, numComps ); real64 totalDens = 0.0; @@ -1174,6 +1176,8 @@ struct HydrostaticPressureKernel phaseDens[0][0], phaseMassDens[0][0], phaseVisc[0][0], + phaseEnthalpy[0][0], + phaseInternalEnergy[0][0], phaseCompFrac[0][0], totalDens ); pres1 = refPres - 0.5 * ( refPhaseMassDens[ipInit] + phaseMassDens[0][0][ipInit] ) * gravCoef; @@ -1217,6 +1221,8 @@ struct HydrostaticPressureKernel phaseDens[0][0], phaseMassDens[0][0], phaseVisc[0][0], + phaseEnthalpy[0][0], + phaseInternalEnergy[0][0], phaseCompFrac[0][0], totalDens ); pres1 = refPres - 0.5 * ( refPhaseMassDens[ipInit] + phaseMassDens[0][0][ipInit] ) * gravCoef; @@ -1274,6 +1280,8 @@ struct HydrostaticPressureKernel array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseDens( 1, 1, numPhases ); array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseMassDens( 1, 1, numPhases ); array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseVisc( 1, 1, numPhases ); + array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseEnthalpy( 1, 1, numPhases ); + array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseInternalEnergy( 1, 1, numPhases ); array4d< real64, multifluid::LAYOUT_PHASE_COMP > datumPhaseCompFrac( 1, 1, numPhases, numComps ); real64 datumTotalDens = 0.0; @@ -1289,6 +1297,8 @@ struct HydrostaticPressureKernel datumPhaseDens[0][0], datumPhaseMassDens[0][0], datumPhaseVisc[0][0], + datumPhaseEnthalpy[0][0], + datumPhaseInternalEnergy[0][0], datumPhaseCompFrac[0][0], datumTotalDens ); diff --git a/src/coreComponents/schema/docs/BlackOilFluid_other.rst b/src/coreComponents/schema/docs/BlackOilFluid_other.rst index 19795673132..bbaf9ca9af6 100644 --- a/src/coreComponents/schema/docs/BlackOilFluid_other.rst +++ b/src/coreComponents/schema/docs/BlackOilFluid_other.rst @@ -1,40 +1,49 @@ -====================================== ========================================================================================================= ================================================================================ -Name Type Description -====================================== ========================================================================================================= ================================================================================ -PVTO geosx_constitutive_PVTOData (no description available) -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -formationVolFactorTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -hydrocarbonPhaseOrder integer_array (no description available) -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseOrder integer_array (no description available) -phaseTypes integer_array (no description available) -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -====================================== ========================================================================================================= ================================================================================ +======================================== ========================================================================================================= ================================================================================ +Name Type Description +======================================== ========================================================================================================= ================================================================================ +PVTO geosx_constitutive_PVTOData (no description available) +dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction +dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure +dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature +dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction +dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure +dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy with respect to temperature +dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction +dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure +dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy with respect to temperature +dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction +dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure +dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature +dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction +dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure +dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature +dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction +dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure +dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature +formationVolFactorTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +hydrocarbonPhaseOrder integer_array (no description available) +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +phaseMassDensity real64_array3d Phase mass density +phaseOrder integer_array (no description available) +phaseTypes integer_array (no description available) +phaseViscosity real64_array3d Phase viscosity +thermalFlag integer (no description available) +totalDensity real64_array2d Total density +useMass integer (no description available) +viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +======================================== ========================================================================================================= ================================================================================ diff --git a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst index 81781e92fc2..8f4598a516a 100644 --- a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst @@ -1,34 +1,43 @@ -====================================== ============================================================================================== ================================================================================ -Name Type Description -====================================== ============================================================================================== ================================================================================ -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -====================================== ============================================================================================== ================================================================================ +======================================== ============================================================================================== ================================================================================ +Name Type Description +======================================== ============================================================================================== ================================================================================ +dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction +dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure +dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature +dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction +dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure +dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy with respect to temperature +dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction +dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure +dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy with respect to temperature +dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction +dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure +dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature +dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction +dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure +dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature +dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction +dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure +dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +phaseMassDensity real64_array3d Phase mass density +phaseViscosity real64_array3d Phase viscosity +thermalFlag integer (no description available) +totalDensity real64_array2d Total density +useMass integer (no description available) +======================================== ============================================================================================== ================================================================================ diff --git a/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid.rst b/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid.rst new file mode 100644 index 00000000000..2010eb6efc8 --- /dev/null +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid.rst @@ -0,0 +1,14 @@ + + +==================== ============ ======== ============================================================================== +Name Type Default Description +==================== ============ ======== ============================================================================== +componentMolarWeight real64_array {0} Component molar weights +componentNames string_array {} List of component names +flashModelParaFile path required Name of the file defining the parameters of the flash model +name string required A name is required for any non-unique nodes +phaseNames string_array {} List of fluid phases +phasePVTParaFiles path_array required Names of the files defining the parameters of the viscosity and density models +==================== ============ ======== ============================================================================== + + diff --git a/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst b/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst new file mode 100644 index 00000000000..8f4598a516a --- /dev/null +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst @@ -0,0 +1,43 @@ + + +======================================== ============================================================================================== ================================================================================ +Name Type Description +======================================== ============================================================================================== ================================================================================ +dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction +dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure +dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature +dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction +dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure +dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy with respect to temperature +dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction +dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure +dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy with respect to temperature +dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction +dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure +dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature +dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction +dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure +dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature +dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction +dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure +dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +phaseMassDensity real64_array3d Phase mass density +phaseViscosity real64_array3d Phase viscosity +thermalFlag integer (no description available) +totalDensity real64_array2d Total density +useMass integer (no description available) +======================================== ============================================================================================== ================================================================================ + + diff --git a/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst b/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst index 81781e92fc2..8f4598a516a 100644 --- a/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst @@ -1,34 +1,43 @@ -====================================== ============================================================================================== ================================================================================ -Name Type Description -====================================== ============================================================================================== ================================================================================ -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -====================================== ============================================================================================== ================================================================================ +======================================== ============================================================================================== ================================================================================ +Name Type Description +======================================== ============================================================================================== ================================================================================ +dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction +dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure +dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature +dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction +dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure +dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy with respect to temperature +dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction +dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure +dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy with respect to temperature +dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction +dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure +dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature +dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction +dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure +dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature +dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction +dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure +dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +phaseMassDensity real64_array3d Phase mass density +phaseViscosity real64_array3d Phase viscosity +thermalFlag integer (no description available) +totalDensity real64_array2d Total density +useMass integer (no description available) +======================================== ============================================================================================== ================================================================================ diff --git a/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid.rst b/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid.rst new file mode 100644 index 00000000000..2010eb6efc8 --- /dev/null +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid.rst @@ -0,0 +1,14 @@ + + +==================== ============ ======== ============================================================================== +Name Type Default Description +==================== ============ ======== ============================================================================== +componentMolarWeight real64_array {0} Component molar weights +componentNames string_array {} List of component names +flashModelParaFile path required Name of the file defining the parameters of the flash model +name string required A name is required for any non-unique nodes +phaseNames string_array {} List of fluid phases +phasePVTParaFiles path_array required Names of the files defining the parameters of the viscosity and density models +==================== ============ ======== ============================================================================== + + diff --git a/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst b/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst new file mode 100644 index 00000000000..8f4598a516a --- /dev/null +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst @@ -0,0 +1,43 @@ + + +======================================== ============================================================================================== ================================================================================ +Name Type Description +======================================== ============================================================================================== ================================================================================ +dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction +dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure +dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature +dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction +dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure +dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy with respect to temperature +dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction +dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure +dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy with respect to temperature +dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction +dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure +dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature +dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction +dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure +dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature +dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction +dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure +dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +phaseMassDensity real64_array3d Phase mass density +phaseViscosity real64_array3d Phase viscosity +thermalFlag integer (no description available) +totalDensity real64_array2d Total density +useMass integer (no description available) +======================================== ============================================================================================== ================================================================================ + + diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst index 81781e92fc2..8f4598a516a 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst @@ -1,34 +1,43 @@ -====================================== ============================================================================================== ================================================================================ -Name Type Description -====================================== ============================================================================================== ================================================================================ -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -====================================== ============================================================================================== ================================================================================ +======================================== ============================================================================================== ================================================================================ +Name Type Description +======================================== ============================================================================================== ================================================================================ +dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction +dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure +dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature +dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction +dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure +dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy with respect to temperature +dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction +dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure +dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy with respect to temperature +dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction +dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure +dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature +dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction +dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure +dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature +dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction +dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure +dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +phaseMassDensity real64_array3d Phase mass density +phaseViscosity real64_array3d Phase viscosity +thermalFlag integer (no description available) +totalDensity real64_array2d Total density +useMass integer (no description available) +======================================== ============================================================================================== ================================================================================ diff --git a/src/coreComponents/schema/docs/Constitutive.rst b/src/coreComponents/schema/docs/Constitutive.rst index 8c3fe7b6108..25baa0182e0 100644 --- a/src/coreComponents/schema/docs/Constitutive.rst +++ b/src/coreComponents/schema/docs/Constitutive.rst @@ -9,7 +9,9 @@ BrooksCoreyBakerRelativePermeability node :ref:`XML_BrooksCoreyBa BrooksCoreyCapillaryPressure node :ref:`XML_BrooksCoreyCapillaryPressure` BrooksCoreyRelativePermeability node :ref:`XML_BrooksCoreyRelativePermeability` CO2BrineEzrokhiFluid node :ref:`XML_CO2BrineEzrokhiFluid` +CO2BrineEzrokhiThermalFluid node :ref:`XML_CO2BrineEzrokhiThermalFluid` CO2BrinePhillipsFluid node :ref:`XML_CO2BrinePhillipsFluid` +CO2BrinePhillipsThermalFluid node :ref:`XML_CO2BrinePhillipsThermalFluid` CarmanKozenyPermeability node :ref:`XML_CarmanKozenyPermeability` CompositionalMultiphaseFluid node :ref:`XML_CompositionalMultiphaseFluid` CompressibleSinglePhaseFluid node :ref:`XML_CompressibleSinglePhaseFluid` diff --git a/src/coreComponents/schema/docs/Constitutive_other.rst b/src/coreComponents/schema/docs/Constitutive_other.rst index 86d9d564051..ad970014f9b 100644 --- a/src/coreComponents/schema/docs/Constitutive_other.rst +++ b/src/coreComponents/schema/docs/Constitutive_other.rst @@ -9,7 +9,9 @@ BrooksCoreyBakerRelativePermeability node :ref:`DATASTRUCTURE_BrooksCorey BrooksCoreyCapillaryPressure node :ref:`DATASTRUCTURE_BrooksCoreyCapillaryPressure` BrooksCoreyRelativePermeability node :ref:`DATASTRUCTURE_BrooksCoreyRelativePermeability` CO2BrineEzrokhiFluid node :ref:`DATASTRUCTURE_CO2BrineEzrokhiFluid` +CO2BrineEzrokhiThermalFluid node :ref:`DATASTRUCTURE_CO2BrineEzrokhiThermalFluid` CO2BrinePhillipsFluid node :ref:`DATASTRUCTURE_CO2BrinePhillipsFluid` +CO2BrinePhillipsThermalFluid node :ref:`DATASTRUCTURE_CO2BrinePhillipsThermalFluid` CarmanKozenyPermeability node :ref:`DATASTRUCTURE_CarmanKozenyPermeability` CompositionalMultiphaseFluid node :ref:`DATASTRUCTURE_CompositionalMultiphaseFluid` CompressibleSinglePhaseFluid node :ref:`DATASTRUCTURE_CompressibleSinglePhaseFluid` diff --git a/src/coreComponents/schema/docs/DeadOilFluid_other.rst b/src/coreComponents/schema/docs/DeadOilFluid_other.rst index 9538942463e..e2ecefa06dd 100644 --- a/src/coreComponents/schema/docs/DeadOilFluid_other.rst +++ b/src/coreComponents/schema/docs/DeadOilFluid_other.rst @@ -1,39 +1,48 @@ -====================================== ========================================================================================================= ================================================================================ -Name Type Description -====================================== ========================================================================================================= ================================================================================ -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -formationVolFactorTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -hydrocarbonPhaseOrder integer_array (no description available) -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseOrder integer_array (no description available) -phaseTypes integer_array (no description available) -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -====================================== ========================================================================================================= ================================================================================ +======================================== ========================================================================================================= ================================================================================ +Name Type Description +======================================== ========================================================================================================= ================================================================================ +dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction +dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure +dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature +dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction +dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure +dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy with respect to temperature +dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction +dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure +dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy with respect to temperature +dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction +dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure +dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature +dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction +dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure +dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature +dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction +dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure +dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature +formationVolFactorTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +hydrocarbonPhaseOrder integer_array (no description available) +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +phaseMassDensity real64_array3d Phase mass density +phaseOrder integer_array (no description available) +phaseTypes integer_array (no description available) +phaseViscosity real64_array3d Phase viscosity +thermalFlag integer (no description available) +totalDensity real64_array2d Total density +useMass integer (no description available) +viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +======================================== ========================================================================================================= ================================================================================ diff --git a/src/coreComponents/schema/docs/domain_other.rst b/src/coreComponents/schema/docs/domain_other.rst index 51d7cb0552f..0d3fc3f0834 100644 --- a/src/coreComponents/schema/docs/domain_other.rst +++ b/src/coreComponents/schema/docs/domain_other.rst @@ -7,7 +7,6 @@ Neighbors std_vector< geosx_NeighborCommunicator, std_allocator< geosx_Ne partitionManager geosx_PartitionBase (no description available) Constitutive node :ref:`DATASTRUCTURE_Constitutive` MeshBodies node :ref:`DATASTRUCTURE_MeshBodies` -cellManager node :ref:`DATASTRUCTURE_cellManager` ================ ===================================================================================== ================================= diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 3a7ad617c2f..f0832493526 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1936,7 +1936,9 @@ Equal to 1 for surface conditions, and to 0 for reservoir conditions--> + + @@ -2081,6 +2083,20 @@ The expected format is "{ waterMax, oilMax }", in that order--> + + + + + + + + + + + + + + @@ -2095,6 +2111,20 @@ The expected format is "{ waterMax, oilMax }", in that order--> + + + + + + + + + + + + + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index d6ccb3102ba..1f7c64120a8 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -768,7 +768,6 @@ - @@ -783,7 +782,9 @@ + + @@ -859,12 +860,24 @@ + + + + + + + + + + + + @@ -893,8 +906,12 @@ + + + + @@ -903,6 +920,8 @@ + + @@ -959,12 +978,24 @@ + + + + + + + + + + + + @@ -989,12 +1020,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1013,12 +1122,24 @@ + + + + + + + + + + + + @@ -1043,12 +1164,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1075,12 +1274,24 @@ + + + + + + + + + + + + @@ -1105,12 +1316,18 @@ + + + + + + @@ -1209,12 +1426,24 @@ + + + + + + + + + + + + @@ -1243,8 +1472,12 @@ + + + + @@ -1253,6 +1486,8 @@ + + @@ -1903,24 +2138,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp index 907f588ec3b..4767d8e98d7 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp @@ -318,6 +318,14 @@ void testValuesAgainstPreviousImplementation( CO2BrinePhillipsFluid::KernelWrapp StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseViscosity_dPressure( 1, 1, 2 ); StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseViscosity_dTemperature( 1, 1, 2 ); StackArray< real64, 4, 4, LAYOUT_PHASE_DC > dPhaseViscosity_dGlobalCompFraction( 1, 1, 2, 2 ); + StackArray< real64, 3, 2, LAYOUT_PHASE > phaseEnthalpy( 1, 1, 2 ); + StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseEnthalpy_dPressure( 1, 1, 2 ); + StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseEnthalpy_dTemperature( 1, 1, 2 ); + StackArray< real64, 4, 4, LAYOUT_PHASE_DC > dPhaseEnthalpy_dGlobalCompFraction( 1, 1, 2, 2 ); + StackArray< real64, 3, 2, LAYOUT_PHASE > phaseInternalEnergy( 1, 1, 2 ); + StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseInternalEnergy_dPressure( 1, 1, 2 ); + StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseInternalEnergy_dTemperature( 1, 1, 2 ); + StackArray< real64, 4, 4, LAYOUT_PHASE_DC > dPhaseInternalEnergy_dGlobalCompFraction( 1, 1, 2, 2 ); StackArray< real64, 4, 4, LAYOUT_PHASE_COMP > phaseCompFraction( 1, 1, 2, 2 ); StackArray< real64, 4, 4, LAYOUT_PHASE_COMP > dPhaseCompFraction_dPressure( 1, 1, 2, 2 ); StackArray< real64, 4, 4, LAYOUT_PHASE_COMP > dPhaseCompFraction_dTemperature( 1, 1, 2, 2 ); @@ -352,6 +360,18 @@ void testValuesAgainstPreviousImplementation( CO2BrinePhillipsFluid::KernelWrapp dPhaseViscosity_dTemperature[0][0], dPhaseViscosity_dGlobalCompFraction[0][0] }, + { + phaseEnthalpy[0][0], + dPhaseEnthalpy_dPressure[0][0], + dPhaseEnthalpy_dTemperature[0][0], + dPhaseEnthalpy_dGlobalCompFraction[0][0] + }, + { + phaseInternalEnergy[0][0], + dPhaseInternalEnergy_dPressure[0][0], + dPhaseInternalEnergy_dTemperature[0][0], + dPhaseInternalEnergy_dGlobalCompFraction[0][0] + }, { phaseCompFraction[0][0], dPhaseCompFraction_dPressure[0][0], diff --git a/src/docs/sphinx/CompleteXMLSchema.rst b/src/docs/sphinx/CompleteXMLSchema.rst index c13996b6018..f49529519ec 100644 --- a/src/docs/sphinx/CompleteXMLSchema.rst +++ b/src/docs/sphinx/CompleteXMLSchema.rst @@ -92,6 +92,13 @@ Element: CO2BrineEzrokhiFluid .. include:: ../../coreComponents/schema/docs/CO2BrineEzrokhiFluid.rst +.. _XML_CO2BrineEzrokhiThermalFluid: + +Element: CO2BrineEzrokhiThermalFluid +==================================== +.. include:: ../../coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid.rst + + .. _XML_CO2BrinePhillipsFluid: Element: CO2BrinePhillipsFluid @@ -99,6 +106,13 @@ Element: CO2BrinePhillipsFluid .. include:: ../../coreComponents/schema/docs/CO2BrinePhillipsFluid.rst +.. _XML_CO2BrinePhillipsThermalFluid: + +Element: CO2BrinePhillipsThermalFluid +===================================== +.. include:: ../../coreComponents/schema/docs/CO2BrinePhillipsThermalFluid.rst + + .. _XML_CarmanKozenyPermeability: Element: CarmanKozenyPermeability @@ -1076,6 +1090,13 @@ Datastructure: CO2BrineEzrokhiFluid .. include:: ../../coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst +.. _DATASTRUCTURE_CO2BrineEzrokhiThermalFluid: + +Datastructure: CO2BrineEzrokhiThermalFluid +========================================== +.. include:: ../../coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst + + .. _DATASTRUCTURE_CO2BrinePhillipsFluid: Datastructure: CO2BrinePhillipsFluid @@ -1083,6 +1104,13 @@ Datastructure: CO2BrinePhillipsFluid .. include:: ../../coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst +.. _DATASTRUCTURE_CO2BrinePhillipsThermalFluid: + +Datastructure: CO2BrinePhillipsThermalFluid +=========================================== +.. include:: ../../coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst + + .. _DATASTRUCTURE_CarmanKozenyPermeability: Datastructure: CarmanKozenyPermeability @@ -1993,20 +2021,6 @@ Datastructure: WellElementRegionuniqueSubRegion .. include:: ../../coreComponents/schema/docs/WellElementRegionuniqueSubRegion_other.rst -.. _DATASTRUCTURE_cellBlocksKey: - -Datastructure: cellBlocksKey -============================ -.. include:: ../../coreComponents/schema/docs/cellBlocksKey_other.rst - - -.. _DATASTRUCTURE_cellManager: - -Datastructure: cellManager -========================== -.. include:: ../../coreComponents/schema/docs/cellManager_other.rst - - .. _DATASTRUCTURE_commandLine: Datastructure: commandLine From 6eff1282875482dd5621fa82e799761dc6f2c5e9 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Mon, 31 Jan 2022 19:30:55 -0800 Subject: [PATCH 2/7] fixed bug in thermal array sizes --- .../constitutive/fluid/MultiFluidBase.cpp | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp index 9df18f9b245..22778a6f525 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp @@ -123,6 +123,16 @@ void MultiFluidBase::resizeFields( localIndex const size, localIndex const numPt m_phaseViscosity.dTemp.resize( size, numPts, numPhase ); m_phaseViscosity.dComp.resize( size, numPts, numPhase, numComp ); + m_phaseEnthalpy.value.resize( size, numPts, numPhase ); + m_phaseEnthalpy.dPres.resize( size, numPts, numPhase ); + m_phaseEnthalpy.dTemp.resize( size, numPts, numPhase ); + m_phaseEnthalpy.dComp.resize( size, numPts, numPhase, numComp ); + + m_phaseInternalEnergy.value.resize( size, numPts, numPhase ); + m_phaseInternalEnergy.dPres.resize( size, numPts, numPhase ); + m_phaseInternalEnergy.dTemp.resize( size, numPts, numPhase ); + m_phaseInternalEnergy.dComp.resize( size, numPts, numPhase, numComp ); + m_phaseCompFraction.value.resize( size, numPts, numPhase, numComp ); m_phaseCompFraction.dPres.resize( size, numPts, numPhase, numComp ); m_phaseCompFraction.dTemp.resize( size, numPts, numPhase, numComp ); @@ -134,33 +144,6 @@ void MultiFluidBase::resizeFields( localIndex const size, localIndex const numPt m_totalDensity.dComp.resize( size, numPts, numComp ); m_initialTotalMassDensity.resize( size, numPts ); - - // special treatment for the (thermal) enthalpy and internal energy fields to save a little bit of space - if( m_thermalFlag ) - { - m_phaseEnthalpy.value.resize( size, numPts, numPhase ); - m_phaseEnthalpy.dPres.resize( size, numPts, numPhase ); - m_phaseEnthalpy.dTemp.resize( size, numPts, numPhase ); - m_phaseEnthalpy.dComp.resize( size, numPts, numPhase, numComp ); - - m_phaseInternalEnergy.value.resize( size, numPts, numPhase ); - m_phaseInternalEnergy.dPres.resize( size, numPts, numPhase ); - m_phaseInternalEnergy.dTemp.resize( size, numPts, numPhase ); - m_phaseInternalEnergy.dComp.resize( size, numPts, numPhase, numComp ); - } - else - { - m_phaseEnthalpy.value.resize( size, numPts, 0 ); - m_phaseEnthalpy.dPres.resize( size, numPts, 0 ); - m_phaseEnthalpy.dTemp.resize( size, numPts, 0 ); - m_phaseEnthalpy.dComp.resize( size, numPts, 0, 0 ); - - m_phaseInternalEnergy.value.resize( size, numPts, 0 ); - m_phaseInternalEnergy.dPres.resize( size, numPts, 0 ); - m_phaseInternalEnergy.dTemp.resize( size, numPts, 0 ); - m_phaseInternalEnergy.dComp.resize( size, numPts, 0, 0 ); - } - } void MultiFluidBase::setLabels() From 81d60b4dc44bd19f4aeb4c5cc10cb39ce753c036 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Tue, 1 Feb 2022 19:17:26 -0800 Subject: [PATCH 3/7] apply Sergey's suggestions --- .../constitutive/CMakeLists.txt | 1 + .../constitutive/fluid/CO2BrineFluid.cpp | 269 +++++------ .../constitutive/fluid/CO2BrineFluid.hpp | 453 ++++++++---------- .../constitutive/fluid/MultiFluidBase.cpp | 4 - .../constitutive/fluid/MultiFluidBase.hpp | 4 +- .../constitutive/fluid/PhaseModel.hpp | 160 +++++++ .../schema/docs/BlackOilFluid_other.rst | 1 - .../docs/CO2BrineEzrokhiFluid_other.rst | 1 - .../CO2BrineEzrokhiThermalFluid_other.rst | 1 - .../docs/CO2BrinePhillipsFluid_other.rst | 1 - .../CO2BrinePhillipsThermalFluid_other.rst | 1 - .../CompositionalMultiphaseFluid_other.rst | 1 - .../schema/docs/DeadOilFluid_other.rst | 1 - src/coreComponents/schema/schema.xsd.other | 14 - 14 files changed, 482 insertions(+), 430 deletions(-) create mode 100644 src/coreComponents/constitutive/fluid/PhaseModel.hpp diff --git a/src/coreComponents/constitutive/CMakeLists.txt b/src/coreComponents/constitutive/CMakeLists.txt index 426a401bff6..0137919ef41 100644 --- a/src/coreComponents/constitutive/CMakeLists.txt +++ b/src/coreComponents/constitutive/CMakeLists.txt @@ -29,6 +29,7 @@ set( constitutive_headers fluid/MultiFluidBase.hpp fluid/MultiFluidUtils.hpp fluid/MultiFluidExtrinsicData.hpp + fluid/PhaseModel.hpp fluid/PVTDriver.hpp fluid/PVTOData.hpp fluid/PVTFunctions/PhillipsBrineDensity.hpp diff --git a/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp b/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp index 69e6be4bbe1..262a1d7a9b3 100644 --- a/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp +++ b/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp @@ -32,22 +32,20 @@ using namespace PVTProps; namespace { -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > class +template< typename PHASE1, typename PHASE2, typename FLASH > class TwoPhaseCatalogNames {}; template<> class - TwoPhaseCatalogNames< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + TwoPhaseCatalogNames< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, PVTProps::CO2Solubility > { public: static string name() { return "CO2BrinePhillipsFluid"; } }; template<> class - TwoPhaseCatalogNames< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + TwoPhaseCatalogNames< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, PVTProps::CO2Solubility > { public: @@ -55,16 +53,16 @@ template<> class }; template<> class - TwoPhaseCatalogNames< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + TwoPhaseCatalogNames< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, PVTProps::CO2Solubility > { public: static string name() { return "CO2BrineEzrokhiFluid"; } }; template<> class - TwoPhaseCatalogNames< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + TwoPhaseCatalogNames< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, PVTProps::CO2Solubility > { public: @@ -74,24 +72,14 @@ template<> class } // end namespace // provide a definition for catalogName() -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > -string CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::catalogName() +template< typename PHASE1, typename PHASE2, typename FLASH > +string CO2BrineFluid< PHASE1, PHASE2, FLASH >::catalogName() { - return TwoPhaseCatalogNames< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::name(); + return TwoPhaseCatalogNames< PHASE1, PHASE2, FLASH >::name(); } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > -CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >:: +template< typename PHASE1, typename PHASE2, typename FLASH > +CO2BrineFluid< PHASE1, PHASE2, FLASH >:: CO2BrineFluid( string const & name, Group * const parent ): MultiFluidBase( name, parent ) { @@ -105,13 +93,8 @@ CO2BrineFluid( string const & name, Group * const parent ): setRestartFlags( RestartFlags::NO_WRITE ). setDescription( "Name of the file defining the parameters of the flash model" ); - m_thermalFlag = ( P1ENTH::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && - P1INTENERGY::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && - P2ENTH::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && - P2INTENERGY::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ); - // if this is a thermal model, we need to make sure that the arrays will be properly displayed and saved to restart - if( m_thermalFlag ) + if( isThermal() ) { getExtrinsicData< extrinsicMeshData::multifluid::phaseEnthalpy >(). setPlotLevel( PlotLevel::LEVEL_0 ). @@ -123,13 +106,19 @@ CO2BrineFluid( string const & name, Group * const parent ): } } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > +template< typename PHASE1, typename PHASE2, typename FLASH > +bool CO2BrineFluid< PHASE1, PHASE2, FLASH >::isThermal() const +{ + return ( PHASE1::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && + PHASE1::InternalEnergy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && + PHASE2::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && + PHASE2::InternalEnergy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ); +} + + +template< typename PHASE1, typename PHASE2, typename FLASH > std::unique_ptr< ConstitutiveBase > -CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >:: +CO2BrineFluid< PHASE1, PHASE2, FLASH >:: deliverClone( string const & name, Group * const parent ) const { std::unique_ptr< ConstitutiveBase > clone = MultiFluidBase::deliverClone( name, parent ); @@ -143,24 +132,16 @@ deliverClone( string const & name, Group * const parent ) const return clone; } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > -integer CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::getWaterPhaseIndex() const +template< typename PHASE1, typename PHASE2, typename FLASH > +integer CO2BrineFluid< PHASE1, PHASE2, FLASH >::getWaterPhaseIndex() const { string const expectedWaterPhaseNames[] = { "Water", "water", "Liquid", "liquid" }; return PVTFunctionHelpers::findName( m_phaseNames, expectedWaterPhaseNames, viewKeyStruct::phaseNamesString() ); } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > -void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::postProcessInput() +template< typename PHASE1, typename PHASE2, typename FLASH > +void CO2BrineFluid< PHASE1, PHASE2, FLASH >::postProcessInput() { MultiFluidBase::postProcessInput(); @@ -186,17 +167,18 @@ void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, createPVTModels(); } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > -void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::createPVTModels() +template< typename PHASE1, typename PHASE2, typename FLASH > +void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels() { // TODO: get rid of these external files and move into XML, this is too error prone + // For now, to support the legacy input, we read all the input parameters at once in the arrays below, and then we create the models + array1d< array1d< string > > phase1InputParams; + phase1InputParams.resize( 4 ); + array1d< array1d< string > > phase2InputParams; + phase2InputParams.resize( 4 ); - // 1) Create the viscosity and density models + // 1) Create the viscosity, density, enthalpy, and internal energy models for( string const & filename : m_phasePVTParaFiles ) { std::ifstream is( filename ); @@ -205,48 +187,48 @@ void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, { string_array const strs = stringutilities::tokenize( str, " " ); - if( strs[0] == "DensityFun" ) + if( strs[0] == toString( SubModelInputNames::DENSITY ) ) { - if( strs[1] == P1DENS::catalogName() ) + if( strs[1] == PHASE1::Density::catalogName() ) { - m_p1Density = std::make_unique< P1DENS >( getName() + '_' + P1DENS::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + phase1InputParams[PHASE1::InputParamOrder::DENSITY] = strs; } - else if( strs[1] == P2DENS::catalogName() ) + else if( strs[1] == PHASE2::Density::catalogName() ) { - m_p2Density = std::make_unique< P2DENS >( getName() + '_' + P2DENS::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + phase2InputParams[PHASE2::InputParamOrder::DENSITY] = strs; } } - else if( strs[0] == "ViscosityFun" ) + else if( strs[0] == toString( SubModelInputNames::VISCOSITY ) ) { - if( strs[1] == P1VISC::catalogName() ) + if( strs[1] == PHASE1::Viscosity::catalogName() ) { - m_p1Viscosity = std::make_unique< P1VISC >( getName() + '_' + P1VISC::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + phase1InputParams[PHASE1::InputParamOrder::VISCOSITY] = strs; } - else if( strs[1] == P2VISC::catalogName() ) + else if( strs[1] == PHASE2::Viscosity::catalogName() ) { - m_p2Viscosity = std::make_unique< P2VISC >( getName() + '_' + P2VISC::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + phase2InputParams[PHASE2::InputParamOrder::VISCOSITY] = strs; } } - else if( strs[0] == "EnthalpyFun" ) + else if( strs[0] == toString( SubModelInputNames::ENTHALPY ) ) { - if( strs[1] == P1ENTH::catalogName() ) + if( strs[1] == PHASE1::Enthalpy::catalogName() ) { - m_p1Enthalpy = std::make_unique< P1ENTH >( getName() + '_' + P1ENTH::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + phase1InputParams[PHASE1::InputParamOrder::ENTHALPY] = strs; } - else if( strs[1] == P2ENTH::catalogName() ) + else if( strs[1] == PHASE2::Enthalpy::catalogName() ) { - m_p2Enthalpy = std::make_unique< P2ENTH >( getName() + '_' + P2ENTH::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + phase2InputParams[PHASE2::InputParamOrder::ENTHALPY] = strs; } } - else if( strs[0] == "InternalEnergyFun" ) + else if( strs[0] == toString( SubModelInputNames::INTERNALENERGY ) ) { - if( strs[1] == P1INTENERGY::catalogName() ) + if( strs[1] == PHASE1::InternalEnergy::catalogName() ) { - m_p1IntEnergy = std::make_unique< P1INTENERGY >( getName() + '_' + P1INTENERGY::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + phase1InputParams[PHASE1::InputParamOrder::INTERNALENERGY] = strs; } - else if( strs[1] == P2INTENERGY::catalogName() ) + else if( strs[1] == PHASE2::InternalEnergy::catalogName() ) { - m_p2IntEnergy = std::make_unique< P2INTENERGY >( getName() + '_' + P2INTENERGY::catalogName(), strs, m_componentNames, m_componentMolarWeight ); + phase2InputParams[PHASE2::InputParamOrder::INTERNALENERGY] = strs; } } else @@ -257,50 +239,41 @@ void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, is.close(); } - // at this point, we have read the file, and we can detect any inconsistency arising in the enthalpy/internal energy models - GEOSX_THROW_IF( m_p1Enthalpy == nullptr && ( P1ENTH::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1ENTH::catalogName() ), + // at this point, we have read the file and we check the consistency of non-thermal models + GEOSX_THROW_IF( phase1InputParams[PHASE1::InputParamOrder::DENSITY].empty(), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE1::Density::catalogName() ), InputError ); - GEOSX_THROW_IF( m_p1IntEnergy == nullptr && ( P1INTENERGY::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1INTENERGY::catalogName() ), + GEOSX_THROW_IF( phase2InputParams[PHASE2::InputParamOrder::DENSITY].empty(), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE2::Density::catalogName() ), InputError ); - GEOSX_THROW_IF( m_p2Enthalpy == nullptr && ( P2ENTH::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2ENTH::catalogName() ), + GEOSX_THROW_IF( phase1InputParams[PHASE1::InputParamOrder::VISCOSITY].empty(), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE1::Viscosity::catalogName() ), InputError ); - GEOSX_THROW_IF( m_p2IntEnergy == nullptr && ( P2INTENERGY::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2INTENERGY::catalogName() ), + GEOSX_THROW_IF( phase2InputParams[PHASE2::InputParamOrder::VISCOSITY].empty(), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE2::Viscosity::catalogName() ), InputError ); - // we also check the consistency of non-thermal models - GEOSX_THROW_IF( m_p1Density == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1DENS::catalogName() ), + + // we also detect any inconsistency arising in the enthalpy/internal energy models + GEOSX_THROW_IF( phase1InputParams[PHASE1::InputParamOrder::INTERNALENERGY].empty() && + ( PHASE1::InternalEnergy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE1::InternalEnergy::catalogName() ), InputError ); - GEOSX_THROW_IF( m_p2Density == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2DENS::catalogName() ), + GEOSX_THROW_IF( phase2InputParams[PHASE2::InputParamOrder::INTERNALENERGY].empty() && + ( PHASE2::InternalEnergy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE2::InternalEnergy::catalogName() ), InputError ); - GEOSX_THROW_IF( m_p1Viscosity == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1VISC::catalogName() ), + GEOSX_THROW_IF( phase1InputParams[PHASE1::InputParamOrder::ENTHALPY].empty() && + ( PHASE1::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE1::Enthalpy::catalogName() ), InputError ); - GEOSX_THROW_IF( m_p2Viscosity == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2VISC::catalogName() ), + GEOSX_THROW_IF( phase2InputParams[PHASE2::InputParamOrder::ENTHALPY].empty() && + ( PHASE2::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE2::Enthalpy::catalogName() ), InputError ); - // for non-thermal models, the user skips the definition of the enthalpy/internal energy models, so we create NoOp models now - if( m_p1Enthalpy == nullptr ) - { - m_p1Enthalpy = std::make_unique< P1ENTH >( getName() + '_' + P1ENTH::catalogName(), string_array(), m_componentNames, m_componentMolarWeight ); - } - if( m_p2Enthalpy == nullptr ) - { - m_p2Enthalpy = std::make_unique< P2ENTH >( getName() + '_' + P2ENTH::catalogName(), string_array(), m_componentNames, m_componentMolarWeight ); - } - if( m_p1IntEnergy == nullptr ) - { - m_p1IntEnergy = std::make_unique< P1INTENERGY >( getName() + '_' + P1INTENERGY::catalogName(), string_array(), m_componentNames, m_componentMolarWeight ); - } - if( m_p2IntEnergy == nullptr ) - { - m_p2IntEnergy = std::make_unique< P2INTENERGY >( getName() + '_' + P2INTENERGY::catalogName(), string_array(), m_componentNames, m_componentMolarWeight ); - } + // then, we are ready to instantiate the phase models + m_phase1 = std::make_unique< PHASE1 >( getName() + "_phaseModel1", phase1InputParams, m_componentNames, m_componentMolarWeight ); + m_phase2 = std::make_unique< PHASE2 >( getName() + "_phaseModel2", phase2InputParams, m_componentNames, m_componentMolarWeight ); // 2) Create the flash model { @@ -313,7 +286,11 @@ void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, { if( strs[1] == FLASH::catalogName() ) { - m_flash = std::make_unique< FLASH >( getName() + '_' + FLASH::catalogName(), strs, m_phaseNames, m_componentNames, m_componentMolarWeight ); + m_flash = std::make_unique< FLASH >( getName() + '_' + FLASH::catalogName(), + strs, + m_phaseNames, + m_componentNames, + m_componentMolarWeight ); } } else @@ -329,26 +306,14 @@ void CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, InputError ); } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > -typename CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::KernelWrapper -CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::createKernelWrapper() +template< typename PHASE1, typename PHASE2, typename FLASH > +typename CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper +CO2BrineFluid< PHASE1, PHASE2, FLASH >::createKernelWrapper() { return KernelWrapper( m_p1Index, m_p2Index, - *m_p1Density, - *m_p1Viscosity, - *m_p1Enthalpy, - *m_p1IntEnergy, - *m_p2Density, - *m_p2Viscosity, - *m_p2Enthalpy, - *m_p2IntEnergy, + *m_phase1, + *m_phase2, *m_flash, m_componentMolarWeight.toViewConst(), m_useMass, @@ -362,22 +327,12 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, m_totalDensity.toView() ); } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > -CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::KernelWrapper:: +template< typename PHASE1, typename PHASE2, typename FLASH > +CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper:: KernelWrapper( integer const p1Index, integer const p2Index, - P1DENS const & p1Density, - P1VISC const & p1Viscosity, - P1ENTH const & p1Enthalpy, - P1INTENERGY const & p1IntEnergy, - P2DENS const & p2Density, - P2VISC const & p2Viscosity, - P2ENTH const & p2Enthalpy, - P2INTENERGY const & p2IntEnergy, + PHASE1 const & phase1, + PHASE2 const & phase2, FLASH const & flash, arrayView1d< geosx::real64 const > componentMolarWeight, bool const useMass, @@ -401,30 +356,24 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, std::move( totalDensity ) ), m_p1Index( p1Index ), m_p2Index( p2Index ), - m_p1Density( p1Density.createKernelWrapper() ), - m_p1Viscosity( p1Viscosity.createKernelWrapper() ), - m_p1Enthalpy( p1Enthalpy.createKernelWrapper() ), - m_p1IntEnergy( p1IntEnergy.createKernelWrapper() ), - m_p2Density( p2Density.createKernelWrapper() ), - m_p2Viscosity( p2Viscosity.createKernelWrapper() ), - m_p2Enthalpy( p2Enthalpy.createKernelWrapper() ), - m_p2IntEnergy( p2IntEnergy.createKernelWrapper() ), + m_phase1( phase1.createKernelWrapper() ), + m_phase2( phase2.createKernelWrapper() ), m_flash( flash.createKernelWrapper() ) {} // explicit instantiation of the model template; unfortunately we can't use the aliases for this -template class CO2BrineFluid< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, +template class CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, PVTProps::CO2Solubility >; -template class CO2BrineFluid< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, +template class CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, PVTProps::CO2Solubility >; -template class CO2BrineFluid< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, +template class CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, PVTProps::CO2Solubility >; -template class CO2BrineFluid< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, +template class CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, PVTProps::CO2Solubility >; REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrinePhillipsFluid, string const &, Group * const ) diff --git a/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp b/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp index 789cb21666b..0e45c0d883b 100644 --- a/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp +++ b/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp @@ -19,8 +19,10 @@ #ifndef GEOSX_CONSTITUTIVE_FLUID_CO2BRINEFLUID_HPP_ #define GEOSX_CONSTITUTIVE_FLUID_CO2BRINEFLUID_HPP_ +#include "codingUtilities/EnumStrings.hpp" #include "constitutive/fluid/MultiFluidBase.hpp" #include "constitutive/fluid/MultiFluidUtils.hpp" +#include "constitutive/fluid/PhaseModel.hpp" #include "constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp" #include "constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp" #include "constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp" @@ -43,9 +45,7 @@ namespace geosx namespace constitutive { -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > +template< typename PHASE1, typename PHASE2, typename FLASH > class CO2BrineFluid : public MultiFluidBase { public: @@ -63,6 +63,8 @@ class CO2BrineFluid : public MultiFluidBase virtual string getCatalogName() const override { return catalogName(); } + virtual bool isThermal() const override; + /** * @brief Kernel wrapper class for CO2BrineFluid. */ @@ -109,14 +111,8 @@ class CO2BrineFluid : public MultiFluidBase KernelWrapper( integer p1Index, integer p2Index, - P1DENS const & p1Density, - P1VISC const & p1Viscosity, - P1ENTH const & p1Enthalpy, - P1INTENERGY const & p1IntEnergy, - P2DENS const & p2Density, - P2VISC const & p2Viscosity, - P2ENTH const & p2Enthalpy, - P2INTENERGY const & p2IntEnergy, + PHASE1 const & phase1, + PHASE2 const & phase2, FLASH const & flash, arrayView1d< real64 const > componentMolarWeight, bool const useMass, @@ -136,44 +132,29 @@ class CO2BrineFluid : public MultiFluidBase integer m_p2Index; - // Brine constitutive kernel wrappers - - /// Kernel wrapper for brine density updates - typename P1DENS::KernelWrapper m_p1Density; - - /// Kernel wrapper for brine viscosity updates - typename P1VISC::KernelWrapper m_p1Viscosity; - - /// Kernel wrapper for brine enthalpy updates - typename P1ENTH::KernelWrapper m_p1Enthalpy; - - /// Kernel wrapper for brine internal energy updates - typename P1INTENERGY::KernelWrapper m_p1IntEnergy; - + /// Brine constitutive kernel wrappers + typename PHASE1::KernelWrapper m_phase1; // CO2 constitutive kernel wrapper - - /// Kernel wrapper for CO2 density updates - typename P2DENS::KernelWrapper m_p2Density; - - /// Kernel wrapper for CO2 viscosity updates - typename P2VISC::KernelWrapper m_p2Viscosity; - - /// Kernel wrapper for CO2 enthalpy updates - typename P2ENTH::KernelWrapper m_p2Enthalpy; - - /// Kernel wrapper for CO2 internal energy updates - typename P2INTENERGY::KernelWrapper m_p2IntEnergy; - + typename PHASE2::KernelWrapper m_phase2; // Flash kernel wrapper - - /// Kernel wrapper for phase fraction and phase component fraction updates typename FLASH::KernelWrapper m_flash; }; virtual integer getWaterPhaseIndex() const override final; + /** + * @brief Names of the submodels for input + */ + enum class SubModelInputNames : integer + { + DENSITY, ///< the keyword for the density model + VISCOSITY, ///< the keyword for the viscosity model + ENTHALPY, ///< the keyword for the enthalpy model + INTERNALENERGY, ///< the keyword for the internal energy model + }; + /** * @brief Create an update kernel wrapper. * @return the wrapper @@ -207,70 +188,40 @@ class CO2BrineFluid : public MultiFluidBase integer m_p2Index; - // Brine constitutive models - - /// Pointer to the brine density model - std::unique_ptr< P1DENS > m_p1Density; - - /// Pointer to the brine viscosity model - std::unique_ptr< P1VISC > m_p1Viscosity; - - /// Pointer to the brine enthalpy model - std::unique_ptr< P1ENTH > m_p1Enthalpy; - - /// Pointer to the brine internal energy model - std::unique_ptr< P1INTENERGY > m_p1IntEnergy; - + /// Brine constitutive models + std::unique_ptr< PHASE1 > m_phase1; // CO2 constitutive models - - /// Pointer to the CO2 density model - std::unique_ptr< P2DENS > m_p2Density; - - /// Pointer to the CO2 viscosity model - std::unique_ptr< P2VISC > m_p2Viscosity; - - /// Pointer to the CO2 enthalpy model - std::unique_ptr< P2ENTH > m_p2Enthalpy; - - /// Pointer to the CO2 internal energy model - std::unique_ptr< P2INTENERGY > m_p2IntEnergy; - + std::unique_ptr< PHASE2 > m_phase2; // Flash model - - /// Pointer to the flash model std::unique_ptr< FLASH > m_flash; }; // these aliases are useful in constitutive dispatch using CO2BrinePhillipsFluid = - CO2BrineFluid< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, PVTProps::CO2Solubility >; using CO2BrinePhillipsThermalFluid = - CO2BrineFluid< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, PVTProps::CO2Solubility >; using CO2BrineEzrokhiFluid = - CO2BrineFluid< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction, + CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, PVTProps::CO2Solubility >; using CO2BrineEzrokhiThermalFluid = - CO2BrineFluid< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy, - PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy, + CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, PVTProps::CO2Solubility >; -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > +template< typename PHASE1, typename PHASE2, typename FLASH > GEOSX_HOST_DEVICE inline void -CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::KernelWrapper:: +CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper:: compute( real64 pressure, real64 temperature, arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition, @@ -326,51 +277,51 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, // 3. Compute phase densities and phase viscosities - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseDensity[ip1], - m_useMass ); - m_p1Viscosity.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseViscosity[ip1], - m_useMass ); - - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseDensity[ip2], - m_useMass ); - m_p2Viscosity.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseViscosity[ip2], - m_useMass ); + m_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseDensity[ip1], + m_useMass ); + m_phase1.viscosity.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseViscosity[ip1], + m_useMass ); + + m_phase2.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseDensity[ip2], + m_useMass ); + m_phase2.viscosity.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseViscosity[ip2], + m_useMass ); // 4. Compute enthalpy and internal energy - m_p1Enthalpy.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseEnthalpy[ip1], - m_useMass ); - m_p1IntEnergy.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseInternalEnergy[ip1], - m_useMass ); - - m_p2Enthalpy.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseEnthalpy[ip2], - m_useMass ); - m_p2IntEnergy.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseInternalEnergy[ip2], - m_useMass ); + m_phase1.enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseEnthalpy[ip1], + m_useMass ); + m_phase1.internalEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseInternalEnergy[ip1], + m_useMass ); + + m_phase2.enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseEnthalpy[ip2], + m_useMass ); + m_phase2.internalEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseInternalEnergy[ip2], + m_useMass ); // 5. Depending on the m_useMass flag, convert to mass variables or simply compute mass density @@ -386,18 +337,18 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, // 5.1.0. Compute the phase molecular weights (ultimately, get that from the PVT function) real64 phaseMW[2]{}; real64 phaseMolarDens = 0.0; - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseMolarDens, - false ); + m_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseMolarDens, + false ); phaseMW[ip1] = phaseDensity[ip1] / phaseMolarDens; - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseMolarDens, - false ); + m_phase2.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseMolarDens, + false ); phaseMW[ip2] = phaseDensity[ip2] / phaseMolarDens; // 5.1.1. Compute mass of each phase and total mass (on a 1-mole basis) @@ -432,16 +383,16 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, else { // for now, we have to compute the phase mass density here - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseMassDensity[ip1], - true ); - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseMassDensity[ip2], - true ); + m_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseMassDensity[ip1], + true ); + m_phase2.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseMassDensity[ip2], + true ); } // TODO: extract the following piece of code and write a function that can be used here and in MultiFluidPVTPackageWrapper @@ -461,14 +412,10 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, } } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > +template< typename PHASE1, typename PHASE2, typename FLASH > GEOSX_HOST_DEVICE inline void -CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::KernelWrapper:: +CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper:: compute( real64 const pressure, real64 const temperature, arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition, @@ -533,67 +480,67 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, // 3. Compute phase densities and phase viscosities - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseDensity.value[ip1], phaseDensity.dPres[ip1], - phaseDensity.dTemp[ip1], phaseDensity.dComp[ip1], - m_useMass ); - m_p1Viscosity.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseViscosity.value[ip1], phaseViscosity.dPres[ip1], - phaseViscosity.dTemp[ip1], phaseViscosity.dComp[ip1], - m_useMass ); - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseDensity.value[ip2], phaseDensity.dPres[ip2], - phaseDensity.dTemp[ip2], phaseDensity.dComp[ip2], - m_useMass ); - m_p2Viscosity.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseViscosity.value[ip2], phaseViscosity.dPres[ip2], - phaseViscosity.dTemp[ip2], phaseViscosity.dComp[ip2], - m_useMass ); + m_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), + phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), + phaseDensity.value[ip1], phaseDensity.dPres[ip1], + phaseDensity.dTemp[ip1], phaseDensity.dComp[ip1], + m_useMass ); + m_phase1.viscosity.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), + phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), + phaseViscosity.value[ip1], phaseViscosity.dPres[ip1], + phaseViscosity.dTemp[ip1], phaseViscosity.dComp[ip1], + m_useMass ); + m_phase2.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), + phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), + phaseDensity.value[ip2], phaseDensity.dPres[ip2], + phaseDensity.dTemp[ip2], phaseDensity.dComp[ip2], + m_useMass ); + m_phase2.viscosity.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), + phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), + phaseViscosity.value[ip2], phaseViscosity.dPres[ip2], + phaseViscosity.dTemp[ip2], phaseViscosity.dComp[ip2], + m_useMass ); // 4. Compute enthalpy and internal energy - m_p1Enthalpy.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseEnthalpy.value[ip1], phaseEnthalpy.dPres[ip1], - phaseEnthalpy.dTemp[ip1], phaseEnthalpy.dComp[ip1], - m_useMass ); - m_p1IntEnergy.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseInternalEnergy.value[ip1], phaseInternalEnergy.dPres[ip1], - phaseInternalEnergy.dTemp[ip1], phaseInternalEnergy.dComp[ip1], - m_useMass ); - - m_p2Enthalpy.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseEnthalpy.value[ip2], phaseEnthalpy.dPres[ip2], - phaseEnthalpy.dTemp[ip2], phaseEnthalpy.dComp[ip2], - m_useMass ); - m_p2IntEnergy.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseInternalEnergy.value[ip2], phaseInternalEnergy.dPres[ip2], - phaseInternalEnergy.dTemp[ip2], phaseInternalEnergy.dComp[ip2], - m_useMass ); + m_phase1.enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), + phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), + phaseEnthalpy.value[ip1], phaseEnthalpy.dPres[ip1], + phaseEnthalpy.dTemp[ip1], phaseEnthalpy.dComp[ip1], + m_useMass ); + m_phase1.internalEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), + phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), + phaseInternalEnergy.value[ip1], phaseInternalEnergy.dPres[ip1], + phaseInternalEnergy.dTemp[ip1], phaseInternalEnergy.dComp[ip1], + m_useMass ); + + m_phase2.enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), + phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), + phaseEnthalpy.value[ip2], phaseEnthalpy.dPres[ip2], + phaseEnthalpy.dTemp[ip2], phaseEnthalpy.dComp[ip2], + m_useMass ); + m_phase2.internalEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), + phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), + phaseInternalEnergy.value[ip2], phaseInternalEnergy.dPres[ip2], + phaseInternalEnergy.dTemp[ip2], phaseInternalEnergy.dComp[ip2], + m_useMass ); // 5. Depending on the m_useMass flag, convert to mass variables or simply compute mass density @@ -618,13 +565,13 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, real64 dPhaseMolarDens_dPres = 0.0; real64 dPhaseMolarDens_dTemp = 0.0; stackArray1d< real64, numComps > dPhaseMolarDens_dComp( 2 ); - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseMolarDens, dPhaseMolarDens_dPres, - dPhaseMolarDens_dTemp, dPhaseMolarDens_dComp.toSlice(), - false ); + m_phase2.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), + phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), + phaseMolarDens, dPhaseMolarDens_dPres, + dPhaseMolarDens_dTemp, dPhaseMolarDens_dComp.toSlice(), + false ); phaseMW[ip2] = phaseDensity.value[ip2] / phaseMolarDens; dPhaseMW_dPres[ip2] = phaseDensity.dPres[ip2] / phaseMolarDens - phaseMW[ip2] * dPhaseMolarDens_dPres / phaseMolarDens; dPhaseMW_dTemp[ip2] = phaseDensity.dTemp[ip2] / phaseMolarDens - phaseMW[ip2] * dPhaseMolarDens_dTemp / phaseMolarDens; @@ -632,13 +579,13 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, { dPhaseMW_dComp[ip2][ic] = phaseDensity.dComp[ip2][ic] / phaseMolarDens - phaseMW[ip2] * dPhaseMolarDens_dComp[ic] / phaseMolarDens; } - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseMolarDens, dPhaseMolarDens_dPres, - dPhaseMolarDens_dTemp, dPhaseMolarDens_dComp.toSlice(), - false ); + m_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), + phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), + phaseMolarDens, dPhaseMolarDens_dPres, + dPhaseMolarDens_dTemp, dPhaseMolarDens_dComp.toSlice(), + false ); phaseMW[ip1] = phaseDensity.value[ip1] / phaseMolarDens; dPhaseMW_dPres[ip1] = phaseDensity.dPres[ip1] / phaseMolarDens - phaseMW[ip1] * dPhaseMolarDens_dPres / phaseMolarDens; dPhaseMW_dTemp[ip1] = phaseDensity.dTemp[ip1] / phaseMolarDens - phaseMW[ip1] * dPhaseMolarDens_dTemp / phaseMolarDens; @@ -734,20 +681,20 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, else { // for now, we have to compute the phase mass density here - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseMassDensity.value[ip1], phaseMassDensity.dPres[ip1], - phaseMassDensity.dTemp[ip1], phaseMassDensity.dComp[ip1], - true ); - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseMassDensity.value[ip2], phaseMassDensity.dPres[ip2], - phaseMassDensity.dTemp[ip2], phaseMassDensity.dComp[ip2], - true ); + m_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), + phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), + phaseMassDensity.value[ip1], phaseMassDensity.dPres[ip1], + phaseMassDensity.dTemp[ip1], phaseMassDensity.dComp[ip1], + true ); + m_phase2.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), + phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), + phaseMassDensity.value[ip2], phaseMassDensity.dPres[ip2], + phaseMassDensity.dTemp[ip2], phaseMassDensity.dComp[ip2], + true ); } // TODO: extract the following piece of code and write a function that can be used here and in MultiFluidPVTPackageWrapper @@ -791,13 +738,9 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, } } -template< typename P1DENS, typename P1VISC, typename P1ENTH, typename P1INTENERGY, - typename P2DENS, typename P2VISC, typename P2ENTH, typename P2INTENERGY, - typename FLASH > +template< typename PHASE1, typename PHASE2, typename FLASH > GEOSX_HOST_DEVICE inline void -CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, - P2DENS, P2VISC, P2ENTH, P2INTENERGY, - FLASH >::KernelWrapper:: +CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper:: update( localIndex const k, localIndex const q, real64 const pressure, @@ -817,8 +760,32 @@ CO2BrineFluid< P1DENS, P1VISC, P1ENTH, P1INTENERGY, m_totalDensity( k, q ) ); } +/// Declare strings associated with enumeration values +/// Needed for now, because we don't use the catalogNames for input (yet) +ENUM_STRINGS( CO2BrinePhillipsFluid::SubModelInputNames, + "DensityFun", + "ViscosityFun", + "EnthalpyFun", + "InternalEnergyFun" ); +ENUM_STRINGS( CO2BrinePhillipsThermalFluid::SubModelInputNames, + "DensityFun", + "ViscosityFun", + "EnthalpyFun", + "InternalEnergyFun" ); +ENUM_STRINGS( CO2BrineEzrokhiFluid::SubModelInputNames, + "DensityFun", + "ViscosityFun", + "EnthalpyFun", + "InternalEnergyFun" ); +ENUM_STRINGS( CO2BrineEzrokhiThermalFluid::SubModelInputNames, + "DensityFun", + "ViscosityFun", + "EnthalpyFun", + "InternalEnergyFun" ); + + } // namespace constitutive } // namespace geosx -#endif //GEOSX_CONSTITUTIVE_FLUID_MULTIPHASEMULTICOMPONENTFLUID_HPP_ +#endif //GEOSX_CONSTITUTIVE_FLUID_CO2BRINEFLUID_HPP_ diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp index 22778a6f525..167c4e4664f 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp @@ -30,7 +30,6 @@ namespace constitutive MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) : ConstitutiveBase( name, parent ), - m_thermalFlag( false ), m_useMass( false ) { // We make base inputs optional here, since derived classes may want to predefine/hardcode @@ -48,9 +47,6 @@ MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) setInputFlag( InputFlags::OPTIONAL ). setDescription( "List of fluid phases" ); - registerWrapper( viewKeyStruct::thermalFlagString(), &m_thermalFlag ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::useMassString(), &m_useMass ). setRestartFlags( RestartFlags::NO_WRITE ); diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index b904a1cc80f..53cdfe0cee5 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -92,10 +92,10 @@ class MultiFluidBase : public ConstitutiveBase /** * @brief Get the thermal flag. * @return boolean value indicating whether the model can be used to assemble the energy balance equation or not - * @detail if thermalFlag is true, the constitutive model compute the enthalpy and internal energy of the phase. + * @detail if isThermal is true, the constitutive model compute the enthalpy and internal energy of the phase. * This can be used to check the compatibility of the constitutive model with the solver */ - bool getThermalFlag() const { return m_thermalFlag; } + virtual bool isThermal() const { return false; } /** * @brief Get the mass flag. diff --git a/src/coreComponents/constitutive/fluid/PhaseModel.hpp b/src/coreComponents/constitutive/fluid/PhaseModel.hpp new file mode 100644 index 00000000000..bcbe9c42e16 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PhaseModel.hpp @@ -0,0 +1,160 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file PhaseModel.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PHASEMODEL_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PHASEMODEL_HPP_ + +namespace geosx +{ + +namespace constitutive +{ + +/** + * @brief Struct storing the submodels describing the fluid phase behavior. + * For now, this is used only in the CO2BrineFluid class + * @tparam DENS Class describing the density model + * @tparam VISC Class describing the viscosity model + * @tparam ENTH Class describing the enthalpy model + * @tparam INTENERGY Class describing the internal energy model + */ +template< typename DENS, typename VISC, typename ENTH, typename INTENERGY > +struct PhaseModel +{ + using Density = DENS; + using Viscosity = VISC; + using Enthalpy = ENTH; + using InternalEnergy = INTENERGY; + + /// Enum used in the constructor to make the distinction between submodel params + enum InputParamOrder : integer + { + DENSITY = 0, ///< position of the density params + VISCOSITY = 1, ///< position of the viscosity params + ENTHALPY = 2, ///< position of the enthalpy params + INTERNALENERGY = 3 ///< position of the internal energy params + }; + + /** + * @brief Constructor of the struct, in charge of the instantiation of the submodels + * @param[in] phaseModelName name of the phase model, used only in the instantiation of the submodels + * @param[in] inputParams input parameters read from files + * @param[in] componentNames names of the components + * @param[in] componentMolarWeight molar weights of the components + */ + PhaseModel( string const & phaseModelName, + array1d< array1d< string > > const & inputParams, + string_array const & componentNames, + array1d< real64 > const & componentMolarWeight ) + : density( phaseModelName + "_" + Density::catalogName(), + inputParams[InputParamOrder::DENSITY], + componentNames, + componentMolarWeight ), + viscosity( phaseModelName + "_" + Viscosity::catalogName(), + inputParams[InputParamOrder::VISCOSITY], + componentNames, + componentMolarWeight ), + enthalpy( phaseModelName + "_" + Enthalpy::catalogName(), + inputParams[InputParamOrder::ENTHALPY], + componentNames, + componentMolarWeight ), + internalEnergy( phaseModelName + "_" + InternalEnergy::catalogName(), + inputParams[InputParamOrder::INTERNALENERGY], + componentNames, + componentMolarWeight ) + {} + + /// The phase density model + Density density; + + /// The phase viscosity model + Viscosity viscosity; + + /// The phase enthalpy model (can be NoOp for non-thermal models) + Enthalpy enthalpy; + + /// The phase internal energy model (can be NoOp for non-thermal models) + InternalEnergy internalEnergy; + + /** + * @brief Struct storing the submodels wrappers used for in-kernel fluid updates + */ + struct KernelWrapper + { + + /** + * @brief Constructor for the kernel wrapper + * @param[in] dens the density model + * @param[in] visc the viscosity model + * @param[in] enth the enthalpy model + * @param[in] intEnergy the internal energy model + */ + KernelWrapper( Density const & dens, + Viscosity const & visc, + Enthalpy const & enth, + InternalEnergy const & intEnergy ) + : density( dens.createKernelWrapper() ), + viscosity( visc.createKernelWrapper() ), + enthalpy( enth.createKernelWrapper() ), + internalEnergy( intEnergy.createKernelWrapper() ) + {} + + /** + * @brief Moves the submodel data to the GPU if the phaseModel is stored in ArrayView + * @param[in] space the target memory space + * @param[in] touch the flag to register touch or not + */ + void move( LvArray::MemorySpace const space, bool const touch ) + { + density.move( space, touch ); + viscosity.move( space, touch ); + enthalpy.move( space, touch ); + internalEnergy.move( space, touch ); + } + + /// Kernel wrapper for density updates + typename Density::KernelWrapper density; + + /// Kernel wrapper for viscosity updates + typename Viscosity::KernelWrapper viscosity; + + /// Kernel wrapper for enthalpy updates + typename Enthalpy::KernelWrapper enthalpy; + + /// Kernel wrapper for internal energy updates + typename InternalEnergy::KernelWrapper internalEnergy; + }; + + /** + * @brief Function to create and return a KernelWrapper + * @return the KernelWrapper object + */ + KernelWrapper createKernelWrapper() const + { + return KernelWrapper( density, + viscosity, + enthalpy, + internalEnergy ); + } +}; + +} // namespace constitutive + +} // namespace geosx + +#endif //GEOSX_CONSTITUTIVE_FLUID_PHASEMODEL_HPP_ diff --git a/src/coreComponents/schema/docs/BlackOilFluid_other.rst b/src/coreComponents/schema/docs/BlackOilFluid_other.rst index bbaf9ca9af6..ae2bf54c08d 100644 --- a/src/coreComponents/schema/docs/BlackOilFluid_other.rst +++ b/src/coreComponents/schema/docs/BlackOilFluid_other.rst @@ -40,7 +40,6 @@ phaseMassDensity real64_array3d phaseOrder integer_array (no description available) phaseTypes integer_array (no description available) phaseViscosity real64_array3d Phase viscosity -thermalFlag integer (no description available) totalDensity real64_array2d Total density useMass integer (no description available) viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) diff --git a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst index 8f4598a516a..44509515edf 100644 --- a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst @@ -35,7 +35,6 @@ phaseFraction real64_array3d phaseInternalEnergy real64_array3d Phase internal energy phaseMassDensity real64_array3d Phase mass density phaseViscosity real64_array3d Phase viscosity -thermalFlag integer (no description available) totalDensity real64_array2d Total density useMass integer (no description available) ======================================== ============================================================================================== ================================================================================ diff --git a/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst b/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst index 8f4598a516a..44509515edf 100644 --- a/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst @@ -35,7 +35,6 @@ phaseFraction real64_array3d phaseInternalEnergy real64_array3d Phase internal energy phaseMassDensity real64_array3d Phase mass density phaseViscosity real64_array3d Phase viscosity -thermalFlag integer (no description available) totalDensity real64_array2d Total density useMass integer (no description available) ======================================== ============================================================================================== ================================================================================ diff --git a/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst b/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst index 8f4598a516a..44509515edf 100644 --- a/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst @@ -35,7 +35,6 @@ phaseFraction real64_array3d phaseInternalEnergy real64_array3d Phase internal energy phaseMassDensity real64_array3d Phase mass density phaseViscosity real64_array3d Phase viscosity -thermalFlag integer (no description available) totalDensity real64_array2d Total density useMass integer (no description available) ======================================== ============================================================================================== ================================================================================ diff --git a/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst b/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst index 8f4598a516a..44509515edf 100644 --- a/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst @@ -35,7 +35,6 @@ phaseFraction real64_array3d phaseInternalEnergy real64_array3d Phase internal energy phaseMassDensity real64_array3d Phase mass density phaseViscosity real64_array3d Phase viscosity -thermalFlag integer (no description available) totalDensity real64_array2d Total density useMass integer (no description available) ======================================== ============================================================================================== ================================================================================ diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst index 8f4598a516a..44509515edf 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst @@ -35,7 +35,6 @@ phaseFraction real64_array3d phaseInternalEnergy real64_array3d Phase internal energy phaseMassDensity real64_array3d Phase mass density phaseViscosity real64_array3d Phase viscosity -thermalFlag integer (no description available) totalDensity real64_array2d Total density useMass integer (no description available) ======================================== ============================================================================================== ================================================================================ diff --git a/src/coreComponents/schema/docs/DeadOilFluid_other.rst b/src/coreComponents/schema/docs/DeadOilFluid_other.rst index e2ecefa06dd..58b6e630a01 100644 --- a/src/coreComponents/schema/docs/DeadOilFluid_other.rst +++ b/src/coreComponents/schema/docs/DeadOilFluid_other.rst @@ -39,7 +39,6 @@ phaseMassDensity real64_array3d phaseOrder integer_array (no description available) phaseTypes integer_array (no description available) phaseViscosity real64_array3d Phase viscosity -thermalFlag integer (no description available) totalDensity real64_array2d Total density useMass integer (no description available) viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 1f7c64120a8..e2efab89486 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -920,8 +920,6 @@ - - @@ -1030,8 +1028,6 @@ - - @@ -1102,8 +1098,6 @@ - - @@ -1174,8 +1168,6 @@ - - @@ -1246,8 +1238,6 @@ - - @@ -1326,8 +1316,6 @@ - - @@ -1486,8 +1474,6 @@ - - From ccb0a2e1aa2a95fc4eef5b22fbe7f287eb00cc6c Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Tue, 1 Feb 2022 21:40:46 -0800 Subject: [PATCH 4/7] removed forgotten thermal flag --- src/coreComponents/constitutive/fluid/MultiFluidBase.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index 53cdfe0cee5..3cefe375c14 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -217,7 +217,6 @@ class MultiFluidBase : public ConstitutiveBase static constexpr char const * componentMolarWeightString() { return "componentMolarWeight"; } static constexpr char const * phaseNamesString() { return "phaseNames"; } static constexpr char const * useMassString() { return "useMass"; } - static constexpr char const * thermalFlagString() { return "thermalFlag"; } }; protected: @@ -357,9 +356,6 @@ class MultiFluidBase : public ConstitutiveBase virtual void postProcessInput() override; - // flag indicating whether the constitutive model can be used to assemble the energy balance or not - int m_thermalFlag; - // flag indicating whether input/output component fractions are treated as mass fractions int m_useMass; From 0f587e6d5b4433f69350c4f05710aa677e8237c4 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 23 Feb 2022 11:50:27 -0800 Subject: [PATCH 5/7] removed deleted files --- .../fluid/MultiPhaseMultiComponentFluid.cpp | 288 ---------- .../fluid/MultiPhaseMultiComponentFluid.hpp | 502 ------------------ 2 files changed, 790 deletions(-) delete mode 100644 src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp delete mode 100644 src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp deleted file mode 100644 index 377050f2112..00000000000 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 TotalEnergies - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file MultiPhaseMultiComponentFluid.cpp - */ -#include "MultiPhaseMultiComponentFluid.hpp" - -#include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" - -namespace geosx -{ - -using namespace dataRepository; - -namespace constitutive -{ - -using namespace PVTProps; - -namespace -{ -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > class - TwoPhaseCatalogNames {}; - -template<> class - TwoPhaseCatalogNames< PVTProps::PhillipsBrineDensity, - PVTProps::PhillipsBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility > -{ -public: - static string name() { return "CO2BrinePhillipsFluid"; } -}; -template<> class - TwoPhaseCatalogNames< PVTProps::EzrokhiBrineDensity, - PVTProps::EzrokhiBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility > -{ -public: - static string name() { return "CO2BrineEzrokhiFluid"; } -}; -} // end namespace - -// provide a definition for catalogName() -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -string MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::catalogName() -{ - return TwoPhaseCatalogNames< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::name(); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >:: -MultiPhaseMultiComponentFluid( string const & name, Group * const parent ): - MultiFluidBase( name, parent ) -{ - registerWrapper( viewKeyStruct::phasePVTParaFilesString(), &m_phasePVTParaFiles ). - setInputFlag( InputFlags::REQUIRED ). - setRestartFlags( RestartFlags::NO_WRITE ). - setDescription( "Names of the files defining the parameters of the viscosity and density models" ); - - registerWrapper( viewKeyStruct::flashModelParaFileString(), &m_flashModelParaFile ). - setInputFlag( InputFlags::REQUIRED ). - setRestartFlags( RestartFlags::NO_WRITE ). - setDescription( "Name of the file defining the parameters of the flash model" ); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -std::unique_ptr< ConstitutiveBase > -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >:: -deliverClone( string const & name, Group * const parent ) const -{ - std::unique_ptr< ConstitutiveBase > clone = MultiFluidBase::deliverClone( name, parent ); - - MultiPhaseMultiComponentFluid & newConstitutiveRelation = dynamicCast< MultiPhaseMultiComponentFluid & >( *clone ); - newConstitutiveRelation.m_p1Index = m_p1Index; - newConstitutiveRelation.m_p2Index = m_p2Index; - - newConstitutiveRelation.createPVTModels(); - - return clone; -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -integer MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::getWaterPhaseIndex() const -{ - string const expectedWaterPhaseNames[] = { "Water", "water", "Liquid", "liquid" }; - return PVTFunctionHelpers::findName( m_phaseNames, expectedWaterPhaseNames, viewKeyStruct::phaseNamesString() ); -} - - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -void MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::postProcessInput() -{ - MultiFluidBase::postProcessInput(); - - GEOSX_THROW_IF_NE_MSG( numFluidPhases(), 2, - GEOSX_FMT( "{}: invalid number of phases", getFullName() ), - InputError ); - GEOSX_THROW_IF_NE_MSG( numFluidComponents(), 2, - GEOSX_FMT( "{}: invalid number of components", getFullName() ), - InputError ); - GEOSX_THROW_IF_NE_MSG( m_phasePVTParaFiles.size(), 2, - GEOSX_FMT( "{}: invalid number of values in attribute '{}'", getFullName() ), - InputError ); - - // NOTE: for now, the names of the phases are still hardcoded here - // Later, we could read them from the XML file and we would then have a general class here - - string const expectedWaterPhaseNames[] = { "Water", "water", "Liquid", "liquid" }; - m_p1Index = PVTFunctionHelpers::findName( m_phaseNames, expectedWaterPhaseNames, viewKeyStruct::phaseNamesString() ); - - string const expectedGasPhaseNames[] = { "CO2", "co2", "gas", "Gas" }; - m_p2Index = PVTFunctionHelpers::findName( m_phaseNames, expectedGasPhaseNames, viewKeyStruct::phaseNamesString() ); - - createPVTModels(); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -void MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::createPVTModels() -{ - // 1) Create the viscosity and density models - for( string const & filename : m_phasePVTParaFiles ) - { - std::ifstream is( filename ); - string str; - while( std::getline( is, str ) ) - { - string_array const strs = stringutilities::tokenize( str, " " ); - - if( strs[0] == "DensityFun" ) - { - if( strs[1] == P1DENS::catalogName() ) - { - m_p1Density = std::make_unique< P1DENS >( getName() + '_' + P1DENS::catalogName(), strs, m_componentNames, m_componentMolarWeight ); - } - else if( strs[1] == P2DENS::catalogName() ) - { - m_p2Density = std::make_unique< P2DENS >( getName() + '_' + P2DENS::catalogName(), strs, m_componentNames, m_componentMolarWeight ); - } - } - else if( strs[0] == "ViscosityFun" ) - { - if( strs[1] == P1VISC::catalogName() ) - { - m_p1Viscosity = std::make_unique< P1VISC >( getName() + '_' + P1VISC::catalogName(), strs, m_componentNames, m_componentMolarWeight ); - } - else if( strs[1] == P2VISC::catalogName() ) - { - m_p2Viscosity = std::make_unique< P2VISC >( getName() + '_' + P2VISC::catalogName(), strs, m_componentNames, m_componentMolarWeight ); - } - } - else - { - GEOSX_THROW( GEOSX_FMT( "{}: invalid PVT function type '{}'", getFullName(), strs[0] ), InputError ); - } - } - is.close(); - } - - GEOSX_THROW_IF( m_p1Density == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1DENS::catalogName() ), - InputError ); - GEOSX_THROW_IF( m_p2Density == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2DENS::catalogName() ), - InputError ); - GEOSX_THROW_IF( m_p1Viscosity == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P1VISC::catalogName() ), - InputError ); - GEOSX_THROW_IF( m_p2Viscosity == nullptr, - GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), P2VISC::catalogName() ), - InputError ); - - // 2) Create the flash model - { - std::ifstream is( m_flashModelParaFile ); - string str; - while( std::getline( is, str ) ) - { - string_array const strs = stringutilities::tokenize( str, " " ); - if( strs[0] == "FlashModel" ) - { - if( strs[1] == FLASH::catalogName() ) - { - m_flash = std::make_unique< FLASH >( getName() + '_' + FLASH::catalogName(), strs, m_phaseNames, m_componentNames, m_componentMolarWeight ); - } - } - else - { - GEOSX_THROW( GEOSX_FMT( "{}: invalid flash model type '{}'", getFullName(), strs[0] ), InputError ); - } - } - is.close(); - } - - GEOSX_THROW_IF( m_flash == nullptr, - GEOSX_FMT( "{}: flash model {} not found in input files", getFullName(), FLASH::catalogName() ), - InputError ); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -typename MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWrapper -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::createKernelWrapper() -{ - return KernelWrapper( m_p1Index, - m_p2Index, - *m_p1Density, - *m_p1Viscosity, - *m_p2Density, - *m_p2Viscosity, - *m_flash, - m_componentMolarWeight.toViewConst(), - m_useMass, - m_phaseFraction.toView(), - m_phaseDensity.toView(), - m_phaseMassDensity.toView(), - m_phaseViscosity.toView(), - m_phaseCompFraction.toView(), - m_totalDensity.toView() ); -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWrapper:: - KernelWrapper( integer const p1Index, - integer const p2Index, - P1DENS const & p1DensityWrapper, - P1VISC const & p1ViscosityWrapper, - P2DENS const & p2DensityWrapper, - P2VISC const & p2ViscosityWrapper, - FLASH const & flashWrapper, - arrayView1d< geosx::real64 const > componentMolarWeight, - bool const useMass, - PhaseProp::ViewType phaseFraction, - PhaseProp::ViewType phaseDensity, - PhaseProp::ViewType phaseMassDensity, - PhaseProp::ViewType phaseViscosity, - PhaseComp::ViewType phaseCompFraction, - FluidProp::ViewType totalDensity ) - : MultiFluidBase::KernelWrapper( std::move( componentMolarWeight ), - useMass, - std::move( phaseFraction ), - std::move( phaseDensity ), - std::move( phaseMassDensity ), - std::move( phaseViscosity ), - std::move( phaseCompFraction ), - std::move( totalDensity ) ), - m_p1Index( p1Index ), - m_p2Index( p2Index ), - m_p1Density( p1DensityWrapper.createKernelWrapper() ), - m_p1Viscosity( p1ViscosityWrapper.createKernelWrapper() ), - m_p2Density( p2DensityWrapper.createKernelWrapper() ), - m_p2Viscosity( p2ViscosityWrapper.createKernelWrapper() ), - m_flash( flashWrapper.createKernelWrapper() ) -{} - -// explicit instantiation of the model template; unfortunately we can't use CO2BrinePhillipsFluid alias for this -template class MultiPhaseMultiComponentFluid< PVTProps::PhillipsBrineDensity, - PVTProps::PhillipsBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility >; - -template class MultiPhaseMultiComponentFluid< PVTProps::EzrokhiBrineDensity, - PVTProps::EzrokhiBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility >; - -REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrinePhillipsFluid, string const &, Group * const ) -REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrineEzrokhiFluid, string const &, Group * const ) - -} //namespace constitutive - -} //namespace geosx diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp deleted file mode 100644 index cb0b1ec753c..00000000000 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ /dev/null @@ -1,502 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 TotalEnergies - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file MultiPhaseMultiComponentFluid.hpp - */ - -#ifndef GEOSX_CONSTITUTIVE_FLUID_MULTIPHASEMULTICOMPONENTFLUID_HPP_ -#define GEOSX_CONSTITUTIVE_FLUID_MULTIPHASEMULTICOMPONENTFLUID_HPP_ - -#include "constitutive/fluid/MultiFluidBase.hpp" -#include "constitutive/fluid/MultiFluidUtils.hpp" -#include "constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp" -#include "constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp" -#include "constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp" -#include "constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp" -#include "constitutive/fluid/PVTFunctions/CO2Solubility.hpp" -#include "constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp" -#include "constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp" - -#include - -namespace geosx -{ - -namespace constitutive -{ - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -class MultiPhaseMultiComponentFluid : public MultiFluidBase -{ -public: - - using exec_policy = parallelDevicePolicy<>; - - MultiPhaseMultiComponentFluid( string const & name, - Group * const parent ); - - virtual std::unique_ptr< ConstitutiveBase > - deliverClone( string const & name, - Group * const parent ) const override; - - - static string catalogName(); - - virtual string getCatalogName() const override { return catalogName(); } - - /** - * @brief Kernel wrapper class for MultiPhaseMultiComponentFluid. - */ - class KernelWrapper final : public MultiFluidBase::KernelWrapper - { -public: - - GEOSX_HOST_DEVICE - virtual void compute( real64 const pressure, - real64 const temperature, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition, - arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseFraction, - arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, - arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, - arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, - arraySlice2d< real64, multifluid::USD_PHASE_COMP-2 > const & phaseCompFraction, - real64 & totalDensity ) const override; - - GEOSX_HOST_DEVICE - virtual void compute( real64 const pressure, - real64 const temperature, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition, - PhaseProp::SliceType const phaseFraction, - PhaseProp::SliceType const phaseDensity, - PhaseProp::SliceType const phaseMassDensity, - PhaseProp::SliceType const phaseViscosity, - PhaseComp::SliceType const phaseCompFraction, - FluidProp::SliceType const totalDensity ) const override; - - GEOSX_HOST_DEVICE - virtual void update( localIndex const k, - localIndex const q, - real64 const pressure, - real64 const temperature, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition ) const override; - -private: - - friend class MultiPhaseMultiComponentFluid; - - KernelWrapper( integer p1Index, - integer p2Index, - P1DENS const & p1DensityWrapper, - P1VISC const & p1ViscosityWrapper, - P2DENS const & p2DensityWrapper, - P2VISC const & p2ViscosityWrapper, - FLASH const & flashWrapper, - arrayView1d< real64 const > componentMolarWeight, - bool const useMass, - PhaseProp::ViewType phaseFraction, - PhaseProp::ViewType phaseDensity, - PhaseProp::ViewType phaseMassDensity, - PhaseProp::ViewType phaseViscosity, - PhaseComp::ViewType phaseCompFraction, - FluidProp::ViewType totalDensity ); - - /// Index of the liquid phase - integer m_p1Index; - - /// Index of the gas phase - integer m_p2Index; - - /// Kernel wrapper for brine density updates - typename P1DENS::KernelWrapper m_p1Density; - - /// Kernel wrapper for brine viscosity updates - typename P1VISC::KernelWrapper m_p1Viscosity; - - /// Kernel wrapper for CO2 density updates - typename P2DENS::KernelWrapper m_p2Density; - - /// Kernel wrapper for CO2 viscosity updates - typename P2VISC::KernelWrapper m_p2Viscosity; - - /// Kernel wrapper for phase fraction and phase component fraction updates - typename FLASH::KernelWrapper m_flash; - }; - - virtual integer getWaterPhaseIndex() const override final; - - /** - * @brief Create an update kernel wrapper. - * @return the wrapper - */ - KernelWrapper createKernelWrapper(); - - struct viewKeyStruct : MultiFluidBase::viewKeyStruct - { - static constexpr char const * flashModelParaFileString() { return "flashModelParaFile"; } - static constexpr char const * phasePVTParaFilesString() { return "phasePVTParaFiles"; } - }; - -protected: - - virtual void postProcessInput() override; - -private: - - void createPVTModels(); - - /// Names of the files defining the viscosity and density models - path_array m_phasePVTParaFiles; - - /// Name of the file defining the flash model - Path m_flashModelParaFile; - - /// Index of the liquid phase - integer m_p1Index; - - /// Index of the gas phase - integer m_p2Index; - - /// Pointer to the brine density model - std::unique_ptr< P1DENS > m_p1Density; - - /// Pointer to the brine viscosity model - std::unique_ptr< P1VISC > m_p1Viscosity; - - /// Pointer to the CO2 density model - std::unique_ptr< P2DENS > m_p2Density; - - /// Pointer to the CO2 viscosity model - std::unique_ptr< P2VISC > m_p2Viscosity; - - /// Pointer to the flash model - std::unique_ptr< FLASH > m_flash; -}; - -// this alias will be useful in constitutive dispatch -using CO2BrinePhillipsFluid = MultiPhaseMultiComponentFluid< PVTProps::PhillipsBrineDensity, - PVTProps::PhillipsBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility >; - -using CO2BrineEzrokhiFluid = MultiPhaseMultiComponentFluid< PVTProps::EzrokhiBrineDensity, - PVTProps::EzrokhiBrineViscosity, - PVTProps::SpanWagnerCO2Density, - PVTProps::FenghourCO2Viscosity, - PVTProps::CO2Solubility >; - -template< typename P1DENSWRAPPER, typename P1VISCWRAPPER, typename P2DENSWRAPPER, typename P2VISCWRAPPER, typename FLASHWRAPPER > -GEOSX_HOST_DEVICE -inline void -MultiPhaseMultiComponentFluid< P1DENSWRAPPER, P1VISCWRAPPER, P2DENSWRAPPER, P2VISCWRAPPER, FLASHWRAPPER >::KernelWrapper:: - compute( real64 pressure, - real64 temperature, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition, - arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseFraction, - arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseDensity, - arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseMassDensity, - arraySlice1d< real64, multifluid::USD_PHASE - 2 > const & phaseViscosity, - arraySlice2d< real64, multifluid::USD_PHASE_COMP-2 > const & phaseCompFraction, - real64 & totalDensity ) const -{ - integer constexpr numComp = 2; - integer constexpr numPhase = 2; - integer const ip1 = m_p1Index; - integer const ip2 = m_p2Index; - - // 1. Convert input mass fractions to mole fractions - - stackArray1d< real64, numComp > compMoleFrac( numComp ); - if( m_useMass ) - { - // convert mass fractions to mole fractions - convertToMoleFractions< numComp >( composition, - compMoleFrac ); - } - else - { - for( integer ic = 0; ic < numComp; ++ic ) - { - compMoleFrac[ic] = composition[ic]; - } - } - - // 2. Compute phase fractions and phase component fractions - - real64 const temperatureInCelsius = temperature - 273.15; - m_flash.compute( pressure, - temperatureInCelsius, - compMoleFrac.toSliceConst(), - phaseFraction, - phaseCompFraction ); - - // 3. Compute phase densities and phase viscosities - - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseDensity[ip1], - m_useMass ); - m_p1Viscosity.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseViscosity[ip1], - m_useMass ); - - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseDensity[ip2], - m_useMass ); - m_p2Viscosity.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseViscosity[ip2], - m_useMass ); - - // 4. Depending on the m_useMass flag, convert to mass variables or simply compute mass density - - // TODO: for now the treatment of molar/mass density requires too many interpolations in the tables, it needs to be fixed - // we should modify the PVT functions so that they can return phaseMassDens, phaseDens, and phaseMW in one call - - if( m_useMass ) - { - // compute the phase molecular weights (ultimately, get that from the PVT function) - real64 phaseMolecularWeight[numPhase]{}; - real64 phaseMolarDens{}; - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseMolarDens, - false ); - phaseMolecularWeight[ip1] = phaseDensity[ip1] / phaseMolarDens; - - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseMolarDens, - false ); - phaseMolecularWeight[ip2] = phaseDensity[ip2] / phaseMolarDens; - - // copy the densities into the mass densities - for( integer ip = 0; ip < numPhase; ++ip ) - { - phaseMassDensity[ip] = phaseDensity[ip]; - } - - // convert mole fractions to mass fractions - convertToMassFractions< numComp >( phaseMolecularWeight, - phaseFraction, - phaseCompFraction ); - } - else - { - // for now, we have to compute the phase mass density here - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip1].toSliceConst(), - phaseMassDensity[ip1], - true ); - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction[ip2].toSliceConst(), - phaseMassDensity[ip2], - true ); - } - - // 5. Compute total fluid mass/molar density and derivatives - - computeTotalDensity< numComp, numPhase >( phaseFraction, - phaseDensity, - totalDensity ); - -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -GEOSX_HOST_DEVICE -inline void -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWrapper:: - compute( real64 const pressure, - real64 const temperature, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & composition, - PhaseProp::SliceType const phaseFraction, - PhaseProp::SliceType const phaseDensity, - PhaseProp::SliceType const phaseMassDensity, - PhaseProp::SliceType const phaseViscosity, - PhaseComp::SliceType const phaseCompFraction, - FluidProp::SliceType const totalDensity ) const -{ - integer constexpr numComp = 2; - integer constexpr numPhase = 2; - integer const ip1 = m_p1Index; - integer const ip2 = m_p2Index; - - // 1. Convert input mass fractions to mole fractions and keep derivatives - - stackArray1d< real64, numComp > compMoleFrac( numComp ); - real64 dCompMoleFrac_dCompMassFrac[numComp][numComp]{}; - - if( m_useMass ) - { - convertToMoleFractions( composition, - compMoleFrac, - dCompMoleFrac_dCompMassFrac ); - } - else - { - for( integer ic = 0; ic < numComp; ++ic ) - { - compMoleFrac[ic] = composition[ic]; - } - } - - // 2. Compute phase fractions and phase component fractions - - real64 const temperatureInCelsius = temperature - 273.15; - m_flash.compute( pressure, - temperatureInCelsius, - compMoleFrac.toSliceConst(), - phaseFraction, - phaseCompFraction ); - - // 3. Compute phase densities and phase viscosities - - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), - phaseDensity.value[ip1], phaseDensity.derivs[ip1], - m_useMass ); - m_p1Viscosity.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), - phaseViscosity.value[ip1], phaseViscosity.derivs[ip1], - m_useMass ); - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), - phaseDensity.value[ip2], phaseDensity.derivs[ip2], - m_useMass ); - m_p2Viscosity.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), - phaseViscosity.value[ip2], phaseViscosity.derivs[ip2], - m_useMass ); - - // 4. Depending on the m_useMass flag, convert to mass variables or simply compute mass density - - // TODO: for now the treatment of molar/mass density requires too many interpolations in the tables, it needs to be fixed - // we should modify the PVT functions so that they can return phaseMassDens, phaseDens, and phaseMW in one call - - if( m_useMass ) - { - - // 4.1 Compute the phase molecular weights (ultimately, get that from the PVT function) - - real64 phaseMolecularWeight[numPhase]{}; - real64 dPhaseMolecularWeight[numPhase][numComp+2]{}; - - real64 phaseMolarDens{}; - stackArray1d< real64, numComp+2 > dPhaseMolarDens( numComp+2 ); - - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), - phaseMolarDens, dPhaseMolarDens.toSlice(), - false ); - phaseMolecularWeight[ip1] = phaseDensity.value[ip1] / phaseMolarDens; - for( integer idof = 0; idof < numComp+2; ++idof ) - { - dPhaseMolecularWeight[ip1][idof] = phaseDensity.derivs[ip1][idof] / phaseMolarDens - phaseMolecularWeight[ip1] * dPhaseMolarDens[idof] / phaseMolarDens; - } - - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), - phaseMolarDens, dPhaseMolarDens.toSlice(), - false ); - phaseMolecularWeight[ip2] = phaseDensity.value[ip2] / phaseMolarDens; - for( integer idof = 0; idof < numComp+2; ++idof ) - { - dPhaseMolecularWeight[ip2][idof] = phaseDensity.derivs[ip2][idof] / phaseMolarDens - phaseMolecularWeight[ip2] * dPhaseMolarDens[idof] / phaseMolarDens; - } - - // 4.2 Convert the mole fractions to mass fractions - convertToMassFractions( dCompMoleFrac_dCompMassFrac, - phaseMolecularWeight, - dPhaseMolecularWeight, - phaseFraction, - phaseCompFraction, - phaseDensity.derivs, - phaseViscosity.derivs ); - - - // 4.3 Copy the phase densities into the phase mass densities - for( integer ip = 0; ip < numPhase; ++ip ) - { - phaseMassDensity.value[ip] = phaseDensity.value[ip]; - for( integer idof = 0; idof < numComp+2; ++idof ) - { - phaseMassDensity.derivs[ip][idof] = phaseDensity.derivs[ip][idof]; - } - } - } - else - { - // for now, we have to compute the phase mass density here - m_p1Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), - phaseMassDensity.value[ip1], phaseMassDensity.derivs[ip1], - true ); - m_p2Density.compute( pressure, - temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), - phaseMassDensity.value[ip2], phaseMassDensity.derivs[ip2], - true ); - } - - // 5. Compute total fluid mass/molar density and derivatives - - computeTotalDensity( phaseFraction, - phaseDensity, - totalDensity ); - -} - -template< typename P1DENS, typename P1VISC, typename P2DENS, typename P2VISC, typename FLASH > -GEOSX_HOST_DEVICE inline void -MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWrapper:: - update( localIndex const k, - localIndex const q, - real64 const pressure, - real64 const temperature, - arraySlice1d< geosx::real64 const, compflow::USD_COMP - 1 > const & composition ) const -{ - compute( pressure, - temperature, - composition, - m_phaseFraction( k, q ), - m_phaseDensity( k, q ), - m_phaseMassDensity( k, q ), - m_phaseViscosity( k, q ), - m_phaseCompFraction( k, q ), - m_totalDensity( k, q ) ); -} - -} //namespace constitutive - -} //namespace geosx - -#endif //GEOSX_CONSTITUTIVE_FLUID_MULTIPHASEMULTICOMPONENTFLUID_HPP_ From 42b5edf43301fc6a8f02ba3cb2234ea291450703 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Fri, 25 Feb 2022 08:46:09 -0800 Subject: [PATCH 6/7] fixed bug --- .../constitutive/fluid/MultiFluidBase.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index 31e0856229d..8362cf5991f 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -608,20 +608,20 @@ MultiFluidBase::KernelWrapper:: MultiFluidVarSlice< real64, 2, USD_PHASE_COMP - 2, USD_PHASE_COMP_DC - 2 > phaseCompFracAndDeriv { phaseCompFrac, dPhaseCompFrac[0][0] }; - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseDens_dComp( 1, 1, numPhase, numComp ); - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseVisc_dComp( 1, 1, numPhase, numComp ); - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseEnthalpy_dComp( 1, 1, numPhase, numComp ); - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseInternalEnergy_dComp( 1, 1, numPhase, numComp ); + StackArray< real64, 4, maxNumDof *maxNumPhase, LAYOUT_PHASE_DC > dPhaseDens( 1, 1, numPhase, numComp+2 ); + StackArray< real64, 4, maxNumDof *maxNumPhase, LAYOUT_PHASE_DC > dPhaseVisc( 1, 1, numPhase, numComp+2 ); + StackArray< real64, 4, maxNumDof *maxNumPhase, LAYOUT_PHASE_DC > dPhaseEnthalpy( 1, 1, numPhase, numComp+2 ); + StackArray< real64, 4, maxNumDof *maxNumPhase, LAYOUT_PHASE_DC > dPhaseInternalEnergy( 1, 1, numPhase, numComp+2 ); convertToMassFractions( dCompMoleFrac_dCompMassFrac, phaseMolecularWeight, dPhaseMolecularWeight, phaseFracAndDeriv, phaseCompFracAndDeriv, - dPhaseDens_dComp[0][0], - dPhaseVisc_dComp[0][0], - dPhaseEnthalpy_dComp[0][0], - dPhaseInternalEnergy_dComp[0][0] ); + dPhaseDens[0][0], + dPhaseVisc[0][0], + dPhaseEnthalpy[0][0], + dPhaseInternalEnergy[0][0] ); } template< integer maxNumComp, integer maxNumPhase > From 3e040aa8cc30d4d1f607938650296ccbc7054b7c Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Fri, 25 Feb 2022 09:18:10 -0800 Subject: [PATCH 7/7] updated integratedTests submodule --- integratedTests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integratedTests b/integratedTests index 398a458235c..03fce312993 160000 --- a/integratedTests +++ b/integratedTests @@ -1 +1 @@ -Subproject commit 398a458235c8465e8c553800ebe2a50079d1d246 +Subproject commit 03fce312993c27a10e2ee781b4c1e1a518ef055e