Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link compositional fluid model to static function implementation #2879

Merged
merged 57 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
83740fc
Use multifluid derivative layout
dkachuma Dec 5, 2023
9a7dad0
Add cubic eos fugacity derivative
dkachuma Dec 6, 2023
adc71ba
Add Rachford-Rice derivatives
dkachuma Dec 7, 2023
b66c8eb
Switch from arrayView to arraySlice
dkachuma Dec 8, 2023
126e108
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Dec 8, 2023
c6d99c6
Flash numerical derivative test
dkachuma Dec 8, 2023
79166a1
Some tweaks to derivatives
dkachuma Dec 12, 2023
c8358b6
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Dec 12, 2023
3a81b0d
Pressure and temperature derivatives
dkachuma Dec 13, 2023
b36f98a
Use mole fractions only
dkachuma Dec 19, 2023
ce430bf
Change component properties
dkachuma Dec 19, 2023
6ebb9f4
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Dec 19, 2023
e46f08f
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Jan 4, 2024
b3ff83e
Tidy up derivatives
dkachuma Jan 4, 2024
5863989
Remove debug text
dkachuma Jan 4, 2024
d8a619a
Remove Rachford rice derivatives
dkachuma Jan 4, 2024
d82904a
Remove unnecessary using
dkachuma Jan 4, 2024
95471e5
Fix compositional properties test
dkachuma Jan 4, 2024
86deff0
Fugacity derivatives
dkachuma Jan 5, 2024
a57eb51
Link negative two phase flash
dkachuma Jan 5, 2024
8f74cfd
Validate binary interaction coefficients. Fix type in catalog name
dkachuma Jan 5, 2024
d8e800b
Fix cubic EOS binary interaction coefficients
dkachuma Jan 8, 2024
0bb27f1
Add density calculation
dkachuma Jan 9, 2024
aa28879
Add mass density output to PVTDriver
dkachuma Jan 9, 2024
e413439
Translate composition derivatives
dkachuma Jan 9, 2024
d6114c2
Fix sign on volume shift parameters
dkachuma Jan 9, 2024
32abea0
PVTDriver documentation
dkachuma Jan 9, 2024
5d880db
Add compositional density unit test
dkachuma Jan 17, 2024
35c0742
Implement LBC viscosity
dkachuma Jan 17, 2024
1046379
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Jan 17, 2024
f2bd75e
Test LBC viscosity
dkachuma Jan 18, 2024
40a6f15
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Jan 18, 2024
b7650dc
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Jan 18, 2024
7197a85
Use phase composition derivativestimne
dkachuma Jan 18, 2024
ad886dc
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Jan 24, 2024
ec8c27c
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Jan 24, 2024
0ee9d04
Add heuristic for flash phase switch
dkachuma Feb 6, 2024
79b6c87
Fix unit test
dkachuma Feb 6, 2024
f35f992
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Feb 6, 2024
a20746a
Update schema
dkachuma Feb 6, 2024
e31b45d
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Feb 7, 2024
2569d39
Fix CUDA compilation
dkachuma Mar 5, 2024
023ee89
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Mar 5, 2024
5019b5d
Fix LBC
dkachuma Apr 11, 2024
4c2cfdd
Allow PVT driver for PVT package
dkachuma Apr 11, 2024
220d46a
Merge remote-tracking branch 'origin/develop' into feature/dkachuma/e…
dkachuma Apr 11, 2024
223e7b7
Fix unit test compilation
dkachuma Apr 12, 2024
a33e7c1
Fix unit test
dkachuma Apr 12, 2024
ef104e3
Fix unit test
dkachuma Apr 12, 2024
19873a4
Fix clang build
dkachuma Apr 15, 2024
23ccc5a
Fix clang build
dkachuma Apr 15, 2024
1751e50
Fix clang build
dkachuma Apr 15, 2024
6817461
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma Apr 29, 2024
3302ab5
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma May 1, 2024
2596321
Merge branch 'develop' into feature/dkachuma/eos-flash-derivatives
dkachuma May 6, 2024
4a81a7b
Comment out new fluid temporarily
dkachuma May 6, 2024
fd53199
Disable unit test
dkachuma May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/coreComponents/constitutive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ set( constitutive_headers
fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.hpp
fluid/multifluid/CO2Brine/functions/WaterDensity.hpp
fluid/multifluid/compositional/functions/CompositionalProperties.hpp
fluid/multifluid/compositional/functions/CompositionalPropertiesImpl.hpp
fluid/multifluid/compositional/functions/CubicEOSPhaseModel.hpp
fluid/multifluid/compositional/functions/KValueInitialization.hpp
fluid/multifluid/compositional/functions/NegativeTwoPhaseFlash.hpp
Expand All @@ -70,6 +71,8 @@ set( constitutive_headers
fluid/multifluid/compositional/models/CompositionalDensity.hpp
fluid/multifluid/compositional/models/ConstantViscosity.hpp
fluid/multifluid/compositional/models/FunctionBase.hpp
fluid/multifluid/compositional/models/LohrenzBrayClarkViscosity.hpp
fluid/multifluid/compositional/models/LohrenzBrayClarkViscosityImpl.hpp
fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.hpp
fluid/multifluid/compositional/models/NullModel.hpp
fluid/multifluid/compositional/models/PhaseModel.hpp
Expand Down Expand Up @@ -214,13 +217,16 @@ set( constitutive_sources
fluid/multifluid/CO2Brine/functions/CO2EOSSolver.cpp
fluid/multifluid/CO2Brine/functions/PureWaterProperties.cpp
fluid/multifluid/CO2Brine/functions/WaterDensity.cpp
fluid/multifluid/compositional/functions/CompositionalProperties.cpp
fluid/multifluid/compositional/models/CompositionalDensity.cpp
fluid/multifluid/compositional/models/ConstantViscosity.cpp
fluid/multifluid/compositional/models/LohrenzBrayClarkViscosity.cpp
fluid/multifluid/compositional/models/NegativeTwoPhaseFlashModel.cpp
fluid/multifluid/compositional/CompositionalMultiphaseFluid.cpp
fluid/multifluid/compositional/CompositionalMultiphaseFluidUpdates.cpp
fluid/multifluid/compositional/PVTDriverRunTestCompositionalMultiphaseFluid.cpp
fluid/multifluid/compositional/PVTDriverRunTestCompositionalPR.cpp
fluid/multifluid/compositional/PVTDriverRunTestCompositionalPRLBC.cpp
fluid/multifluid/compositional/PVTDriverRunTestCompositionalSRK.cpp
fluid/multifluid/compositional/PVTDriverRunTestCompositionalSRKLBC.cpp
fluid/multifluid/reactive/ReactiveBrineFluid.cpp
fluid/multifluid/reactive/ReactiveMultiFluid.cpp
fluid/multifluid/reactive/ReactiveFluidDriver.cpp
Expand Down Expand Up @@ -253,10 +259,10 @@ set( constitutive_sources
relativePermeability/VanGenuchtenStone2RelativePermeability.cpp
relativePermeability/RelpermDriver.cpp
relativePermeability/RelpermDriverBrooksCoreyBakerRunTest.cpp
relativePermeability/RelpermDriverBrooksCoreyStone2RunTest.cpp
relativePermeability/RelpermDriverBrooksCoreyStone2RunTest.cpp
relativePermeability/RelpermDriverBrooksCoreyRunTest.cpp
relativePermeability/RelpermDriverVanGenuchtenBakerRunTest.cpp
relativePermeability/RelpermDriverVanGenuchtenStone2RunTest.cpp
relativePermeability/RelpermDriverVanGenuchtenStone2RunTest.cpp
relativePermeability/RelpermDriverTableRelativeRunTest.cpp
relativePermeability/RelpermDriverTableRelativeHysteresisRunTest.cpp
solid/CompressibleSolid.cpp
Expand Down Expand Up @@ -300,7 +306,8 @@ if( ENABLE_PVTPackage )

set( constitutive_sources
${constitutive_sources}
fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.cpp )
fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.cpp
fluid/multifluid/compositional/PVTDriverRunTestCompositionalMultiphaseFluid.cpp )

add_subdirectory( PVTPackage )

Expand Down
1 change: 1 addition & 0 deletions src/coreComponents/constitutive/docs/PVTDriver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ In this case, we have a two-phase, two-component mixture.
The total density is reported in column 4, while phase fractions, phase densities, and phase viscosities are reported in subsequent columns.
If the ``outputCompressibility`` flag is activated, an extra column will be added for the total fluid compressibility after the density.
This is defined as :math:`c_t=\frac{1}{\rho_t}\left(\partial{\rho_t}/\partial P\right)` where :math:`\rho_t` is the total density.
If the ``outputMassDensity`` flag is activated, extra columns will be added for the mass density of each phase.
The number of columns will also depend on whether the ``outputPhaseComposition`` flag is activated or not. If it is activated, there will be an extra column for the mole fraction of each component in each phase.
The phase order will match the one defined in the input XML (here, the co2-rich phase followed by the water-rich phase).
This file can be readily plotted using any number of plotting tools. Each row corresponds to one timestep of the driver, starting from initial conditions in the first row.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct MultiFluidConstants
/**
* @brief Max number of SSI iterations
*/
static constexpr integer maxSSIIterations = 200;
static constexpr integer maxSSIIterations = 1000;
dkachuma marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Max number of Newton iterations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void constitutiveUpdatePassThru( MultiFluidBase const & fluid,
BlackOilFluid,
CompositionalTwoPhasePengRobinsonConstantViscosity,
CompositionalTwoPhaseSoaveRedlichKwongConstantViscosity,
// CompositionalTwoPhasePengRobinsonLBCViscosity,
// CompositionalTwoPhaseSoaveRedlichKwongLBCViscosity,
#ifdef GEOSX_USE_PVTPackage
CompositionalMultiphaseFluidPVTPackage,
#endif
Expand All @@ -62,6 +64,8 @@ void constitutiveUpdatePassThru( MultiFluidBase & fluid,
BlackOilFluid,
CompositionalTwoPhasePengRobinsonConstantViscosity,
CompositionalTwoPhaseSoaveRedlichKwongConstantViscosity,
// CompositionalTwoPhasePengRobinsonLBCViscosity,
// CompositionalTwoPhaseSoaveRedlichKwongLBCViscosity,
#ifdef GEOSX_USE_PVTPackage
CompositionalMultiphaseFluidPVTPackage,
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ struct MultiFluidVarSlice

internal::ArraySliceOrRef< T, DIM, USD > value; /// variable value
internal::ArraySliceOrRef< T, DIM + 1, USD_DC > derivs; /// derivative w.r.t. pressure, temperature, compositions

using ValueType = internal::ArraySliceOrRef< T, DIM, USD >;
};

/**
Expand All @@ -87,13 +89,15 @@ struct MultiFluidVarView
ArrayView< T, NDIM + 1, USD_DC > const & derivsSrc ):
value( valueSrc ),
derivs( derivsSrc )
{};
{}

ArrayView< T, NDIM, USD > value; ///< View into property values
ArrayView< T, NDIM + 1, USD_DC > derivs; ///< View into property derivatives w.r.t. pressure, temperature, compositions

using SliceType = MultiFluidVarSlice< T, NDIM - 2, USD - 2, USD_DC - 2 >;

using ValueType = ArrayView< T, NDIM, USD >;

GEOS_HOST_DEVICE
SliceType operator()( localIndex const k, localIndex const q ) const
{
Expand All @@ -119,6 +123,12 @@ struct MultiFluidVar
using SliceType = typename ViewType::SliceType;
using SliceTypeConst = typename ViewTypeConst::SliceType;

using ValueType = Array< real64, NDIM, PERM >;
template< int MAXSIZE >
using StackValueType = StackArray< real64, NDIM, MAXSIZE, PERM >;
using ViewValueType = typename ViewType::ValueType;
using SliceValueType = typename SliceType::ValueType;

ViewType toView()
{
return { value.toView(), derivs.toView() };
Expand Down
21 changes: 21 additions & 0 deletions src/coreComponents/constitutive/fluid/multifluid/PVTDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
setInputFlag( InputFlags::REQUIRED ).
setDescription( "Function controlling temperature time history" );

registerWrapper( viewKeyStruct::outputMassDensityString(), &m_outputMassDensity ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 0 ).
setDescription( "Flag to indicate that the mass density of each phase should be output" );

registerWrapper( viewKeyStruct::outputCompressibilityString(), &m_outputCompressibility ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 0 ).
Expand Down Expand Up @@ -90,6 +95,10 @@
void PVTDriver::postProcessInput()
{
// Validate some inputs
GEOS_ERROR_IF( m_outputMassDensity != 0 && m_outputMassDensity != 1,
getWrapperDataContext( viewKeyStruct::outputMassDensityString() ) <<
": option can be either 0 (false) or 1 (true)" );

GEOS_ERROR_IF( m_outputCompressibility != 0 && m_outputCompressibility != 1,
getWrapperDataContext( viewKeyStruct::outputCompressibilityString() ) <<
": option can be either 0 (false) or 1 (true)" );
Expand All @@ -112,6 +121,12 @@
// Default column order = time, pressure, temp, totalDensity, phaseFraction_{1:NP}, phaseDensity_{1:NP}, phaseViscosity_{1:NP}
integer numCols = 3*m_numPhases+4;

// If the mass density is requested then add NP columns
if( m_outputMassDensity != 0 )
{
numCols += m_numPhases;

Check warning on line 127 in src/coreComponents/constitutive/fluid/multifluid/PVTDriver.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/constitutive/fluid/multifluid/PVTDriver.cpp#L127

Added line #L127 was not covered by tests
}

// If the total compressibility is requested then add a column
if( m_outputCompressibility != 0 )
{
Expand Down Expand Up @@ -185,6 +200,7 @@
GEOS_LOG_RANK_0( " Steps .................. " << m_numSteps );
GEOS_LOG_RANK_0( " Output ................. " << m_outputFile );
GEOS_LOG_RANK_0( " Baseline ............... " << m_baselineFile );
GEOS_LOG_RANK_0( " Output Mass Density .... " << m_outputMassDensity );
GEOS_LOG_RANK_0( " Output Compressibility . " << m_outputCompressibility );
GEOS_LOG_RANK_0( " Output Phase Comp. ..... " << m_outputPhaseComposition );
}
Expand Down Expand Up @@ -248,6 +264,11 @@
columnIndex += m_numPhases;
fprintf( fp, "# columns %d-%d = phase densities\n", columnIndex+1, columnIndex + m_numPhases );
columnIndex += m_numPhases;
if( m_outputMassDensity != 0 )

Check warning on line 267 in src/coreComponents/constitutive/fluid/multifluid/PVTDriver.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/constitutive/fluid/multifluid/PVTDriver.cpp#L267

Added line #L267 was not covered by tests
{
fprintf( fp, "# columns %d-%d = phase mass densities\n", columnIndex+1, columnIndex + m_numPhases );
columnIndex += m_numPhases;

Check warning on line 270 in src/coreComponents/constitutive/fluid/multifluid/PVTDriver.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/constitutive/fluid/multifluid/PVTDriver.cpp#L269-L270

Added lines #L269 - L270 were not covered by tests
}
fprintf( fp, "# columns %d-%d = phase viscosities\n", columnIndex+1, columnIndex + m_numPhases );
columnIndex += m_numPhases;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class PVTDriver : public TaskBase
constexpr static char const * outputString() { return "output"; }
constexpr static char const * baselineString() { return "baseline"; }
constexpr static char const * feedString() { return "feedComposition"; }
constexpr static char const * outputMassDensityString() { return "outputMassDensity"; }
constexpr static char const * outputCompressibilityString() { return "outputCompressibility"; }
constexpr static char const * outputPhaseCompositionString() { return "outputPhaseComposition"; }
};
Expand All @@ -102,6 +103,7 @@ class PVTDriver : public TaskBase
string m_pressureFunctionName; ///< Time-dependent function controlling pressure
string m_temperatureFunctionName; ///< Time-dependent function controlling temperature
string m_outputFile; ///< Output file (optional, no output if not specified)
integer m_outputMassDensity{0}; ///< Flag to indicate that the mass density of each phase should be output
integer m_outputCompressibility{0}; ///< Flag to indicate that the total compressibility should be output
integer m_outputPhaseComposition{0}; ///< Flag to indicate that phase compositions should be output

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,23 @@
// perform fluid update using table (P,T) and save resulting total density, etc.
// note: column indexing should be kept consistent with output file header below.

bool const outputMassDensity = (m_outputMassDensity != 0);
bool const outputCompressibility = (m_outputCompressibility != 0);
bool const outputPhaseComposition = (m_outputPhaseComposition != 0);

integer const numSteps = m_numSteps;
integer const outputCompressibility = m_outputCompressibility;
integer const outputPhaseComposition = m_outputPhaseComposition;
using ExecPolicy = typename FLUID_TYPE::exec_policy;
forAll< ExecPolicy >( composition.size( 0 ),
[ outputCompressibility, outputPhaseComposition, numPhases, numComponents, numSteps, kernelWrapper,
table, composition]
[outputMassDensity, outputCompressibility, outputPhaseComposition,
numPhases, numComponents, numSteps, kernelWrapper,
table, composition]
GEOS_HOST_DEVICE ( localIndex const i )
{
// Index for start of phase properties
integer const PHASE = outputCompressibility != 0 ? TEMP + 3 : TEMP + 2;
integer const PHASE_FRACTION = outputCompressibility ? TEMP + 3 : TEMP + 2;
integer const PHASE_DENSITY = PHASE_FRACTION + numPhases;
integer const PHASE_VISCOSITY = outputMassDensity ? PHASE_DENSITY + 2*numPhases : PHASE_DENSITY + numPhases;
integer const PHASE_COMP = PHASE_VISCOSITY + numPhases;

// Temporary space for phase mole fractions
stackArray1d< real64, constitutive::MultiFluidBase::MAX_NUM_COMPONENTS > phaseComposition( numComponents );
Expand All @@ -83,22 +89,29 @@
kernelWrapper.update( i, 0, table( n, PRES ), table( n, TEMP ), composition[i] );
table( n, TEMP + 1 ) = kernelWrapper.totalDensity()( i, 0 );

if( outputCompressibility != 0 )
if( outputCompressibility )
{
table( n, TEMP + 2 ) = kernelWrapper.totalCompressibility( i, 0 );
}

for( integer p = 0; p < numPhases; ++p )
{
table( n, PHASE + p ) = kernelWrapper.phaseFraction()( i, 0, p );
table( n, PHASE + p + numPhases ) = kernelWrapper.phaseDensity()( i, 0, p );
table( n, PHASE + p + 2 * numPhases ) = kernelWrapper.phaseViscosity()( i, 0, p );
table( n, PHASE_FRACTION + p ) = kernelWrapper.phaseFraction()( i, 0, p );
table( n, PHASE_DENSITY + p ) = kernelWrapper.phaseDensity()( i, 0, p );
table( n, PHASE_VISCOSITY + p ) = kernelWrapper.phaseViscosity()( i, 0, p );
}
if( outputMassDensity )
{
for( integer p = 0; p < numPhases; ++p )

Check warning on line 105 in src/coreComponents/constitutive/fluid/multifluid/PVTDriverRunTest.hpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/constitutive/fluid/multifluid/PVTDriverRunTest.hpp#L105

Added line #L105 was not covered by tests
{
table( n, PHASE_DENSITY + numPhases + p ) = kernelWrapper.phaseMassDensity()( i, 0, p );

Check warning on line 107 in src/coreComponents/constitutive/fluid/multifluid/PVTDriverRunTest.hpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/constitutive/fluid/multifluid/PVTDriverRunTest.hpp#L107

Added line #L107 was not covered by tests
}
}
if( outputPhaseComposition != 0 )
if( outputPhaseComposition )
{
for( integer p = 0; p < numPhases; ++p )
{
integer const compStartIndex = PHASE + 3 * numPhases + p * numComponents;
integer const compStartIndex = PHASE_COMP + p * numComponents;

kernelWrapper.phaseCompMoleFraction( i, 0, p, phaseComposition );
for( integer ic = 0; ic < numComponents; ++ic )
Expand Down
Loading
Loading