Skip to content

Commit

Permalink
Use ComponentProperties in calculation functions (#2799)
Browse files Browse the repository at this point in the history
* Create another copy of CompositionalMultiphaseFluid

* Create template parameterised Compositional multiphase fluid

* Create phase models

* Replace template parameter pack with individual parameters

* Rename CompositionalMultiphaseFluidPVT to CompositionalMultiphaseFluidPVTPackage

* Lump component molecular weight and component names into ComponentProperties

* Implement water phase index

* Use ComponentProperties

---------
  • Loading branch information
dkachuma authored Nov 29, 2023
1 parent cac9479 commit e064ae1
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace geos
namespace constitutive
{

namespace compositional
{

/*
* Calculate the molar volume and apply the Peneloux shift parameters. The parameters should be in
* dimensional form.
Expand Down Expand Up @@ -142,6 +145,8 @@ void CompositionalProperties::computeMassDensity( integer const numComps,
}
}

} // namespace compositional

} // namespace constitutive

} // namespace geos
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ namespace geos
namespace constitutive
{

namespace compositional
{

struct CompositionalProperties
{
public:
Expand Down Expand Up @@ -122,6 +125,8 @@ struct CompositionalProperties
arraySlice1d< real64 > const & dMassDensity_dz );
};

} //namespace compositional

} // namespace constitutive

} // namespace geos
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
#define GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_COMPOSITIONAL_FUNCTIONS_KVALUEINITIALIZATION_HPP_

#include "common/DataTypes.hpp"
#include "constitutive/fluid/multifluid/compositional/models/ComponentProperties.hpp"

namespace geos
{

namespace constitutive
{

namespace compositional
{

struct KValueInitialization
{
public:
Expand All @@ -35,9 +39,7 @@ struct KValueInitialization
* @param[in] numComps number of components
* @param[in] pressure pressure
* @param[in] temperature temperature
* @param[in] criticalPressure critical pressures
* @param[in] criticalTemperature critical temperatures
* @param[in] acentricFactor acentric factors
* @param[in] componentProperties The compositional component properties
* @param[out] kValues the calculated k-values
**/
GEOS_HOST_DEVICE
Expand All @@ -46,11 +48,12 @@ struct KValueInitialization
computeWilsonGasLiquidKvalue( integer const numComps,
real64 const pressure,
real64 const temperature,
arrayView1d< real64 const > const criticalPressure,
arrayView1d< real64 const > const criticalTemperature,
arrayView1d< real64 const > const acentricFactor,
ComponentProperties::KernelWrapper const & componentProperties,
arraySlice1d< real64 > const kValues )
{
arrayView1d< real64 const > const & criticalPressure = componentProperties.m_componentCriticalPressure;
arrayView1d< real64 const > const & criticalTemperature = componentProperties.m_componentCriticalTemperature;
arrayView1d< real64 const > const & acentricFactor = componentProperties.m_componentAcentricFactor;
for( integer ic = 0; ic < numComps; ++ic )
{
real64 const pr = criticalPressure[ic] / pressure;
Expand All @@ -76,6 +79,8 @@ struct KValueInitialization

};

} // namespace compositional

} // namespace constitutive

} // namespace geos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@
#define GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_COMPOSITIONAL_FUNCTIONS_NEGATIVETWOPHASEFLASH_HPP_

#include "common/DataTypes.hpp"
#include "CubicEOSPhaseModel.hpp"
#include "RachfordRice.hpp"
#include "KValueInitialization.hpp"
#include "constitutive/fluid/multifluid/MultiFluidConstants.hpp"
#include "constitutive/fluid/multifluid/compositional/models/ComponentProperties.hpp"

namespace geos
{

namespace constitutive
{

namespace compositional
{

struct NegativeTwoPhaseFlash
{
public:
Expand All @@ -40,10 +43,7 @@ struct NegativeTwoPhaseFlash
* @param[in] pressure pressure
* @param[in] temperature temperature
* @param[in] composition composition of the mixture
* @param[in] criticalPressure critical pressures
* @param[in] criticalTemperature critical temperatures
* @param[in] acentricFactor acentric factors
* @param[in] binaryInteractionCoefficients binary coefficients (currently not implemented)
* @param[in] componentProperties The compositional component properties
* @param[out] vapourPhaseMoleFraction the calculated vapour (gas) mole fraction
* @param[out] liquidComposition the calculated liquid phase composition
* @param[out] vapourComposition the calculated vapour phase composition
Expand All @@ -55,10 +55,7 @@ struct NegativeTwoPhaseFlash
real64 const pressure,
real64 const temperature,
arrayView1d< real64 const > const composition,
arrayView1d< real64 const > const criticalPressure,
arrayView1d< real64 const > const criticalTemperature,
arrayView1d< real64 const > const acentricFactor,
real64 const & binaryInteractionCoefficients,
ComponentProperties::KernelWrapper const & componentProperties,
real64 & vapourPhaseMoleFraction,
arrayView1d< real64 > const liquidComposition,
arrayView1d< real64 > const vapourComposition )
Expand Down Expand Up @@ -91,9 +88,7 @@ struct NegativeTwoPhaseFlash
KValueInitialization::computeWilsonGasLiquidKvalue( numComps,
pressure,
temperature,
criticalPressure,
criticalTemperature,
acentricFactor,
componentProperties,
kVapourLiquid );

bool converged = false;
Expand All @@ -113,24 +108,18 @@ struct NegativeTwoPhaseFlash
normalizeComposition( numComps, vapourComposition );

// Compute the phase fugacities
CubicEOSPhaseModel< EOS_TYPE_LIQUID >::compute( numComps,
pressure,
temperature,
liquidComposition,
criticalPressure,
criticalTemperature,
acentricFactor,
binaryInteractionCoefficients,
logLiquidFugacity );
CubicEOSPhaseModel< EOS_TYPE_VAPOUR >::compute( numComps,
pressure,
temperature,
vapourComposition,
criticalPressure,
criticalTemperature,
acentricFactor,
binaryInteractionCoefficients,
logVapourFugacity );
EOS_TYPE_LIQUID::computeLogFugacityCoefficients( numComps,
pressure,
temperature,
liquidComposition,
componentProperties,
logLiquidFugacity );
EOS_TYPE_VAPOUR::computeLogFugacityCoefficients( numComps,
pressure,
temperature,
vapourComposition,
componentProperties,
logVapourFugacity );

// Compute fugacity ratios and check convergence
converged = true;
Expand Down Expand Up @@ -203,6 +192,8 @@ struct NegativeTwoPhaseFlash
}
};

} // namespace compositional

} // namespace constitutive

} // namespace geos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@ namespace constitutive

namespace compositional
{
template< typename EOS_TYPE > struct EOSCatalogName {};
template<> struct EOSCatalogName< PengRobinsonEOS > { static constexpr char const * catalogName() { return "PengRobinson"; } };
template<> struct EOSCatalogName< SoaveRedlichKwongEOS > { static constexpr char const * catalogName() { return "SoaveRedlichKwong"; } };

// Naming conventions
template< typename EOS_TYPE_LIQUID, typename EOS_TYPE_VAPOUR >
string NegativeTwoPhaseFlashModel< EOS_TYPE_LIQUID, EOS_TYPE_VAPOUR >::catalogName()
{
return EOSCatalogName< EOS_TYPE_LIQUID >::catalogName();
return EOS_TYPE_LIQUID::catalogName();
}

template< typename EOS_TYPE_LIQUID, typename EOS_TYPE_VAPOUR >
Expand All @@ -58,8 +55,8 @@ NegativeTwoPhaseFlashModelUpdate( integer const numComponents ):
{}

// Explicit instantiation of the model template.
template class NegativeTwoPhaseFlashModel< PengRobinsonEOS, PengRobinsonEOS >;
template class NegativeTwoPhaseFlashModel< SoaveRedlichKwongEOS, SoaveRedlichKwongEOS >;
template class NegativeTwoPhaseFlashModel< CubicEOSPhaseModel< PengRobinsonEOS >, CubicEOSPhaseModel< PengRobinsonEOS > >;
template class NegativeTwoPhaseFlashModel< CubicEOSPhaseModel< SoaveRedlichKwongEOS >, CubicEOSPhaseModel< SoaveRedlichKwongEOS > >;

} // end namespace compositional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ class NegativeTwoPhaseFlashModel : public FunctionBase
KernelWrapper createKernelWrapper() const;
};

using NegativeTwoPhaseFlashPRPR = NegativeTwoPhaseFlashModel< PengRobinsonEOS, PengRobinsonEOS >;
using NegativeTwoPhaseFlashSRKSRK = NegativeTwoPhaseFlashModel< SoaveRedlichKwongEOS, SoaveRedlichKwongEOS >;
using NegativeTwoPhaseFlashPRPR = NegativeTwoPhaseFlashModel<
CubicEOSPhaseModel< PengRobinsonEOS >,
CubicEOSPhaseModel< PengRobinsonEOS > >;
using NegativeTwoPhaseFlashSRKSRK = NegativeTwoPhaseFlashModel<
CubicEOSPhaseModel< SoaveRedlichKwongEOS >,
CubicEOSPhaseModel< SoaveRedlichKwongEOS > >;

} // end namespace compositional

Expand Down
35 changes: 24 additions & 11 deletions src/coreComponents/constitutive/unitTests/TestFluid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define GEOS_CONSTITUTIVE_UNITTESTS_TESTFLUID_HPP_

#include "common/DataTypes.hpp"
#include "constitutive/fluid/multifluid/compositional/models/ComponentProperties.hpp"

namespace geos
{
Expand All @@ -45,11 +46,12 @@ struct Fluid

static constexpr integer Pc = 0;
static constexpr integer Tc = 1;
static constexpr integer Ac = 2;
static constexpr integer Mw = 3;
static constexpr integer Vs = 4;
static constexpr integer Vc = 2;
static constexpr integer Ac = 3;
static constexpr integer Mw = 4;
static constexpr integer Vs = 5;

static std::array< real64, 55 > data;
static std::array< real64, 66 > data;
};

template< int NC >
Expand All @@ -66,18 +68,25 @@ class TestFluid
std::unique_ptr< TestFluid< NC > > testFluid( new TestFluid() );
createArray( testFluid->criticalPressure, components, Fluid::Pc, Fluid::data );
createArray( testFluid->criticalTemperature, components, Fluid::Tc, Fluid::data );
createArray( testFluid->criticalVolume, components, Fluid::Vc, Fluid::data );
createArray( testFluid->acentricFactor, components, Fluid::Ac, Fluid::data );
createArray( testFluid->molecularWeight, components, Fluid::Mw, Fluid::data );
createArray( testFluid->volumeShift, components, Fluid::Vs, Fluid::data );
testFluid->binaryCoeff.resize( NC, NC );
return testFluid;
}

arrayView1d< real64 const > const getCriticalPressure() const { return criticalPressure.toViewConst(); }
arrayView1d< real64 const > const getCriticalTemperature() const { return criticalTemperature.toViewConst(); }
arrayView1d< real64 const > const getCriticalVolume() const { return criticalVolume.toViewConst(); }
arrayView1d< real64 const > const getAcentricFactor() const { return acentricFactor.toViewConst(); }
arrayView1d< real64 const > const getMolecularWeight() const { return molecularWeight.toViewConst(); }
arrayView1d< real64 const > const getVolumeShift() const { return volumeShift.toViewConst(); }
constitutive::compositional::ComponentProperties::KernelWrapper createKernelWrapper() const
{
return constitutive::compositional::ComponentProperties::KernelWrapper(
molecularWeight,
criticalPressure,
criticalTemperature,
criticalVolume,
acentricFactor,
volumeShift,
binaryCoeff );
}

private:
TestFluid() = default;
Expand All @@ -88,6 +97,7 @@ class TestFluid
array1d< real64 > acentricFactor;
array1d< real64 > molecularWeight;
array1d< real64 > volumeShift;
array2d< real64 > binaryCoeff;

private:
template< typename ARRAY, typename LIST, typename DATAARRAY >
Expand All @@ -109,13 +119,16 @@ class TestFluid
}
};

std::array< real64, 55 > Fluid::data = {
std::array< real64, 66 > Fluid::data = {
// -- Pc
2.2050e+07, 7.3750e+06, 3.4000e+06, 8.9630e+06, 1.2960e+06, 4.8721e+06,
4.2481e+06, 3.6400e+06, 4.5990e+06, 2.5300e+06, 1.4600e+06,
// -- Tc
6.4700e+02, 3.0410e+02, 1.2620e+02, 3.7353e+02, 3.3150e+01, 3.0532e+02,
3.6983e+02, 4.0785e+02, 1.9060e+02, 6.2200e+02, 7.8200e+02,
// -- Vc
6.4920e-05, 9.1025e-05, 8.1615e-05, 9.2053e-05, 5.5585e-05, 1.3810e-04,
1.9170e-04, 2.4649e-04, 9.1302e-05, 5.3923e-04, 1.1664e-03,
// -- Ac
3.4400e-01, 2.3900e-01, 4.0000e-02, 9.4200e-02, -2.1900e-01, 9.9500e-02,
1.5230e-01, 1.8440e-01, 1.1400e-02, 4.4300e-01, 8.1600e-01,
Expand Down
Loading

0 comments on commit e064ae1

Please sign in to comment.