From 4f5b0faddc71f17ac015c453bed8846d063642ff Mon Sep 17 00:00:00 2001 From: dkachuma Date: Tue, 14 Apr 2026 15:17:31 -0500 Subject: [PATCH 01/11] Add temperature dependency of viscosity --- .../thermalSinglePhaseFlow.ats | 7 + .../singlePhaseFlow/thermalViscosity_1d.xml | 183 ++++++++++++++++++ .../docs/CompressibleSinglePhaseFluid.rst | 56 +++++- .../ThermalCompressibleSinglePhaseFluid.cpp | 11 +- .../ThermalCompressibleSinglePhaseFluid.hpp | 12 +- src/coreComponents/schema/schema.xsd | 4 + 6 files changed, 258 insertions(+), 15 deletions(-) create mode 100644 inputFiles/singlePhaseFlow/thermalViscosity_1d.xml diff --git a/inputFiles/singlePhaseFlow/thermalSinglePhaseFlow.ats b/inputFiles/singlePhaseFlow/thermalSinglePhaseFlow.ats index b47f93c6527..7701f94051a 100644 --- a/inputFiles/singlePhaseFlow/thermalSinglePhaseFlow.ats +++ b/inputFiles/singlePhaseFlow/thermalSinglePhaseFlow.ats @@ -45,6 +45,13 @@ decks = [ restart_step=0, check_step=1, restartcheck_params=RestartcheckParameters(**restartcheck_params)), + TestDeck( + name="thermalViscosity_1d", + description='Thermal problem with temperature dependent viscosity', + partitions=((1, 1, 1)), + restart_step=1, + check_step=1, + restartcheck_params=RestartcheckParameters(**restartcheck_params)), ] generate_geos_tests(decks) diff --git a/inputFiles/singlePhaseFlow/thermalViscosity_1d.xml b/inputFiles/singlePhaseFlow/thermalViscosity_1d.xml new file mode 100644 index 00000000000..f917f080855 --- /dev/null +++ b/inputFiles/singlePhaseFlow/thermalViscosity_1d.xml @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/coreComponents/constitutive/docs/CompressibleSinglePhaseFluid.rst b/src/coreComponents/constitutive/docs/CompressibleSinglePhaseFluid.rst index 1781ed99222..3066ffe9e42 100644 --- a/src/coreComponents/constitutive/docs/CompressibleSinglePhaseFluid.rst +++ b/src/coreComponents/constitutive/docs/CompressibleSinglePhaseFluid.rst @@ -9,31 +9,46 @@ Overview This model represents a compressible single-phase fluid with constant compressibility and pressure-dependent viscosity. +For thermal simulations, the model density and viscosity have a temperature dependency +expressed as a constant thermal expansion coefficient. These assumptions are valid for slightly compressible fluids, such as water, and some types of oil with negligible amounts of dissolved gas. Specifically, fluid density is computed as .. math:: - \rho(p) = \rho_0 ( e^{c_\rho(p - p_0)} + e^{\beta_f (T - T_0)} ) + \rho(p) = \rho_0 e^{c_\rho(p - p_0)} -where :math:`c_\rho` is compressibility, :math:`p_0` is reference pressure, :math:`\rho_0` is -density at reference pressure, :math:`\beta_f` is the fluid thermal expansion coefficient, :math:`T_0` is reference temperature. +for isothermal cases and, + +.. math:: + \rho(p,T) = \rho_0 e^{c_\rho(p - p_0)} e^{-\beta_\rho (T - T_0)} + +for thermal cases. + +where :math:`c_\rho` is compressibility, :math:`p_0` is reference pressure, :math:`\rho_0` is the +density at the reference pressure, :math:`\beta_\rho` is the fluid thermal expansion coefficient, +:math:`T_0` is reference temperature. Similarly, .. math:: \mu(p) = \mu_0 e^{c_\mu(p - p_0)} -where :math:`c_\mu` is viscosibility (viscosity compressibility), :math:`\mu_0` is reference viscosity. +for isothermal cases and, -Either exponent may be approximated by linear (default) or quadratic terms of Taylor series expansion. -Currently there is no temperature dependence in the model, although it may be added in future. +.. math:: + \mu(p,T) = \mu_0 e^{c_\mu(p - p_0)} e^{-\beta_\mu (T - T_0)} + +for thermal cases. + +where :math:`c_\mu` is viscosibility (viscosity compressibility), :math:`\mu_0` is reference viscosity, +:math:`\beta_\rho` is the fluid viscosity thermal coefficient. Parameters ========================= -The model is represented by ```` node in the input. +For the isothermal case, the model is represented by ```` node in the input. The following attributes are supported: @@ -51,4 +66,29 @@ Example compressibility="1e-19" referenceViscosity="0.001" viscosibility="0.0"/> - \ No newline at end of file + + +For the thermal case, the model is represented by ```` node in the input. + +The following attributes are supported: + +.. include:: /docs/sphinx/datastructure/ThermalCompressibleSinglePhaseFluid.rst + +Example +========================= + +.. code-block:: xml + + + + diff --git a/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp b/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp index e52ab6a878e..ad636495d5c 100644 --- a/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp +++ b/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp @@ -32,12 +32,18 @@ namespace constitutive ThermalCompressibleSinglePhaseFluid::ThermalCompressibleSinglePhaseFluid( string const & name, Group * const parent ): CompressibleSinglePhaseFluid( name, parent ) { - m_numDOF=2; + m_numDOF = 2; + registerWrapper( viewKeyStruct::thermalExpansionCoeffString(), &m_thermalExpansionCoeff ). setApplyDefaultValue( 0.0 ). setInputFlag( InputFlags::OPTIONAL ). setDescription( "Fluid thermal expansion coefficient. Unit: 1/K" ); + registerWrapper( viewKeyStruct::viscosityExpansivityString(), &m_viscosityExpansivity ). + setApplyDefaultValue( 0.0 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Fluid viscosity thermal expansion coefficient at the reference temperature. Unit: 1/K" ); + registerWrapper( viewKeyStruct::specificHeatCapacityString(), &m_specificHeatCapacity ). setApplyDefaultValue( 0.0 ). setInputFlag( InputFlags::OPTIONAL ). @@ -80,6 +86,7 @@ void ThermalCompressibleSinglePhaseFluid::postInputInitialization() }; checkNonnegative( m_thermalExpansionCoeff, viewKeyStruct::thermalExpansionCoeffString() ); + checkNonnegative( m_viscosityExpansivity, viewKeyStruct::viscosityExpansivityString() ); checkNonnegative( m_specificHeatCapacity, viewKeyStruct::specificHeatCapacityString() ); checkNonnegative( m_referenceInternalEnergy, viewKeyStruct::referenceInternalEnergyString() ); @@ -98,7 +105,7 @@ ThermalCompressibleSinglePhaseFluid::KernelWrapper ThermalCompressibleSinglePhaseFluid::createKernelWrapper() { return KernelWrapper( KernelWrapper::DensRelationType( m_referencePressure, m_referenceTemperature, m_referenceDensity, m_compressibility, -m_thermalExpansionCoeff ), - KernelWrapper::ViscRelationType( m_referencePressure, m_referenceViscosity, m_viscosibility ), + KernelWrapper::ViscRelationType( m_referencePressure, m_referenceTemperature, m_referenceViscosity, m_viscosibility, -m_viscosityExpansivity ), KernelWrapper::IntEnergyRelationType( m_referenceTemperature, m_referenceInternalEnergy, m_specificHeatCapacity/m_referenceInternalEnergy ), m_density.value, m_density.derivs, diff --git a/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.hpp b/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.hpp index 2f110c295ef..2232906a79b 100644 --- a/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.hpp +++ b/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.hpp @@ -43,7 +43,7 @@ class ThermalCompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate public: using DensRelationType = ExponentialRelation< real64, DENS_EAT, 3 >; - using ViscRelationType = ExponentialRelation< real64, VISC_EAT >; + using ViscRelationType = ExponentialRelation< real64, VISC_EAT, 3 >; using IntEnergyRelationType = ExponentialRelation< real64, INTENERGY_EAT >; using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >; @@ -114,11 +114,10 @@ class ThermalCompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate real64 & dEnthalpy_dPressure, real64 & dEnthalpy_dTemperature ) const override { - m_viscRelation.compute( pressure, viscosity, dViscosity_dPressure ); - dViscosity_dTemperature = 0.0; - m_densRelation.compute( pressure, temperature, density, dDensity_dPressure, dDensity_dTemperature ); + m_viscRelation.compute( pressure, temperature, viscosity, dViscosity_dPressure, dViscosity_dTemperature ); + /// Compute the internal energy (only sensitive to temperature) m_intEnergyRelation.compute( temperature, internalEnergy, dInternalEnergy_dTemperature ); dInternalEnergy_dPressure = 0.0; @@ -126,7 +125,6 @@ class ThermalCompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate enthalpy = internalEnergy - m_refIntEnergy; dEnthalpy_dPressure = 0.0; dEnthalpy_dTemperature = dInternalEnergy_dTemperature; - } GEOS_HOST_DEVICE @@ -240,6 +238,7 @@ class ThermalCompressibleSinglePhaseFluid : public CompressibleSinglePhaseFluid struct viewKeyStruct : public CompressibleSinglePhaseFluid::viewKeyStruct { static constexpr char const * thermalExpansionCoeffString() { return "thermalExpansionCoeff"; } + static constexpr char const * viscosityExpansivityString() { return "viscosityExpansivity"; } static constexpr char const * specificHeatCapacityString() { return "specificHeatCapacity"; } static constexpr char const * referenceTemperatureString() { return "referenceTemperature"; } static constexpr char const * referenceInternalEnergyString() { return "referenceInternalEnergy"; } @@ -255,6 +254,9 @@ class ThermalCompressibleSinglePhaseFluid : public CompressibleSinglePhaseFluid /// scalar fluid thermal expansion coefficient real64 m_thermalExpansionCoeff; + /// scalar fluid viscosity thermal expansion coefficient + real64 m_viscosityExpansivity; + /// scalar fluid volumetric heat capacity coefficient real64 m_specificHeatCapacity; diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 9a9bb51d843..cdd5ebef73e 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -8616,6 +8616,8 @@ If you want to do a three-phase simulation, please use instead wettingIntermedia + + + + diff --git a/src/coreComponents/constitutive/docs/CompressibleSinglePhaseFluid.rst b/src/coreComponents/constitutive/docs/CompressibleSinglePhaseFluid.rst index e5ee65781e6..2b8b4e3d0fd 100644 --- a/src/coreComponents/constitutive/docs/CompressibleSinglePhaseFluid.rst +++ b/src/coreComponents/constitutive/docs/CompressibleSinglePhaseFluid.rst @@ -9,7 +9,8 @@ Overview This model represents a compressible single-phase fluid with constant compressibility and pressure-dependent viscosity. -For thermal simulations, fluid density and viscosity are temperature-dependent, governed by a constant thermal expansion coefficient. +For thermal simulations, fluid density and viscosity are temperature-dependent, governed by a constant thermal +expansion coefficient and a constant temperature-viscosity coefficient, respectively. These assumptions are valid for slightly compressible fluids, such as water, and some types of oil with negligible amounts of dissolved gas. diff --git a/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp b/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp index ad636495d5c..d8a6e2c16d4 100644 --- a/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp +++ b/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp @@ -39,7 +39,7 @@ ThermalCompressibleSinglePhaseFluid::ThermalCompressibleSinglePhaseFluid( string setInputFlag( InputFlags::OPTIONAL ). setDescription( "Fluid thermal expansion coefficient. Unit: 1/K" ); - registerWrapper( viewKeyStruct::viscosityExpansivityString(), &m_viscosityExpansivity ). + registerWrapper( viewKeyStruct::temperatureViscosityCoefficient(), &m_temperatureViscosityCoefficient ). setApplyDefaultValue( 0.0 ). setInputFlag( InputFlags::OPTIONAL ). setDescription( "Fluid viscosity thermal expansion coefficient at the reference temperature. Unit: 1/K" ); @@ -86,7 +86,7 @@ void ThermalCompressibleSinglePhaseFluid::postInputInitialization() }; checkNonnegative( m_thermalExpansionCoeff, viewKeyStruct::thermalExpansionCoeffString() ); - checkNonnegative( m_viscosityExpansivity, viewKeyStruct::viscosityExpansivityString() ); + checkNonnegative( m_temperatureViscosityCoefficient, viewKeyStruct::temperatureViscosityCoefficient() ); checkNonnegative( m_specificHeatCapacity, viewKeyStruct::specificHeatCapacityString() ); checkNonnegative( m_referenceInternalEnergy, viewKeyStruct::referenceInternalEnergyString() ); @@ -105,7 +105,7 @@ ThermalCompressibleSinglePhaseFluid::KernelWrapper ThermalCompressibleSinglePhaseFluid::createKernelWrapper() { return KernelWrapper( KernelWrapper::DensRelationType( m_referencePressure, m_referenceTemperature, m_referenceDensity, m_compressibility, -m_thermalExpansionCoeff ), - KernelWrapper::ViscRelationType( m_referencePressure, m_referenceTemperature, m_referenceViscosity, m_viscosibility, -m_viscosityExpansivity ), + KernelWrapper::ViscRelationType( m_referencePressure, m_referenceTemperature, m_referenceViscosity, m_viscosibility, -m_temperatureViscosityCoefficient ), KernelWrapper::IntEnergyRelationType( m_referenceTemperature, m_referenceInternalEnergy, m_specificHeatCapacity/m_referenceInternalEnergy ), m_density.value, m_density.derivs, diff --git a/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.hpp b/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.hpp index 587c756f1e3..83958834e33 100644 --- a/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.hpp +++ b/src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.hpp @@ -238,7 +238,7 @@ class ThermalCompressibleSinglePhaseFluid : public CompressibleSinglePhaseFluid struct viewKeyStruct : public CompressibleSinglePhaseFluid::viewKeyStruct { static constexpr char const * thermalExpansionCoeffString() { return "thermalExpansionCoeff"; } - static constexpr char const * viscosityExpansivityString() { return "viscosityExpansivity"; } + static constexpr char const * temperatureViscosityCoefficient() { return "temperatureViscosityCoefficient"; } static constexpr char const * specificHeatCapacityString() { return "specificHeatCapacity"; } static constexpr char const * referenceTemperatureString() { return "referenceTemperature"; } static constexpr char const * referenceInternalEnergyString() { return "referenceInternalEnergy"; } diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index cdd5ebef73e..4805f560fa5 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -8612,12 +8612,12 @@ If you want to do a three-phase simulation, please use instead wettingIntermedia + + - - + + - -