Skip to content

Commit be12179

Browse files
Improved phase internal energy computation (#1846)
* refactored computation of internal energy * small bugfix
1 parent 223e3d9 commit be12179

38 files changed

Lines changed: 473 additions & 1009 deletions

src/coreComponents/constitutive/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ set( constitutive_headers
4545
fluid/PVTFunctions/SpanWagnerCO2Density.hpp
4646
fluid/PVTFunctions/BrineEnthalpy.hpp
4747
fluid/PVTFunctions/CO2Enthalpy.hpp
48-
fluid/PVTFunctions/BrineInternalEnergy.hpp
49-
fluid/PVTFunctions/CO2InternalEnergy.hpp
5048
fluid/PVTFunctions/CO2EOSSolver.hpp
5149
fluid/PVTFunctions/PureWaterProperties.hpp
5250
fluid/ParticleFluid.hpp
@@ -150,8 +148,6 @@ set( constitutive_sources
150148
fluid/PVTFunctions/PVTFunctionHelpers.cpp
151149
fluid/PVTFunctions/BrineEnthalpy.cpp
152150
fluid/PVTFunctions/CO2Enthalpy.cpp
153-
fluid/PVTFunctions/BrineInternalEnergy.cpp
154-
fluid/PVTFunctions/CO2InternalEnergy.cpp
155151
fluid/PVTFunctions/CO2EOSSolver.cpp
156152
fluid/PVTFunctions/PureWaterProperties.cpp
157153
fluid/ParticleFluid.cpp

src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,33 @@ template< typename PHASE1, typename PHASE2, typename FLASH > class
3636
TwoPhaseCatalogNames {};
3737

3838
template<> class
39-
TwoPhaseCatalogNames< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >,
40-
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >,
39+
TwoPhaseCatalogNames< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction >,
40+
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction >,
4141
PVTProps::CO2Solubility >
4242
{
4343
public:
4444
static string name() { return "CO2BrinePhillipsFluid"; }
4545
};
4646
template<> class
47-
TwoPhaseCatalogNames< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >,
48-
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >,
47+
TwoPhaseCatalogNames< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy >,
48+
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy >,
4949
PVTProps::CO2Solubility >
5050
{
5151
public:
5252
static string name() { return "CO2BrinePhillipsThermalFluid"; }
5353
};
5454

5555
template<> class
56-
TwoPhaseCatalogNames< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >,
57-
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >,
56+
TwoPhaseCatalogNames< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction >,
57+
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction >,
5858
PVTProps::CO2Solubility >
5959
{
6060
public:
6161
static string name() { return "CO2BrineEzrokhiFluid"; }
6262
};
6363
template<> class
64-
TwoPhaseCatalogNames< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >,
65-
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >,
64+
TwoPhaseCatalogNames< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy >,
65+
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy >,
6666
PVTProps::CO2Solubility >
6767
{
6868
public:
@@ -109,10 +109,8 @@ CO2BrineFluid( string const & name, Group * const parent ):
109109
template< typename PHASE1, typename PHASE2, typename FLASH >
110110
bool CO2BrineFluid< PHASE1, PHASE2, FLASH >::isThermal() const
111111
{
112-
return ( PHASE1::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() &&
113-
PHASE1::InternalEnergy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() &&
114-
PHASE2::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() &&
115-
PHASE2::InternalEnergy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() );
112+
return ( PHASE1::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() &&
113+
PHASE2::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() );
116114
}
117115

118116

@@ -174,11 +172,11 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels()
174172
// TODO: get rid of these external files and move into XML, this is too error prone
175173
// 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
176174
array1d< array1d< string > > phase1InputParams;
177-
phase1InputParams.resize( 4 );
175+
phase1InputParams.resize( 3 );
178176
array1d< array1d< string > > phase2InputParams;
179-
phase2InputParams.resize( 4 );
177+
phase2InputParams.resize( 3 );
180178

181-
// 1) Create the viscosity, density, enthalpy, and internal energy models
179+
// 1) Create the viscosity, density, enthalpy models
182180
for( string const & filename : m_phasePVTParaFiles )
183181
{
184182
std::ifstream is( filename );
@@ -220,17 +218,6 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels()
220218
phase2InputParams[PHASE2::InputParamOrder::ENTHALPY] = strs;
221219
}
222220
}
223-
else if( strs[0] == toString( SubModelInputNames::INTERNALENERGY ) )
224-
{
225-
if( strs[1] == PHASE1::InternalEnergy::catalogName() )
226-
{
227-
phase1InputParams[PHASE1::InputParamOrder::INTERNALENERGY] = strs;
228-
}
229-
else if( strs[1] == PHASE2::InternalEnergy::catalogName() )
230-
{
231-
phase2InputParams[PHASE2::InputParamOrder::INTERNALENERGY] = strs;
232-
}
233-
}
234221
else
235222
{
236223
GEOSX_THROW( GEOSX_FMT( "{}: invalid PVT function type '{}'", getFullName(), strs[0] ), InputError );
@@ -253,15 +240,7 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels()
253240
GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE2::Viscosity::catalogName() ),
254241
InputError );
255242

256-
// we also detect any inconsistency arising in the enthalpy/internal energy models
257-
GEOSX_THROW_IF( phase1InputParams[PHASE1::InputParamOrder::INTERNALENERGY].empty() &&
258-
( PHASE1::InternalEnergy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ),
259-
GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE1::InternalEnergy::catalogName() ),
260-
InputError );
261-
GEOSX_THROW_IF( phase2InputParams[PHASE2::InputParamOrder::INTERNALENERGY].empty() &&
262-
( PHASE2::InternalEnergy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ),
263-
GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE2::InternalEnergy::catalogName() ),
264-
InputError );
243+
// we also detect any inconsistency arising in the enthalpy models
265244
GEOSX_THROW_IF( phase1InputParams[PHASE1::InputParamOrder::ENTHALPY].empty() &&
266245
( PHASE1::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ),
267246
GEOSX_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE1::Enthalpy::catalogName() ),
@@ -317,6 +296,7 @@ CO2BrineFluid< PHASE1, PHASE2, FLASH >::createKernelWrapper()
317296
*m_flash,
318297
m_componentMolarWeight.toViewConst(),
319298
m_useMass,
299+
isThermal(),
320300
m_phaseFraction.toView(),
321301
m_phaseDensity.toView(),
322302
m_phaseMassDensity.toView(),
@@ -336,6 +316,7 @@ CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper::
336316
FLASH const & flash,
337317
arrayView1d< geosx::real64 const > componentMolarWeight,
338318
bool const useMass,
319+
bool const isThermal,
339320
PhaseProp::ViewType phaseFraction,
340321
PhaseProp::ViewType phaseDensity,
341322
PhaseProp::ViewType phaseMassDensity,
@@ -356,24 +337,25 @@ CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper::
356337
std::move( totalDensity ) ),
357338
m_p1Index( p1Index ),
358339
m_p2Index( p2Index ),
340+
m_isThermal( isThermal ),
359341
m_phase1( phase1.createKernelWrapper() ),
360342
m_phase2( phase2.createKernelWrapper() ),
361343
m_flash( flash.createKernelWrapper() )
362344
{}
363345

364346
// explicit instantiation of the model template; unfortunately we can't use the aliases for this
365-
template class CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >,
366-
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >,
347+
template class CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::NoOpPVTFunction >,
348+
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction >,
367349
PVTProps::CO2Solubility >;
368-
template class CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >,
369-
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >,
350+
template class CO2BrineFluid< PhaseModel< PVTProps::PhillipsBrineDensity, PVTProps::PhillipsBrineViscosity, PVTProps::BrineEnthalpy >,
351+
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy >,
370352
PVTProps::CO2Solubility >;
371353

372-
template class CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >,
373-
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction, PVTProps::NoOpPVTFunction >,
354+
template class CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::NoOpPVTFunction >,
355+
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::NoOpPVTFunction >,
374356
PVTProps::CO2Solubility >;
375-
template class CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy, PVTProps::BrineInternalEnergy >,
376-
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy, PVTProps::CO2InternalEnergy >,
357+
template class CO2BrineFluid< PhaseModel< PVTProps::EzrokhiBrineDensity, PVTProps::EzrokhiBrineViscosity, PVTProps::BrineEnthalpy >,
358+
PhaseModel< PVTProps::SpanWagnerCO2Density, PVTProps::FenghourCO2Viscosity, PVTProps::CO2Enthalpy >,
377359
PVTProps::CO2Solubility >;
378360

379361
REGISTER_CATALOG_ENTRY( ConstitutiveBase, CO2BrinePhillipsFluid, string const &, Group * const )

0 commit comments

Comments
 (0)