mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-25 08:41:00 -06:00
Address review comments.
This commit is contained in:
parent
2bf4d15285
commit
852765a65b
@ -665,7 +665,7 @@ namespace Opm {
|
||||
for (const auto& well : well_container_) {
|
||||
report += well->getWellConvergence(B_avg);
|
||||
}
|
||||
auto severity = report.severityOfWorstFailure();
|
||||
ConvergenceReport::Severity severity = report.severityOfWorstFailure();
|
||||
|
||||
// checking NaN residuals
|
||||
{
|
||||
|
@ -420,25 +420,27 @@ namespace Opm
|
||||
}
|
||||
|
||||
using CR = ConvergenceReport;
|
||||
CR::WellFailure::Type ctrltype = CR::WellFailure::Type::Mb;
|
||||
CR::WellFailure::Type ctrltype = CR::WellFailure::Type::Invalid;
|
||||
switch(well_controls_get_current_type(well_controls_)) {
|
||||
case THP:
|
||||
ctrltype = CR::WellFailure::Type::CtrlTHP;
|
||||
ctrltype = CR::WellFailure::Type::ControlTHP;
|
||||
break;
|
||||
case BHP:
|
||||
ctrltype = CR::WellFailure::Type::CtrlBHP;
|
||||
ctrltype = CR::WellFailure::Type::ControlBHP;
|
||||
break;
|
||||
case RESERVOIR_RATE:
|
||||
case SURFACE_RATE:
|
||||
ctrltype = CR::WellFailure::Type::CtrlRate;
|
||||
ctrltype = CR::WellFailure::Type::ControlRate;
|
||||
break;
|
||||
default:
|
||||
OPM_THROW(std::runtime_error, "Unknown well control control types for well " << name());
|
||||
}
|
||||
assert(ctrltype != CR::WellFailure::Type::Invalid);
|
||||
|
||||
std::vector<double> maximum_residual(numWellEq, 0.0);
|
||||
|
||||
ConvergenceReport report;
|
||||
const int dummy_component = -1;
|
||||
// TODO: the following is a little complicated, maybe can be simplified in some way?
|
||||
for (int eq_idx = 0; eq_idx < numWellEq; ++eq_idx) {
|
||||
for (int seg = 0; seg < numberOfSegments(); ++seg) {
|
||||
@ -452,11 +454,11 @@ namespace Opm
|
||||
// Control equation
|
||||
const double control_residual = abs_residual[seg][eq_idx];
|
||||
if (std::isnan(control_residual)) {
|
||||
report.setWellFailed({ctrltype, CR::Severity::NotANumber, -1, name()});
|
||||
report.setWellFailed({ctrltype, CR::Severity::NotANumber, dummy_component, name()});
|
||||
} else if (control_residual > param_.max_residual_allowed_) {
|
||||
report.setWellFailed({ctrltype, CR::Severity::TooLarge, -1, name()});
|
||||
report.setWellFailed({ctrltype, CR::Severity::TooLarge, dummy_component, name()});
|
||||
} else if (control_residual > param_.tolerance_wells_) {
|
||||
report.setWellFailed({ctrltype, CR::Severity::Normal, -1, name()});
|
||||
report.setWellFailed({ctrltype, CR::Severity::Normal, dummy_component, name()});
|
||||
}
|
||||
} else {
|
||||
// Pressure equation
|
||||
@ -474,20 +476,20 @@ namespace Opm
|
||||
const double flux_residual = maximum_residual[eq_idx];
|
||||
// TODO: the report can not handle the segment number yet.
|
||||
if (std::isnan(flux_residual)) {
|
||||
report.setWellFailed({CR::WellFailure::Type::Mb, CR::Severity::NotANumber, eq_idx, name()});
|
||||
report.setWellFailed({CR::WellFailure::Type::MassBalance, CR::Severity::NotANumber, eq_idx, name()});
|
||||
} else if (flux_residual > param_.max_residual_allowed_) {
|
||||
report.setWellFailed({CR::WellFailure::Type::Mb, CR::Severity::TooLarge, eq_idx, name()});
|
||||
report.setWellFailed({CR::WellFailure::Type::MassBalance, CR::Severity::TooLarge, eq_idx, name()});
|
||||
} else if (flux_residual > param_.tolerance_wells_) {
|
||||
report.setWellFailed({CR::WellFailure::Type::Mb, CR::Severity::Normal, eq_idx, name()});
|
||||
report.setWellFailed({CR::WellFailure::Type::MassBalance, CR::Severity::Normal, eq_idx, name()});
|
||||
}
|
||||
} else { // pressure equation
|
||||
const double pressure_residual = maximum_residual[eq_idx];
|
||||
if (std::isnan(pressure_residual)) {
|
||||
report.setWellFailed({CR::WellFailure::Type::Pressure, CR::Severity::NotANumber, -1, name()});
|
||||
report.setWellFailed({CR::WellFailure::Type::Pressure, CR::Severity::NotANumber, dummy_component, name()});
|
||||
} else if (std::isinf(pressure_residual)) {
|
||||
report.setWellFailed({CR::WellFailure::Type::Pressure, CR::Severity::TooLarge, -1, name()});
|
||||
report.setWellFailed({CR::WellFailure::Type::Pressure, CR::Severity::TooLarge, dummy_component, name()});
|
||||
} else if (pressure_residual > param_.tolerance_pressure_ms_wells_) {
|
||||
report.setWellFailed({CR::WellFailure::Type::Pressure, CR::Severity::Normal, -1, name()});
|
||||
report.setWellFailed({CR::WellFailure::Type::Pressure, CR::Severity::Normal, dummy_component, name()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1510,7 +1510,7 @@ namespace Opm
|
||||
|
||||
ConvergenceReport report;
|
||||
using CR = ConvergenceReport;
|
||||
CR::WellFailure::Type type = CR::WellFailure::Type::Mb;
|
||||
CR::WellFailure::Type type = CR::WellFailure::Type::MassBalance;
|
||||
// checking if any NaN or too large residuals found
|
||||
for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
|
||||
if (!FluidSystem::phaseIsActive(phaseIdx)) {
|
||||
@ -1536,16 +1536,16 @@ namespace Opm
|
||||
double control_tolerance = 0.;
|
||||
switch(well_controls_get_current_type(well_controls_)) {
|
||||
case THP:
|
||||
type = CR::WellFailure::Type::CtrlTHP;
|
||||
type = CR::WellFailure::Type::ControlTHP;
|
||||
control_tolerance = 1.e3; // 0.01 bar
|
||||
break;
|
||||
case BHP: // pressure type of control
|
||||
type = CR::WellFailure::Type::CtrlBHP;
|
||||
type = CR::WellFailure::Type::ControlBHP;
|
||||
control_tolerance = 1.e3; // 0.01 bar
|
||||
break;
|
||||
case RESERVOIR_RATE:
|
||||
case SURFACE_RATE:
|
||||
type = CR::WellFailure::Type::CtrlRate;
|
||||
type = CR::WellFailure::Type::ControlRate;
|
||||
control_tolerance = 1.e-4; // smaller tolerance for rate control
|
||||
break;
|
||||
default:
|
||||
|
@ -47,7 +47,7 @@ namespace Opm
|
||||
NotANumber = 3 };
|
||||
struct ReservoirFailure
|
||||
{
|
||||
enum struct Type { Mb, Cnv };
|
||||
enum struct Type { Invalid, MassBalance, Cnv };
|
||||
Type type;
|
||||
Severity severity;
|
||||
int phase;
|
||||
@ -55,7 +55,7 @@ namespace Opm
|
||||
};
|
||||
struct WellFailure
|
||||
{
|
||||
enum struct Type { Mb, Pressure, CtrlBHP, CtrlTHP, CtrlRate };
|
||||
enum struct Type { Invalid, MassBalance, Pressure, ControlBHP, ControlTHP, ControlRate };
|
||||
Type type;
|
||||
Severity severity;
|
||||
int phase;
|
||||
|
@ -54,8 +54,8 @@ BOOST_AUTO_TEST_CASE(Failures)
|
||||
}
|
||||
|
||||
Opm::ConvergenceReport s2;
|
||||
s2.setWellFailed({CR::WellFailure::Type::CtrlTHP, CR::Severity::Normal, -1, "PRODUCER-123"});
|
||||
s2.setWellFailed({CR::WellFailure::Type::Mb, CR::Severity::TooLarge, 2, "INJECTOR-XYZ"});
|
||||
s2.setWellFailed({CR::WellFailure::Type::ControlTHP, CR::Severity::Normal, -1, "PRODUCER-123"});
|
||||
s2.setWellFailed({CR::WellFailure::Type::MassBalance, CR::Severity::TooLarge, 2, "INJECTOR-XYZ"});
|
||||
{
|
||||
BOOST_CHECK(!s2.converged());
|
||||
BOOST_CHECK(!s2.reservoirFailed());
|
||||
@ -63,12 +63,12 @@ BOOST_AUTO_TEST_CASE(Failures)
|
||||
BOOST_CHECK(s2.reservoirFailures().empty());
|
||||
BOOST_REQUIRE(s2.wellFailures().size() == 2);
|
||||
const auto f0 = s2.wellFailures()[0];
|
||||
BOOST_CHECK(f0.type == CR::WellFailure::Type::CtrlTHP);
|
||||
BOOST_CHECK(f0.type == CR::WellFailure::Type::ControlTHP);
|
||||
BOOST_CHECK(f0.severity == CR::Severity::Normal);
|
||||
BOOST_CHECK(f0.phase == -1);
|
||||
BOOST_CHECK(f0.well_name == "PRODUCER-123");
|
||||
const auto f1 = s2.wellFailures()[1];
|
||||
BOOST_CHECK(f1.type == CR::WellFailure::Type::Mb);
|
||||
BOOST_CHECK(f1.type == CR::WellFailure::Type::MassBalance);
|
||||
BOOST_CHECK(f1.severity == CR::Severity::TooLarge);
|
||||
BOOST_CHECK(f1.phase == 2);
|
||||
BOOST_CHECK(f1.well_name == "INJECTOR-XYZ");
|
||||
@ -88,12 +88,12 @@ BOOST_AUTO_TEST_CASE(Failures)
|
||||
BOOST_CHECK(f.cell_index == 100);
|
||||
BOOST_REQUIRE(s1.wellFailures().size() == 2);
|
||||
const auto f0 = s1.wellFailures()[0];
|
||||
BOOST_CHECK(f0.type == CR::WellFailure::Type::CtrlTHP);
|
||||
BOOST_CHECK(f0.type == CR::WellFailure::Type::ControlTHP);
|
||||
BOOST_CHECK(f0.severity == CR::Severity::Normal);
|
||||
BOOST_CHECK(f0.phase == -1);
|
||||
BOOST_CHECK(f0.well_name == "PRODUCER-123");
|
||||
const auto f1 = s1.wellFailures()[1];
|
||||
BOOST_CHECK(f1.type == CR::WellFailure::Type::Mb);
|
||||
BOOST_CHECK(f1.type == CR::WellFailure::Type::MassBalance);
|
||||
BOOST_CHECK(f1.severity == CR::Severity::TooLarge);
|
||||
BOOST_CHECK(f1.phase == 2);
|
||||
BOOST_CHECK(f1.well_name == "INJECTOR-XYZ");
|
||||
@ -116,12 +116,12 @@ BOOST_AUTO_TEST_CASE(Failures)
|
||||
BOOST_CHECK(s1.reservoirFailures().empty());
|
||||
BOOST_REQUIRE(s1.wellFailures().size() == 2);
|
||||
const auto f0 = s1.wellFailures()[0];
|
||||
BOOST_CHECK(f0.type == CR::WellFailure::Type::CtrlTHP);
|
||||
BOOST_CHECK(f0.type == CR::WellFailure::Type::ControlTHP);
|
||||
BOOST_CHECK(f0.severity == CR::Severity::Normal);
|
||||
BOOST_CHECK(f0.phase == -1);
|
||||
BOOST_CHECK(f0.well_name == "PRODUCER-123");
|
||||
const auto f1 = s1.wellFailures()[1];
|
||||
BOOST_CHECK(f1.type == CR::WellFailure::Type::Mb);
|
||||
BOOST_CHECK(f1.type == CR::WellFailure::Type::MassBalance);
|
||||
BOOST_CHECK(f1.severity == CR::Severity::TooLarge);
|
||||
BOOST_CHECK(f1.phase == 2);
|
||||
BOOST_CHECK(f1.well_name == "INJECTOR-XYZ");
|
||||
|
Loading…
Reference in New Issue
Block a user