Merge pull request #2820 from bska/support-fluid-api-gravity
Support GRAVITY As Fallback for DENSITY
This commit is contained in:
@@ -51,6 +51,37 @@ struct DensityTable : public FlatTable< DENSITYRecord > {
|
||||
}
|
||||
};
|
||||
|
||||
struct GRAVITYRecord {
|
||||
static constexpr std::size_t size = 3;
|
||||
|
||||
double oil_api;
|
||||
double water_sg;
|
||||
double gas_sg;
|
||||
|
||||
bool operator==(const GRAVITYRecord& data) const {
|
||||
return this->oil_api == data.oil_api &&
|
||||
this->water_sg == data.water_sg &&
|
||||
this->gas_sg == data.gas_sg;
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(this->oil_api);
|
||||
serializer(this->water_sg);
|
||||
serializer(this->gas_sg);
|
||||
}
|
||||
};
|
||||
|
||||
struct GravityTable : public FlatTable< GRAVITYRecord > {
|
||||
using FlatTable< GRAVITYRecord >::FlatTable;
|
||||
|
||||
static GravityTable serializeObject()
|
||||
{
|
||||
return GravityTable({{1.0, 2.0, 3.0}});
|
||||
}
|
||||
};
|
||||
|
||||
struct DiffCoeffRecord {
|
||||
static constexpr std::size_t size = 8;
|
||||
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <ios>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
@@ -120,6 +122,36 @@ std::optional<JFunc> make_jfunc(const Deck& deck) {
|
||||
return JFunc(deck);
|
||||
}
|
||||
|
||||
DensityTable make_density_table(const GravityTable& gravity) {
|
||||
auto rho = DensityTable{};
|
||||
rho.reserve(gravity.size());
|
||||
|
||||
constexpr auto default_air_density =
|
||||
1.22 * unit::kilogram / unit::cubic(unit::meter);
|
||||
|
||||
constexpr auto default_water_density =
|
||||
1000.0 * unit::kilogram / unit::cubic(unit::meter);
|
||||
|
||||
// Degrees API defined as
|
||||
//
|
||||
// API = (141.5 / SG) - 131.5
|
||||
//
|
||||
// with SG being the specific gravity of oil relative to pure water.
|
||||
|
||||
std::transform(gravity.begin(), gravity.end(),
|
||||
std::back_inserter(rho),
|
||||
[](const GRAVITYRecord& record)
|
||||
{
|
||||
return DENSITYRecord {
|
||||
(141.5 / (record.oil_api + 131.5)) * default_water_density,
|
||||
record.water_sg * default_water_density,
|
||||
record.gas_sg * default_air_density
|
||||
};
|
||||
});
|
||||
|
||||
return rho;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +195,9 @@ std::optional<JFunc> make_jfunc(const Deck& deck) {
|
||||
if( deck.hasKeyword( "DENSITY" ) )
|
||||
this->m_densityTable = DensityTable( deck.getKeyword( "DENSITY" ) );
|
||||
|
||||
else if( deck.hasKeyword( "GRAVITY" ) )
|
||||
this->m_densityTable = make_density_table( GravityTable ( deck.getKeyword( "GRAVITY" ) ) );
|
||||
|
||||
if( deck.hasKeyword( "DIFFC" ) )
|
||||
this->m_diffCoeffTable = DiffCoeffTable( deck.getKeyword( "DIFFC" ) );
|
||||
|
||||
|
||||
@@ -1526,6 +1526,7 @@ FlatTable< T >::FlatTable( const DeckKeyword& kw ) :
|
||||
{}
|
||||
|
||||
template FlatTable< DENSITYRecord >::FlatTable( const DeckKeyword& );
|
||||
template FlatTable< GRAVITYRecord >::FlatTable( const DeckKeyword& );
|
||||
template FlatTable< DiffCoeffRecord >::FlatTable( const DeckKeyword& );
|
||||
template FlatTable< PVTWRecord >::FlatTable( const DeckKeyword& );
|
||||
template FlatTable< PVCDORecord >::FlatTable( const DeckKeyword& );
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
{
|
||||
"name": "WATER_SP_GRAVITY",
|
||||
"value_type": "DOUBLE",
|
||||
"dimension": "1",
|
||||
"default": 1
|
||||
},
|
||||
{
|
||||
"name": "GAS_SP_GRAVITY",
|
||||
"value_type": "DOUBLE",
|
||||
"dimension": "1",
|
||||
"default": 0.7773
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1665,6 +1665,25 @@ BOOST_AUTO_TEST_CASE( TestParseDENSITY ) {
|
||||
BOOST_CHECK_EQUAL( 1.3, density[0].gas );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( TestParseGRAVITY ) {
|
||||
const auto deck = Parser{}.parseString(R"(RUNSPEC
|
||||
TABDIMS
|
||||
1* 1 /
|
||||
|
||||
GRAVITY
|
||||
12.34 1.2 1.21 /
|
||||
|
||||
END
|
||||
)");
|
||||
|
||||
const auto tables = Opm::TableManager { deck };
|
||||
const auto& density = tables.getDensityTable();
|
||||
|
||||
BOOST_CHECK_CLOSE( 983.731924360, density[0].oil , 1.0e-8 );
|
||||
BOOST_CHECK_CLOSE( 1200.0 , density[0].water, 1.0e-8 );
|
||||
BOOST_CHECK_CLOSE( 1.4762 , density[0].gas , 1.0e-8 );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( TestParseDIFFC ) {
|
||||
const std::string data = R"(
|
||||
TABDIMS
|
||||
|
||||
Reference in New Issue
Block a user