From 64143cd4170f26ef383dabf6a48be2c1fb8b37b1 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Wed, 29 Jun 2022 11:54:36 +0200 Subject: [PATCH 1/3] when a valve is shut, the rate and pressure drop will be zero --- opm/simulators/wells/MultisegmentWellEval.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/opm/simulators/wells/MultisegmentWellEval.cpp b/opm/simulators/wells/MultisegmentWellEval.cpp index 3f1e79f7a..80c9c229e 100644 --- a/opm/simulators/wells/MultisegmentWellEval.cpp +++ b/opm/simulators/wells/MultisegmentWellEval.cpp @@ -1554,6 +1554,18 @@ assembleICDPressureEq(const int seg, // top segment can not be a spiral ICD device assert(seg != 0); + if(this->segmentSet()[seg].segmentType() == Segment::SegmentType::VALVE) { + const Valve& valve = this->segmentSet()[seg].valve(); + if (valve.status() == Opm::ICDStatus::SHUT) { // we switch here to be a zero rate equation + resWell_[seg][SPres] = this->primary_variables_evaluation_[seg][GTotal].value(); + duneD_[seg][seg][SPres][GTotal] = 1.; + + auto& ws = well_state.well(baseif_.indexOfWell()); + ws.segments.pressure_drop_friction[seg] = 0.; + return; + } + } + // the pressure equation is something like // p_seg - deltaP - p_outlet = 0. // the major part is how to calculate the deltaP From ed78d8c99a326b2e38bee76355c4ce9da2cc426f Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Wed, 29 Jun 2022 13:32:14 +0200 Subject: [PATCH 2/3] adding a regression test for WSEGVALV --- compareECLFiles.cmake | 6 ++++++ tests/update_reference_data.sh | 1 + 2 files changed, 7 insertions(+) diff --git a/compareECLFiles.cmake b/compareECLFiles.cmake index d10f1d1c5..b3c09d79f 100755 --- a/compareECLFiles.cmake +++ b/compareECLFiles.cmake @@ -971,6 +971,12 @@ add_test_compareECLFiles(CASENAME wsegaicd ABS_TOL ${abs_tol} REL_TOL ${rel_tol}) +add_test_compareECLFiles(CASENAME wsegvalv + FILENAME BASE_MSW_WSEGVALV + SIMULATOR flow + ABS_TOL ${abs_tol} + REL_TOL ${rel_tol}) + add_test_compareECLFiles(CASENAME nnc FILENAME NNC_AND_EDITNNC SIMULATOR flow diff --git a/tests/update_reference_data.sh b/tests/update_reference_data.sh index eb056cc2e..eeb7dcb3c 100755 --- a/tests/update_reference_data.sh +++ b/tests/update_reference_data.sh @@ -154,6 +154,7 @@ tests[udq_pyaction]="flow udq_actionx PYACTION_WCONPROD" tests[spe1_foam]="flow spe1_foam SPE1FOAM" tests[wsegsicd]="flow wsegsicd TEST_WSEGSICD" tests[wsegaicd]="flow wsegaicd BASE_MSW_WSEGAICD" +tests[wsegvalv]="flow wsegvalv BASE_MSW_WSEGVALV" tests[bc_lab]="flow bc_lab BC_LAB" tests[pinch_multz_all]="flow pinch PINCH_MULTZ_ALL" tests[pinch_multz_all_barrier]="flow pinch PINCH_MULTZ_ALL_BARRIER" From 1b3cee80887858b965cee79d4b80dc0e5bda45e7 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Wed, 29 Jun 2022 14:20:35 +0200 Subject: [PATCH 3/3] using C++17 style for to reduce nesting level of for loop --- opm/simulators/wells/MultisegmentWellEval.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellEval.cpp b/opm/simulators/wells/MultisegmentWellEval.cpp index 80c9c229e..e9a3eafd4 100644 --- a/opm/simulators/wells/MultisegmentWellEval.cpp +++ b/opm/simulators/wells/MultisegmentWellEval.cpp @@ -1554,16 +1554,15 @@ assembleICDPressureEq(const int seg, // top segment can not be a spiral ICD device assert(seg != 0); - if(this->segmentSet()[seg].segmentType() == Segment::SegmentType::VALVE) { - const Valve& valve = this->segmentSet()[seg].valve(); - if (valve.status() == Opm::ICDStatus::SHUT) { // we switch here to be a zero rate equation - resWell_[seg][SPres] = this->primary_variables_evaluation_[seg][GTotal].value(); - duneD_[seg][seg][SPres][GTotal] = 1.; + if (const auto& segment = this->segmentSet()[seg]; + (segment.segmentType() == Segment::SegmentType::VALVE) && + (segment.valve().status() == Opm::ICDStatus::SHUT) ) { // we use a zero rate equation to handle SHUT valve + resWell_[seg][SPres] = this->primary_variables_evaluation_[seg][GTotal].value(); + duneD_[seg][seg][SPres][GTotal] = 1.; - auto& ws = well_state.well(baseif_.indexOfWell()); - ws.segments.pressure_drop_friction[seg] = 0.; - return; - } + auto& ws = well_state.well(baseif_.indexOfWell()); + ws.segments.pressure_drop_friction[seg] = 0.; + return; } // the pressure equation is something like