diff --git a/integratedTests b/integratedTests index 398a458235c..03fce312993 160000 --- a/integratedTests +++ b/integratedTests @@ -1 +1 @@ -Subproject commit 398a458235c8465e8c553800ebe2a50079d1d246 +Subproject commit 03fce312993c27a10e2ee781b4c1e1a518ef055e diff --git a/src/coreComponents/constitutive/CMakeLists.txt b/src/coreComponents/constitutive/CMakeLists.txt index 05e1bc11d84..18d5595c6e4 100644 --- a/src/coreComponents/constitutive/CMakeLists.txt +++ b/src/coreComponents/constitutive/CMakeLists.txt @@ -24,11 +24,12 @@ 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/PhaseModel.hpp fluid/PVTDriver.hpp fluid/PVTOData.hpp fluid/PVTFunctions/PhillipsBrineDensity.hpp @@ -38,7 +39,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 @@ -131,11 +133,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 32f666acd7c..e31ed7cdb6e 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp @@ -496,6 +496,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 ), @@ -511,6 +513,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() ) @@ -533,6 +537,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 33b0dcbdd96..ada95113d91 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp @@ -69,6 +69,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; @@ -80,6 +82,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; @@ -127,6 +131,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 ); @@ -368,10 +374,12 @@ 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 & totalDensity ) const { - GEOSX_UNUSED_VAR( temperature ); + GEOSX_UNUSED_VAR( temperature, phaseEnthalpy, phaseInternalEnergy ); real64 compMoleFrac[NC_BO]{}; real64 phaseMolecularWeight[NP_BO]{}; @@ -435,10 +443,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]{}; @@ -492,7 +502,9 @@ BlackOilFluid::KernelWrapper:: phaseFraction, phaseCompFraction, phaseDensity.derivs, - phaseViscosity.derivs ); + phaseViscosity.derivs, + phaseEnthalpy.derivs, + phaseInternalEnergy.derivs ); } // 5. Compute total fluid mass/molar density and derivatives @@ -1101,6 +1113,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 8210fd9801d..37bdd5f409e 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluidBase.cpp @@ -299,6 +299,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 ), @@ -307,6 +309,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 def272249c8..66823b63a7b 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..262a1d7a9b3 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp @@ -0,0 +1,386 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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 PHASE1, typename PHASE2, typename FLASH > class + TwoPhaseCatalogNames {}; + +template<> class + 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< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, + PVTProps::CO2Solubility > +{ +public: + static string name() { return "CO2BrinePhillipsThermalFluid"; } +}; + +template<> class + 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< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< 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 PHASE1, typename PHASE2, typename FLASH > +string CO2BrineFluid< PHASE1, PHASE2, FLASH >::catalogName() +{ + return TwoPhaseCatalogNames< PHASE1, PHASE2, FLASH >::name(); +} + +template< typename PHASE1, typename PHASE2, typename FLASH > +CO2BrineFluid< PHASE1, PHASE2, 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" ); + + // if this is a thermal model, we need to make sure that the arrays will be properly displayed and saved to restart + if( isThermal() ) + { + 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 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< PHASE1, PHASE2, 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 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 PHASE1, typename PHASE2, typename FLASH > +void CO2BrineFluid< PHASE1, PHASE2, 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 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, density, enthalpy, and internal energy 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] == toString( SubModelInputNames::DENSITY ) ) + { + if( strs[1] == PHASE1::Density::catalogName() ) + { + phase1InputParams[PHASE1::InputParamOrder::DENSITY] = strs; + } + else if( strs[1] == PHASE2::Density::catalogName() ) + { + phase2InputParams[PHASE2::InputParamOrder::DENSITY] = strs; + } + } + else if( strs[0] == toString( SubModelInputNames::VISCOSITY ) ) + { + if( strs[1] == PHASE1::Viscosity::catalogName() ) + { + phase1InputParams[PHASE1::InputParamOrder::VISCOSITY] = strs; + } + else if( strs[1] == PHASE2::Viscosity::catalogName() ) + { + phase2InputParams[PHASE2::InputParamOrder::VISCOSITY] = strs; + } + } + else if( strs[0] == toString( SubModelInputNames::ENTHALPY ) ) + { + if( strs[1] == PHASE1::Enthalpy::catalogName() ) + { + phase1InputParams[PHASE1::InputParamOrder::ENTHALPY] = strs; + } + else if( strs[1] == PHASE2::Enthalpy::catalogName() ) + { + phase2InputParams[PHASE2::InputParamOrder::ENTHALPY] = strs; + } + } + else if( strs[0] == toString( SubModelInputNames::INTERNALENERGY ) ) + { + if( strs[1] == PHASE1::InternalEnergy::catalogName() ) + { + phase1InputParams[PHASE1::InputParamOrder::INTERNALENERGY] = strs; + } + else if( strs[1] == PHASE2::InternalEnergy::catalogName() ) + { + phase2InputParams[PHASE2::InputParamOrder::INTERNALENERGY] = strs; + } + } + 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 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( phase2InputParams[PHASE2::InputParamOrder::DENSITY].empty(), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE2::Density::catalogName() ), + InputError ); + 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( phase2InputParams[PHASE2::InputParamOrder::VISCOSITY].empty(), + GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE2::Viscosity::catalogName() ), + InputError ); + + // 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( 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( 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( 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 ); + + // 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 + { + 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 PHASE1, typename PHASE2, typename FLASH > +typename CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper +CO2BrineFluid< PHASE1, PHASE2, FLASH >::createKernelWrapper() +{ + return KernelWrapper( m_p1Index, + m_p2Index, + *m_phase1, + *m_phase2, + *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 PHASE1, typename PHASE2, typename FLASH > +CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper:: + KernelWrapper( integer const p1Index, + integer const p2Index, + PHASE1 const & phase1, + PHASE2 const & phase2, + 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_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< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PVTProps::CO2Solubility >; +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< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PVTProps::CO2Solubility >; +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 ) +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/CO2BrineFluid.hpp b/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp new file mode 100644 index 00000000000..268642a1a6a --- /dev/null +++ b/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp @@ -0,0 +1,602 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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.hpp + */ + +#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" +#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/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 +{ + +namespace constitutive +{ + +template< typename PHASE1, typename PHASE2, typename FLASH > +class CO2BrineFluid : public MultiFluidBase +{ +public: + + using exec_policy = parallelDevicePolicy<>; + + 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(); } + + virtual bool isThermal() const override; + + /** + * @brief Kernel wrapper class for CO2BrineFluid. + */ + 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, + 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; + + 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, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, + 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 CO2BrineFluid; + + KernelWrapper( integer p1Index, + integer p2Index, + PHASE1 const & phase1, + PHASE2 const & phase2, + 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 + integer m_p1Index; + + /// Index of the gas phase + integer m_p2Index; + + + /// Brine constitutive kernel wrappers + typename PHASE1::KernelWrapper m_phase1; + + // CO2 constitutive kernel wrapper + typename PHASE2::KernelWrapper m_phase2; + + // Flash kernel wrapper + 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 + */ + 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; + + + /// Brine constitutive models + std::unique_ptr< PHASE1 > m_phase1; + + // CO2 constitutive models + std::unique_ptr< PHASE2 > m_phase2; + + // Flash model + std::unique_ptr< FLASH > m_flash; + +}; + +// these aliases are useful in constitutive dispatch +using CO2BrinePhillipsFluid = + CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PVTProps::CO2Solubility >; +using CO2BrinePhillipsThermalFluid = + CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, + PVTProps::CO2Solubility >; + +using CO2BrineEzrokhiFluid = + CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >, + PVTProps::CO2Solubility >; +using CO2BrineEzrokhiThermalFluid = + CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >, + PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >, + PVTProps::CO2Solubility >; + +template< typename PHASE1, typename PHASE2, typename FLASH > +GEOSX_HOST_DEVICE +inline void +CO2BrineFluid< PHASE1, PHASE2, FLASH >::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, + 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 +{ + 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 ); + 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_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_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 + + // 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_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseMolarDens, + false ); + phaseMolecularWeight[ip1] = phaseDensity[ip1] / phaseMolarDens; + + m_phase2.density.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_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip1].toSliceConst(), + phaseMassDensity[ip1], + true ); + m_phase2.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction[ip2].toSliceConst(), + phaseMassDensity[ip2], + true ); + } + + // 6. Compute total fluid mass/molar density + + computeTotalDensity< numComp, numPhase >( phaseFraction, + phaseDensity, + totalDensity ); +} + +template< typename PHASE1, typename PHASE2, typename FLASH > +GEOSX_HOST_DEVICE +inline void +CO2BrineFluid< PHASE1, PHASE2, 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, + PhaseProp::SliceType const phaseEnthalpy, + PhaseProp::SliceType const phaseInternalEnergy, + 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_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseDensity.value[ip1], phaseDensity.derivs[ip1], + m_useMass ); + m_phase1.viscosity.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseViscosity.value[ip1], phaseViscosity.derivs[ip1], + m_useMass ); + m_phase2.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseDensity.value[ip2], phaseDensity.derivs[ip2], + m_useMass ); + m_phase2.viscosity.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseViscosity.value[ip2], phaseViscosity.derivs[ip2], + m_useMass ); + + + // 4. Compute enthalpy and internal energy + + m_phase1.enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseEnthalpy.value[ip1], phaseEnthalpy.derivs[ip1], + m_useMass ); + m_phase1.internalEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseInternalEnergy.value[ip1], phaseInternalEnergy.derivs[ip1], + m_useMass ); + + m_phase2.enthalpy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseEnthalpy.value[ip2], phaseEnthalpy.derivs[ip2], + m_useMass ); + m_phase2.internalEnergy.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseInternalEnergy.value[ip2], phaseInternalEnergy.derivs[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 + + 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_phase1.density.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_phase2.density.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, + phaseEnthalpy.derivs, + phaseInternalEnergy.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_phase1.density.compute( pressure, + temperatureInCelsius, + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseMassDensity.value[ip1], phaseMassDensity.derivs[ip1], + true ); + m_phase2.density.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 PHASE1, typename PHASE2, typename FLASH > +GEOSX_HOST_DEVICE inline void +CO2BrineFluid< PHASE1, PHASE2, 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_phaseEnthalpy( k, q ), + m_phaseInternalEnergy( k, q ), + m_phaseCompFraction( k, q ), + 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_CO2BRINEFLUID_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 c3bb78d5928..52abc92b97d 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 @@ -254,9 +263,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 @@ -368,7 +380,9 @@ CompositionalMultiphaseFluid::KernelWrapper:: phaseFraction, phaseCompFraction, phaseDensity.derivs, - phaseViscosity.derivs ); + phaseViscosity.derivs, + phaseEnthalpy.derivs, + phaseInternalEnergy.derivs ); } // 5. Compute total fluid mass/molar density and derivatives @@ -396,6 +410,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 ) ); } 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 d82a22af5b0..623b333defa 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; @@ -109,6 +113,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 ); @@ -321,10 +327,12 @@ 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 & totalDensity ) const { - GEOSX_UNUSED_VAR( temperature ); + GEOSX_UNUSED_VAR( temperature, phaseEnthalpy, phaseInternalEnergy ); integer constexpr maxNumComp = 3; integer constexpr maxNumPhase = 3; @@ -369,10 +377,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 ); using Deriv = multifluid::DerivativeOffset; @@ -438,6 +448,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 ef3975d0b1b..cc42425a961 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp @@ -62,6 +62,12 @@ MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) registerExtrinsicData( extrinsicMeshData::multifluid::phaseViscosity{}, &m_phaseViscosity.value ); registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseViscosity{}, &m_phaseViscosity.derivs ); + registerExtrinsicData( extrinsicMeshData::multifluid::phaseEnthalpy{}, &m_phaseEnthalpy.value ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseEnthalpy{}, &m_phaseEnthalpy.derivs ); + + registerExtrinsicData( extrinsicMeshData::multifluid::phaseInternalEnergy{}, &m_phaseInternalEnergy.value ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseInternalEnergy{}, &m_phaseInternalEnergy.derivs ); + registerExtrinsicData( extrinsicMeshData::multifluid::phaseCompFraction{}, &m_phaseCompFraction.value ); registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseCompFraction{}, &m_phaseCompFraction.derivs ); @@ -76,25 +82,31 @@ void MultiFluidBase::resizeFields( localIndex const size, localIndex const numPt { integer const numPhase = numFluidPhases(); integer const numComp = numFluidComponents(); - integer const numDeriv = numComp + 2; + integer const numDof = numComp + 2; m_phaseFraction.value.resize( size, numPts, numPhase ); - m_phaseFraction.derivs.resize( size, numPts, numPhase, numDeriv ); + m_phaseFraction.derivs.resize( size, numPts, numPhase, numDof ); m_phaseDensity.value.resize( size, numPts, numPhase ); - m_phaseDensity.derivs.resize( size, numPts, numPhase, numDeriv ); + m_phaseDensity.derivs.resize( size, numPts, numPhase, numDof ); m_phaseMassDensity.value.resize( size, numPts, numPhase ); - m_phaseMassDensity.derivs.resize( size, numPts, numPhase, numDeriv ); + m_phaseMassDensity.derivs.resize( size, numPts, numPhase, numDof ); m_phaseViscosity.value.resize( size, numPts, numPhase ); - m_phaseViscosity.derivs.resize( size, numPts, numPhase, numDeriv ); + m_phaseViscosity.derivs.resize( size, numPts, numPhase, numDof ); + + m_phaseEnthalpy.value.resize( size, numPts, numPhase ); + m_phaseEnthalpy.derivs.resize( size, numPts, numPhase, numDof ); + + m_phaseInternalEnergy.value.resize( size, numPts, numPhase ); + m_phaseInternalEnergy.derivs.resize( size, numPts, numPhase, numDof ); m_phaseCompFraction.value.resize( size, numPts, numPhase, numComp ); - m_phaseCompFraction.derivs.resize( size, numPts, numPhase, numComp, numDeriv ); + m_phaseCompFraction.derivs.resize( size, numPts, numPhase, numComp, numDof ); m_totalDensity.value.resize( size, numPts ); - m_totalDensity.derivs.resize( size, numPts, numDeriv ); + m_totalDensity.derivs.resize( size, numPts, numDof ); m_initialTotalMassDensity.resize( size, numPts ); } @@ -113,6 +125,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 ); @@ -155,6 +173,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 d00f1f48ae5..8362cf5991f 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 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 + */ + virtual bool isThermal() const { return false; } + /** * @brief Get the mass flag. * @return boolean value indicating whether the model is using mass-based quantities (as opposed to mole-based) @@ -143,6 +151,17 @@ 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; } + + arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseEnthalpy() const + { return m_phaseEnthalpy.derivs; } + + arrayView3d< real64 const, multifluid::USD_PHASE > phaseInternalEnergy() const + { return m_phaseInternalEnergy.value; } + + arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseInternalEnergy() const + { return m_phaseInternalEnergy.derivs; } struct viewKeyStruct : ConstitutiveBase::viewKeyStruct { @@ -208,6 +227,8 @@ class MultiFluidBase : public ConstitutiveBase * @param[out] phaseDensity the array of phase densities (+ derivatives) * @param[out] phaseMassDensity the array of phase mass densities (+derivatives) * @param[out] phaseViscosity the array of phase viscosities (+derivatives) + * @param[out] phaseEnthalpy the array of phase enthalpy (+derivatives) + * @param[out] phaseInternalEnergy the array of phase internal energy (+derivatives) * @param[out] phaseCompFraction the array of phase component fractions (+derivatives) * @param[out] totalDensity the total density (+derivatives) */ @@ -217,6 +238,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 ) ), @@ -225,6 +248,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 ) ) { } @@ -283,6 +308,8 @@ class MultiFluidBase : public ConstitutiveBase * @param[inout] phaseCompFrac the phase component fractions in moles that will be converted to mass * @param[inout] dPhaseDens the derivatives of phase densities wrt pressure, temperature, and comp fractions * @param[inout] dPhaseVisc the derivatives of phase viscosities wrt pressure, temperature, and comp fractions + * @param[inout] dPhaseEnthalpy the derivatives of phase enthalpy wrt pressure, temperature, and comp fractions + * @param[inout] dPhaseInternalEnergy the derivatives of phase internal energy wrt pressure, temperature, and comp fractions * @detail This function performs three conversions * 1) Conversion of phase mass fractions into phase mole fractions * 2) Conversion of phase component mass fractions into phase component mole fractions @@ -296,7 +323,9 @@ class MultiFluidBase : public ConstitutiveBase PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac, arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const; + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseEnthalpy, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseInternalEnergy ) const; /** * @brief Utility function to convert mole fractions to mass fractions @@ -335,6 +364,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; @@ -378,6 +409,8 @@ class MultiFluidBase : public ConstitutiveBase * @param[inout] phaseCompFrac the phase component fractions in the cell * @param[inout] dPhaseDens the derivatives of phase densities wrt pressure, temperature, and comp fractions * @param[inout] dPhaseVisc the derivatives of phase viscosities wrt pressure, temperature, and comp fractions + * @param[inout] dPhaseEnthalpy the derivatives of phase enthalpy wrt pressure, temperature, and comp fractions + * @param[inout] dPhaseInternalEnergy the derivatives of phase internal energy wrt pressure, temperature, and comp fractions */ template< integer maxNumComp > GEOSX_HOST_DEVICE @@ -385,7 +418,9 @@ class MultiFluidBase : public ConstitutiveBase PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac, arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const; + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseEnthalpy, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseInternalEnergy ) const; /** @@ -397,6 +432,8 @@ class MultiFluidBase : public ConstitutiveBase * @param[out] phaseDensity phase mass/molar density in the cell * @param[out] phaseMassDensity phase mass density in the cell * @param[out] phaseViscosity phase viscosity in the cell + * @param[out] phaseEnthalpy phase enthalpy in the cell + * @param[out] phaseInternalEnergy phase internal energy in the cell * @param[out] phaseCompFraction phase component fraction in the cell * @param[out] totalDensity total mass/molar density in the cell */ @@ -408,6 +445,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; @@ -420,6 +459,8 @@ class MultiFluidBase : public ConstitutiveBase * @param[out] phaseDensity phase mass/molar density in the cell (+ derivatives) * @param[out] phaseMassDensity phase mass density in the cell (+ derivatives) * @param[out] phaseViscosity phase viscosity in the cell (+ derivatives) + * @param[out] phaseEnthalpy phase enthalpy in the cell (+ derivatives) + * @param[out] phaseInternalEnergy phase internal energy in the cell (+ derivatives) * @param[out] phaseCompFraction phase component fraction in the cell (+ derivatives) * @param[out] totalDensity total mass/molar density in the cell (+ derivatives) */ @@ -431,6 +472,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; @@ -483,6 +526,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; @@ -563,16 +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, 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] ); + dPhaseDens[0][0], + dPhaseVisc[0][0], + dPhaseEnthalpy[0][0], + dPhaseInternalEnergy[0][0] ); } template< integer maxNumComp, integer maxNumPhase > @@ -585,7 +634,9 @@ MultiFluidBase::KernelWrapper:: PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac, arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseEnthalpy, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseInternalEnergy ) const { convertToPhaseMassFractions( phaseMolecularWeight, dPhaseMolecularWeight, @@ -598,7 +649,9 @@ MultiFluidBase::KernelWrapper:: phaseFrac, phaseCompFrac, dPhaseDens, - dPhaseVisc ); + dPhaseVisc, + dPhaseEnthalpy, + dPhaseInternalEnergy ); } template< integer maxNumDof, integer maxNumPhase > @@ -709,7 +762,9 @@ MultiFluidBase::KernelWrapper:: PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac, arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseEnthalpy, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseInternalEnergy ) const { using Deriv = multifluid::DerivativeOffset; @@ -722,6 +777,9 @@ MultiFluidBase::KernelWrapper:: applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, phaseFrac.derivs[ip], work, Deriv::dC ); applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, dPhaseDens[ip], work, Deriv::dC ); applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, dPhaseVisc[ip], work, Deriv::dC ); + applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, dPhaseEnthalpy[ip], work, Deriv::dC ); + applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, dPhaseInternalEnergy[ip], work, Deriv::dC ); + for( integer ic = 0; ic < numComp; ++ic ) { applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, phaseCompFrac.derivs[ip][ic], work, Deriv::dC ); diff --git a/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp b/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp index f032ac20e8b..a8540501b5a 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp @@ -102,6 +102,38 @@ EXTRINSIC_MESH_DATA_TRAIT( dPhaseViscosity, NO_WRITE, "Derivative of phase viscosity with respect to pressure, temperature, and global component fractions" ); +EXTRINSIC_MESH_DATA_TRAIT( phaseEnthalpy, + "phaseEnthalpy", + array3dLayoutPhase, + 0, + NOPLOT, // default behavior overridden by thermal models + NO_WRITE, + "Phase enthalpy" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseEnthalpy, + "dPhaseEnthalpy", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase enthalpy with respect to pressure, temperature, and global component fractions" ); + +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, + "dPhaseInternalEnergy", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase internal energy with respect to pressure, temperature, and 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 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_ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/NoOpPVTFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/NoOpPVTFunction.hpp new file mode 100644 index 00000000000..b6bbc6e60e7 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/NoOpPVTFunction.hpp @@ -0,0 +1,122 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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 > + GEOSX_HOST_DEVICE + void compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, + real64 & value, + arraySlice1d< real64, USD3 > const & dValue, + bool useMass ) const + { + GEOSX_UNUSED_VAR( pressure, temperature, + phaseComposition, dPhaseComposition, + value, dValue, + 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/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/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 1f6cf80de00..794069a7256 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp @@ -1137,6 +1137,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; @@ -1166,6 +1168,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; @@ -1209,6 +1213,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; @@ -1266,6 +1272,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; @@ -1281,6 +1289,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 8f0d462d9a8..cb73e6c3f6c 100644 --- a/src/coreComponents/schema/docs/BlackOilFluid_other.rst +++ b/src/coreComponents/schema/docs/BlackOilFluid_other.rst @@ -6,7 +6,9 @@ Name Type PVTO geosx_constitutive_PVTOData (no description available) dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseEnthalpy real64_array4d Derivative of phase enthalpy with respect to pressure, temperature, and global component fractions dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseInternalEnergy real64_array4d Derivative of phase internal energy with respect to pressure, temperature, and global component fraction dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions @@ -15,7 +17,9 @@ hydrocarbonPhaseOrder integer_array 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) diff --git a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst index a7575d6b734..0a1cedf60d4 100644 --- a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst @@ -5,14 +5,18 @@ Name Type ======================= ============================================================================================== ============================================================================================================ dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseEnthalpy real64_array4d Derivative of phase enthalpy with respect to pressure, temperature, and global component fractions dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseInternalEnergy real64_array4d Derivative of phase internal energy with respect to pressure, temperature, and global component fraction dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions 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 totalDensity real64_array2d Total density 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..0a1cedf60d4 --- /dev/null +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiThermalFluid_other.rst @@ -0,0 +1,26 @@ + + +======================= ============================================================================================== ============================================================================================================ +Name Type Description +======================= ============================================================================================== ============================================================================================================ +dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions +dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseEnthalpy real64_array4d Derivative of phase enthalpy with respect to pressure, temperature, and global component fractions +dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseInternalEnergy real64_array4d Derivative of phase internal energy with respect to pressure, temperature, and global component fraction +dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions +dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions +dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions +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 +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 a7575d6b734..0a1cedf60d4 100644 --- a/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst @@ -5,14 +5,18 @@ Name Type ======================= ============================================================================================== ============================================================================================================ dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseEnthalpy real64_array4d Derivative of phase enthalpy with respect to pressure, temperature, and global component fractions dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseInternalEnergy real64_array4d Derivative of phase internal energy with respect to pressure, temperature, and global component fraction dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions 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 totalDensity real64_array2d Total density 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..0a1cedf60d4 --- /dev/null +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsThermalFluid_other.rst @@ -0,0 +1,26 @@ + + +======================= ============================================================================================== ============================================================================================================ +Name Type Description +======================= ============================================================================================== ============================================================================================================ +dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions +dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseEnthalpy real64_array4d Derivative of phase enthalpy with respect to pressure, temperature, and global component fractions +dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseInternalEnergy real64_array4d Derivative of phase internal energy with respect to pressure, temperature, and global component fraction +dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions +dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions +dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions +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 +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 a7575d6b734..0a1cedf60d4 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst @@ -5,14 +5,18 @@ Name Type ======================= ============================================================================================== ============================================================================================================ dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseEnthalpy real64_array4d Derivative of phase enthalpy with respect to pressure, temperature, and global component fractions dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseInternalEnergy real64_array4d Derivative of phase internal energy with respect to pressure, temperature, and global component fraction dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions 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 totalDensity real64_array2d Total density diff --git a/src/coreComponents/schema/docs/Constitutive.rst b/src/coreComponents/schema/docs/Constitutive.rst index 2772db21f11..6fa3cfd19db 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 e5e05f4c231..2ca2f51060a 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 9b385f6c702..2999169495d 100644 --- a/src/coreComponents/schema/docs/DeadOilFluid_other.rst +++ b/src/coreComponents/schema/docs/DeadOilFluid_other.rst @@ -5,7 +5,9 @@ Name Type =============================== ========================================================================================================= ============================================================================================================ dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseEnthalpy real64_array4d Derivative of phase enthalpy with respect to pressure, temperature, and global component fractions dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseInternalEnergy real64_array4d Derivative of phase internal energy with respect to pressure, temperature, and global component fraction dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions @@ -14,7 +16,9 @@ hydrocarbonPhaseOrder integer_array 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) diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index d3751324fee..25a9e70e87c 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1850,7 +1850,9 @@ Equal to 1 for surface conditions, and to 0 for reservoir conditions--> + + @@ -1996,6 +1998,20 @@ The expected format is "{ waterMax, oilMax }", in that order--> + + + + + + + + + + + + + + @@ -2010,6 +2026,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 b9298e1a436..c0985dee8fb 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -827,7 +827,9 @@ + + @@ -896,8 +898,12 @@ + + + + @@ -914,8 +920,12 @@ + + + + @@ -972,8 +982,12 @@ + + + + @@ -986,8 +1000,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1002,8 +1058,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1016,8 +1114,12 @@ + + + + @@ -1040,8 +1142,12 @@ + + + + @@ -1054,8 +1160,12 @@ + + + + @@ -1150,8 +1260,12 @@ + + + + @@ -1168,8 +1282,12 @@ + + + + diff --git a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp index 57ef5ee9319..43f6697a8e0 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp @@ -321,6 +321,10 @@ void testValuesAgainstPreviousImplementation( CO2BrinePhillipsFluid::KernelWrapp StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseMassDensity( 1, 1, numPhase, numDof ); StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseViscosity( 1, 1, numPhase ); StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseViscosity( 1, 1, numPhase, numDof ); + StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseEnthalpy( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseEnthalpy( 1, 1, numPhase, numDof ); + StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseInternalEnergy( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseInternalEnergy( 1, 1, numPhase, numDof ); StackArray< real64, 4, numComp *numPhase, LAYOUT_PHASE_COMP > phaseCompFraction( 1, 1, numPhase, numComp ); StackArray< real64, 5, numDof *numComp *numPhase, LAYOUT_PHASE_COMP_DC > dPhaseCompFraction( 1, 1, numPhase, numComp, numDof ); StackArray< real64, 2, 1, LAYOUT_FLUID > totalDensity( 1, 1 ); @@ -343,6 +347,14 @@ void testValuesAgainstPreviousImplementation( CO2BrinePhillipsFluid::KernelWrapp phaseViscosity[0][0], dPhaseViscosity[0][0] }, + { + phaseEnthalpy[0][0], + dPhaseEnthalpy[0][0] + }, + { + phaseInternalEnergy[0][0], + dPhaseInternalEnergy[0][0] + }, { phaseCompFraction[0][0], dPhaseCompFraction[0][0] diff --git a/src/docs/sphinx/CompleteXMLSchema.rst b/src/docs/sphinx/CompleteXMLSchema.rst index 7de8a5c2409..03a6fe10490 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 @@ -1083,6 +1097,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 @@ -1090,6 +1111,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