Refactor norne_pvt test.

This commit is contained in:
Atgeirr Flø Rasmussen committed 2025-08-21 10:51:58 +02:00
1 parent 322864f53b
commit acb2f3186a
3 files changed
+184 -80

No files matched your search

+136
View File
@@ -0,0 +1,136 @@
0.001067365884768252
0.8842144459465948
0.001139610367867863
0.8889390911747412
0.0009380136595621231
0.8649334286087783
0.0009987172851173591
0.8697895741961066
0.0008352974262307506
0.8467640201617289
0.0008872876919754234
0.8517176299799303
0.0007798698884157563
0.8335427974822971
0.0008262750804524759
0.8385186142862242
0.0007288311307782538
0.8190404127209736
0.0007698866514049059
0.8240471961522335
0.0006825042410160947
0.803410444833244
0.0007204078622273607
0.8084595074425605
0.0006234767677558306
0.7713138172586758
0.0006496330618961862
0.7766160433369542
0.000651229105624119
0.776917384729955
0.001207677499838996
0.9069944946214321
0.001290773523318014
0.9112044963286439
0.001110630385719949
0.8904069569629799
0.001196270380351536
0.8955100813995633
0.00103118116169964
0.8754885916744818
0.001106335207380859
0.8806296520468501
0.0009441347105027721
0.8569701338850926
0.001009983732539072
0.8622423563182279
0.0009032093095128285
0.8453361872800773
0.0009637453647768096
0.8506130170932648
0.0008671448069623387
0.8306981928590661
0.0009214297424414502
0.8358586733515898
0.0008181109758136193
0.8147353680775065
0.0008673522699228274
0.8199410720992917
0.0007770436447790644
0.7995549138985545
0.0008222901043284433
0.8047914482097706
0.0007097520539714978
0.7850771136974397
0.000760291642167173
0.7903291531251422
0.0006567932886715405
0.7707309776186537
0.0007112417453320037
0.775961893613465
0.0006149617519937411
0.7562740188955196
0.0006721364233644667
0.7614129029554696
0.0005800038064245576
0.7416133164752957
0.0006411534634401428
0.746781980805345
0.000551247394294262
0.7268688957467365
0.0006163327387350402
0.7320673403468846
0.0005284088753580348
0.7121435343910416
0.0005978192793407415
0.717371759261292
0.0005092618355698417
0.6973320723054014
0.0005832339415679676
0.7025900774457522
0.0004929573897622886
0.6824327226736142
0.0005699632141109842
0.6876147523758552
0.0004802681029531063
0.6675500499930874
0.0005647448609131752
0.6728676156736344
0.0004708899801247241
0.6526840542638054
0.0005642787764001166
0.6581383471334691
0.0004764965885921432
0.6385875331566937
0.00060774836371811
0.6450400846215855
0.000480061876971874
0.6240834749571945
0.0005990919234678501
0.6294903814480374
0.0002662364828106089
0.6122387462923542
0.0006091538599248313
0.6144926854262093
0.0002567048941245055
0.604223446382163
0.0006215731480908455
0.5993999545934215
0.0002476020952651217
0.5962081464719715
0.000642907345845706
0.5859485521055366
0.0002388997883115314
0.5881928465617802
0.0006794628278756396
0.5773916521850377
0.000223306623435024
0.5728909103695966
0.0007783722276609877
0.5601905008427143
0.01142273040374406
0.5547460187737973
-0.003512925191329921
0.5580920111920565
-0.001298671946699846
0.5452683227705116
+47 -80
View File
@@ -45,6 +45,7 @@
#include <opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp>
#include <algorithm>
#include <fstream>
using namespace Opm;
@@ -61,7 +62,25 @@ using namespace Opm;
further semantic meaning.
*/
void verify_norne_oil_pvt_region1(const Opm::EclipseState& eclState, const Opm::Schedule& schedule) {
// The TEST_OR_PRINT macro has been added to simplify updating this
// regression test.
#define TEST_OR_PRINT BOOST_CHECK_CLOSE
// #define TEST_OR_PRINT(val, expected, tolerance) printVal(val);
inline void printVal(const double val)
{
std::cout.precision(16);
std::cout << val << '\n';
}
void
verify_norne_oil_pvt_region1(const Opm::EclipseState& eclState,
const Opm::Schedule& schedule,
std::istream& expectedData)
{
Opm::LiveOilPvt<double> oilPvt;
oilPvt.initFromState(eclState, schedule);
@@ -84,25 +103,11 @@ void verify_norne_oil_pvt_region1(const Opm::EclipseState& eclState, const Opm::
234, 268,
270 };
std::vector<double> mu_expected = {0.00106736588, 0.00113961037,
0.00093801366, 0.00099871729,
0.00083529743, 0.00088728769,
0.00077986989, 0.00082627508,
0.00072883113, 0.00076988665,
0.00068250424, 0.00072040786,
0.00062347677, 0.00064963306,
0.00065122911};
std::vector<double> b_expected = {0.88421444595, 0.88893909117,
0.86493342861, 0.86978957420,
0.84676402016, 0.85171762998,
0.83354279748, 0.83851861429,
0.81904041272, 0.82404719615,
0.80341044483, 0.80845950744,
0.77131381726, 0.77661604334,
0.77691738473};
std::vector<double> mu_expected(P.size());
std::vector<double> b_expected(P.size());
for (std::size_t ii = 0; ii < P.size(); ++ii) {
expectedData >> mu_expected[ii] >> b_expected[ii];
}
{
// convert the pressures to SI units (bar to Pascal)
@@ -126,14 +131,18 @@ void verify_norne_oil_pvt_region1(const Opm::EclipseState& eclState, const Opm::
b = oilPvt.inverseFormationVolumeFactor(/*tableIndex=*/0, /*T=*/273.15, P[i], rs[i]);
}
BOOST_CHECK_CLOSE( mu , mu_expected[i], 1e-5 );
BOOST_CHECK_CLOSE( b , b_expected[i], 1e-5 );
TEST_OR_PRINT( mu , mu_expected[i], 1e-5 );
TEST_OR_PRINT( b , b_expected[i], 1e-5 );
}
}
}
void verify_norne_oil_pvt_region2(const Opm::EclipseState& eclState, const Opm::Schedule& schedule) {
void
verify_norne_oil_pvt_region2(const Opm::EclipseState& eclState,
const Opm::Schedule& schedule,
std::istream& expectedData)
{
Opm::LiveOilPvt<double> oilPvt;
oilPvt.initFromState(eclState, schedule);
@@ -195,60 +204,12 @@ void verify_norne_oil_pvt_region2(const Opm::EclipseState& eclState, const Opm::
503, 553,
650, 680, 710};
std::vector<double> mu_expected(P.size());
std::vector<double> b_expected(P.size());
for (std::size_t ii = 0; ii < P.size(); ++ii) {
expectedData >> mu_expected[ii] >> b_expected[ii];
}
std::vector<double> mu_expected = {0.00120767750, 0.00129077352,
0.00111063039, 0.00119627038,
0.00103118116, 0.00110633521,
0.00094413471, 0.00100998373,
0.00090320931, 0.00096374536,
0.00086714481, 0.00092142974,
0.00081811098, 0.00086735227,
0.00077704364, 0.00082229010,
0.00070975205, 0.00076029164,
0.00065679329, 0.00071124175,
0.00061496175, 0.00067213642,
0.00058000381, 0.00064115346,
0.00055124739, 0.00061633274,
0.00052840888, 0.00059781928,
0.00050926184, 0.00058323394,
0.00049295739, 0.00056996321,
0.00048026810, 0.00056474486,
0.00047088998, 0.00056427878,
0.00047649659, 0.00060774836,
0.00048006188, 0.00059909192,
0.00026623648, 0.00060915386,
0.00025670489, 0.00062157315,
0.00024760210, 0.00064290735,
0.00023889979, 0.00067946283,
0.00022330662, 0.00077837223,
0.01142273040, -0.00351292519, -0.00129867195};
std::vector<double> b_expected = {0.90699449462, 0.91120449633,
0.89040695696, 0.89551008140,
0.87548859167, 0.88062965205,
0.85697013389, 0.86224235632,
0.84533618728, 0.85061301709,
0.83069819286, 0.83585867335,
0.81473536808, 0.81994107210,
0.79955491390, 0.80479144821,
0.78507711370, 0.79032915313,
0.77073097762, 0.77596189361,
0.75627401890, 0.76141290296,
0.74161331648, 0.74678198081,
0.72686889575, 0.73206734035,
0.71214353439, 0.71737175926,
0.69733207231, 0.70259007745,
0.68243272267, 0.68761475238,
0.66755004999, 0.67286761567,
0.65268405426, 0.65813834713,
0.63858753316, 0.64504008462,
0.62408347496, 0.62949038145,
0.61223874629, 0.61449268543,
0.60422344638, 0.59939995459,
0.59620814647, 0.58594855211,
0.58819284656, 0.57739165219,
0.57289091037, 0.56019050084,
0.55474601877, 0.55809201119, 0.54526832277};
// convert the pressures to SI units (bar to Pascal)
std::transform(P.begin(), P.end(), P.begin(),
@@ -271,8 +232,8 @@ void verify_norne_oil_pvt_region2(const Opm::EclipseState& eclState, const Opm::
b = oilPvt.inverseFormationVolumeFactor(/*tableIndex=*/1, /*T=*/273.15, P[i], rs[i]);
}
BOOST_CHECK_CLOSE( mu , mu_expected[i], 1e-5 );
BOOST_CHECK_CLOSE( b , b_expected[i], 1e-5 );
TEST_OR_PRINT( mu , mu_expected[i], 1e-5 );
TEST_OR_PRINT( b , b_expected[i], 1e-5 );
}
}
@@ -287,6 +248,12 @@ BOOST_AUTO_TEST_CASE( Test_Norne_PVT) {
Opm::EclipseState eclState(deck);
Opm::Schedule schedule(deck, eclState, python);
verify_norne_oil_pvt_region1(eclState, schedule);
verify_norne_oil_pvt_region2(eclState, schedule);
// The expected data are stored in the order they are printed (if
// setting TEST_OR_PRINT to printing), i.e. mu and b for each
// sample point in order.
std::ifstream expectedData("norne_pvt_expected.txt");
BOOST_REQUIRE(expectedData);
verify_norne_oil_pvt_region1(eclState, schedule, expectedData);
verify_norne_oil_pvt_region2(eclState, schedule, expectedData);
}